From ded1ae48aa3cd953a695e7e7e736ae0021866d5b Mon Sep 17 00:00:00 2001 From: Jonathan Nalley Date: Tue, 14 Jan 2025 01:18:52 -0500 Subject: [PATCH 1/3] feat: adds new Other CAN Method of Transfer --- ...f396e_adding_new_can_method_of_transfer.py | 42 +++++++++++++++++++ backend/models/cans.py | 1 + 2 files changed, 43 insertions(+) create mode 100644 backend/alembic/versions/2025_01_14_0616-52bf070f396e_adding_new_can_method_of_transfer.py diff --git a/backend/alembic/versions/2025_01_14_0616-52bf070f396e_adding_new_can_method_of_transfer.py b/backend/alembic/versions/2025_01_14_0616-52bf070f396e_adding_new_can_method_of_transfer.py new file mode 100644 index 0000000000..9d2d2d633e --- /dev/null +++ b/backend/alembic/versions/2025_01_14_0616-52bf070f396e_adding_new_can_method_of_transfer.py @@ -0,0 +1,42 @@ +"""adding new CAN Method of Transfer + +Revision ID: 52bf070f396e +Revises: 6615ac7d4eea +Create Date: 2025-01-14 06:16:14.707739+00:00 + +""" +from typing import Sequence, Union + +import sqlalchemy as sa +from alembic import op +from alembic_postgresql_enum import TableReference + +# revision identifiers, used by Alembic. +revision: str = '52bf070f396e' +down_revision: Union[str, None] = '6615ac7d4eea' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.sync_enum_values( + enum_schema='ops', + enum_name='canmethodoftransfer', + new_values=['DIRECT', 'COST_SHARE', 'IAA', 'IDDA', 'OTHER'], + affected_columns=[TableReference(table_schema='ops', table_name='can_funding_details', column_name='method_of_transfer'), TableReference(table_schema='ops', table_name='can_funding_details_version', column_name='method_of_transfer')], + enum_values_to_rename=[], + ) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.sync_enum_values( + enum_schema='ops', + enum_name='canmethodoftransfer', + new_values=['DIRECT', 'COST_SHARE', 'IAA', 'IDDA'], + affected_columns=[TableReference(table_schema='ops', table_name='can_funding_details', column_name='method_of_transfer'), TableReference(table_schema='ops', table_name='can_funding_details_version', column_name='method_of_transfer')], + enum_values_to_rename=[], + ) + # ### end Alembic commands ### diff --git a/backend/models/cans.py b/backend/models/cans.py index d67f6190cd..031e23c8d8 100644 --- a/backend/models/cans.py +++ b/backend/models/cans.py @@ -18,6 +18,7 @@ class CANMethodOfTransfer(Enum): COST_SHARE = auto() IAA = auto() IDDA = auto() + OTHER = auto() class CANStatus(Enum): From b669e900b4aa8248d664b4a5e4615aaaff2cf83b Mon Sep 17 00:00:00 2001 From: Jonathan Nalley Date: Tue, 14 Jan 2025 01:49:10 -0500 Subject: [PATCH 2/3] test: update unit test for CAN funding summary --- backend/openapi.yml | 3 +++ .../tests/ops/funding_summary/test_can_funding_summary.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/openapi.yml b/backend/openapi.yml index 7222c8ee41..ea24d57f2f 100644 --- a/backend/openapi.yml +++ b/backend/openapi.yml @@ -1161,6 +1161,7 @@ paths: - COST_SHARE - IAA - IDDA + - OTHER example: [ "DIRECT", "IAA" ] - name: portfolio in: query @@ -2967,6 +2968,7 @@ components: - COST_SHARE - IAA - IDDA + - OTHER sub_allowance: type: string FundingDetails: @@ -3002,6 +3004,7 @@ components: - COST_SHARE - IAA - IDDA + - OTHER sub_allowance: type: string created_on: diff --git a/backend/ops_api/tests/ops/funding_summary/test_can_funding_summary.py b/backend/ops_api/tests/ops/funding_summary/test_can_funding_summary.py index 5a385b5489..a38012bc72 100644 --- a/backend/ops_api/tests/ops/funding_summary/test_can_funding_summary.py +++ b/backend/ops_api/tests/ops/funding_summary/test_can_funding_summary.py @@ -64,7 +64,7 @@ def test_can_get_can_funding_summary_invalid_transfer(auth_client: FlaskClient): query_params = f"can_ids={0}&fiscal_year=2023&transfer=INVALID" response = auth_client.get(f"/api/v1/can-funding-summary?{query_params}") assert response.status_code == 400 - assert response.json["Error"] == "Invalid 'transfer' value. Must be one of: DIRECT, COST_SHARE, IAA, IDDA." + assert response.json["Error"] == "Invalid 'transfer' value. Must be one of: DIRECT, COST_SHARE, IAA, IDDA, OTHER." def test_can_get_can_funding_summary_mou_transfer(auth_client: FlaskClient): From ef04f11231a10af024401583745ecc6ba631d2c5 Mon Sep 17 00:00:00 2001 From: John DeAngelis Date: Tue, 14 Jan 2025 09:38:57 -0500 Subject: [PATCH 3/3] chore: update mot in fe Signed-off-by: John DeAngelis --- frontend/src/components/CANs/CAN.constants.js | 3 ++- .../CANs/CANTransferComboBox/CANTransferComboBox.jsx | 3 ++- frontend/src/helpers/utils.js | 5 +++-- frontend/src/pages/cans/list/CanList.jsx | 3 +-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/CANs/CAN.constants.js b/frontend/src/components/CANs/CAN.constants.js index 87c246bee8..fb1b9835ff 100644 --- a/frontend/src/components/CANs/CAN.constants.js +++ b/frontend/src/components/CANs/CAN.constants.js @@ -2,5 +2,6 @@ export const CAN_TRANSFER = { DIRECT: "Direct", COST_SHARE: "COST_SHARE", IDDA: "IDDA", - IAA: "IAA" + IAA: "IAA", + OTHER: "OTHER" }; diff --git a/frontend/src/components/CANs/CANTransferComboBox/CANTransferComboBox.jsx b/frontend/src/components/CANs/CANTransferComboBox/CANTransferComboBox.jsx index 7c85435a73..be73514744 100644 --- a/frontend/src/components/CANs/CANTransferComboBox/CANTransferComboBox.jsx +++ b/frontend/src/components/CANs/CANTransferComboBox/CANTransferComboBox.jsx @@ -28,7 +28,8 @@ const CANTransferComboBox = ({ { id: 1, title: convertCodeForDisplay("methodOfTransfer", CAN_TRANSFER.DIRECT) }, { id: 2, title: convertCodeForDisplay("methodOfTransfer", CAN_TRANSFER.COST_SHARE) }, { id: 3, title: convertCodeForDisplay("methodOfTransfer", CAN_TRANSFER.IAA) }, - { id: 4, title: convertCodeForDisplay("methodOfTransfer", CAN_TRANSFER.IDDA) } + { id: 4, title: convertCodeForDisplay("methodOfTransfer", CAN_TRANSFER.IDDA) }, + { id: 5, title: convertCodeForDisplay("methodOfTransfer", CAN_TRANSFER.OTHER) } ]; return ( diff --git a/frontend/src/helpers/utils.js b/frontend/src/helpers/utils.js index 57e6980cf9..1353beda37 100644 --- a/frontend/src/helpers/utils.js +++ b/frontend/src/helpers/utils.js @@ -185,9 +185,10 @@ export const codesToDisplayText = { }, methodOfTransfer: { DIRECT: "Direct", - COST_SHARE: "MOU", + COST_SHARE: "Cost Share", IAA: "IAA", - IDDA: "IDDA" + IDDA: "IDDA", + OTHER: "Other" }, project: { ADMINISTRATIVE_AND_SUPPORT: "Admin & Support", diff --git a/frontend/src/pages/cans/list/CanList.jsx b/frontend/src/pages/cans/list/CanList.jsx index 424fdc5616..19f9f35aed 100644 --- a/frontend/src/pages/cans/list/CanList.jsx +++ b/frontend/src/pages/cans/list/CanList.jsx @@ -36,8 +36,7 @@ const CanList = () => { const activePeriodIds = filters.activePeriod.map((ap) => ap.id); const transferTitles = filters.transfer.map((t) => { - const title = t.title.toUpperCase(); - return title === "MOU" ? "COST_SHARE" : title; + return t.title.toUpperCase(); }); const portfolioAbbreviations = filters.portfolio.map((p) => p.abbr);