diff --git a/backend/ops_api/ops/utils/cans.py b/backend/ops_api/ops/utils/cans.py index 02bbf6af01..3ab42ac268 100644 --- a/backend/ops_api/ops/utils/cans.py +++ b/backend/ops_api/ops/utils/cans.py @@ -87,8 +87,6 @@ def get_can_funding_summary(can: CAN, fiscal_year: Optional[int] = None) -> CanF total_funding = sum([c.budget for c in can.funding_budgets if c.fiscal_year == fiscal_year]) or 0 - carry_forward_funding = sum([c.budget for c in can.funding_budgets[1:] if c.fiscal_year == fiscal_year]) or 0 - new_funding = get_new_funding_by_fiscal_year(can, fiscal_year) planned_funding = get_funding_by_budget_line_item_status(can, BudgetLineItemStatus.PLANNED, fiscal_year) @@ -102,8 +100,6 @@ def get_can_funding_summary(can: CAN, fiscal_year: Optional[int] = None) -> CanF total_funding = sum([c.budget for c in can.funding_budgets]) or 0 - carry_forward_funding = sum([c.budget for c in can.funding_budgets[1:]]) or 0 - new_funding = get_new_funding_by_funding_details(can) planned_funding = get_funding_by_budget_line_item_status(can, BudgetLineItemStatus.PLANNED, None) @@ -128,7 +124,7 @@ def get_can_funding_summary(can: CAN, fiscal_year: Optional[int] = None) -> CanF "expiration_date": f"10/01/{can.obligate_by}" if can.obligate_by else "", } ], - "carry_forward_funding": carry_forward_funding, + "carry_forward_funding": available_funding, # Carry forward funding is the same as available funding "received_funding": received_funding, "expected_funding": total_funding - received_funding, "in_draft_funding": in_draft_funding, 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 a38012bc72..ded5d1e02b 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 @@ -185,7 +185,7 @@ def test_get_can_funding_summary_no_fiscal_year(loaded_db, test_can) -> None: "expiration_date": "10/01/2024", } ], - "carry_forward_funding": 0, + "carry_forward_funding": Decimal("-860000.00"), "expected_funding": Decimal("260000.0"), "in_draft_funding": 0, "in_execution_funding": Decimal("2000000.00"), @@ -279,7 +279,7 @@ def test_get_can_funding_summary_with_fiscal_year(loaded_db, test_can) -> None: "expiration_date": "10/01/2024", } ], - "carry_forward_funding": 0, + "carry_forward_funding": Decimal("1140000.0"), "in_draft_funding": Decimal("0.0"), "expected_funding": Decimal("260000.0"), "in_execution_funding": 0, @@ -316,7 +316,7 @@ def test_cans_get_can_funding_summary(auth_client: FlaskClient, test_cans: list[ assert len(response.json["cans"]) == 2 assert available_funding == "3340000.00" - assert carry_forward_funding == "10000000.0" + assert carry_forward_funding == "3340000.00" assert response.json["new_funding"] == "1340000.0" diff --git a/frontend/src/components/Agreements/AgreementCANReviewAccordion/AgreementCANReviewAccordion.test.jsx b/frontend/src/components/Agreements/AgreementCANReviewAccordion/AgreementCANReviewAccordion.test.jsx index e7ab5d1c8b..56a14fcae8 100644 --- a/frontend/src/components/Agreements/AgreementCANReviewAccordion/AgreementCANReviewAccordion.test.jsx +++ b/frontend/src/components/Agreements/AgreementCANReviewAccordion/AgreementCANReviewAccordion.test.jsx @@ -1238,45 +1238,47 @@ const canData = [ const canFundingCardData = { available_funding: "14300000.00", - cans: [{ - can: { - appropriation_date: "2023-10-01T00:00:00.000000Z", - active_period: 1, - arrangement_type: "OPRE_APPROPRIATION", - authorizer: 26, - authorizer_id: 26, - budget_line_items: [15011, 15017, 15020], - can_type: null, - created_by: null, - created_by_user: null, - created_on: "2024-07-29T14:44:58.757452Z", - description: "Social Science Research and Development", - display_name: "G99PHS9", - division_id: 6, - expiration_date: "2024-09-01T00:00:00.000000Z", - external_authorizer_id: null, - funding_sources: [26], - id: 502, - managing_portfolio: 8, - portfolio_id: 8, - nick_name: "SSRD", - number: "G99PHS9", - projects: [], - shared_portfolios: [], - updated_by: null, - updated_by_user: null, - updated_on: "2024-07-29T14:44:58.757452Z", - versions: [ - { - id: 502, - transaction_id: 208 - } - ] - }, - carry_forward_label: "Carry-Forward", - expiration_date: "09/01/2024", - }], - carry_forward_funding: 0, + cans: [ + { + can: { + appropriation_date: "2023-10-01T00:00:00.000000Z", + active_period: 1, + arrangement_type: "OPRE_APPROPRIATION", + authorizer: 26, + authorizer_id: 26, + budget_line_items: [15011, 15017, 15020], + can_type: null, + created_by: null, + created_by_user: null, + created_on: "2024-07-29T14:44:58.757452Z", + description: "Social Science Research and Development", + display_name: "G99PHS9", + division_id: 6, + expiration_date: "2024-09-01T00:00:00.000000Z", + external_authorizer_id: null, + funding_sources: [26], + id: 502, + managing_portfolio: 8, + portfolio_id: 8, + nick_name: "SSRD", + number: "G99PHS9", + projects: [], + shared_portfolios: [], + updated_by: null, + updated_by_user: null, + updated_on: "2024-07-29T14:44:58.757452Z", + versions: [ + { + id: 502, + transaction_id: 208 + } + ] + }, + carry_forward_label: "Carry-Forward", + expiration_date: "09/01/2024" + } + ], + carry_forward_funding: "14300000.00", expected_funding: "5000000.00", in_draft_funding: 0, in_execution_funding: "2000000.00", @@ -1289,45 +1291,47 @@ const canFundingCardData = { const canFundingCardData2 = { available_funding: "1979500.00", - cans: [{ - can: { - appropriation_date: "2022-10-01T00:00:00.000000Z", - active_period: 1, - arrangement_type: "OPRE_APPROPRIATION", - authorizer: 26, - authorizer_id: 26, - budget_line_items: [15018, 15021], - can_type: null, - created_by: null, - created_by_user: null, - created_on: "2024-07-29T14:44:58.941288Z", - description: "Example CAN", - display_name: "G99XXX8", - division_id: 4, - expiration_date: "2023-09-01T00:00:00.000000Z", - external_authorizer_id: null, - funding_sources: [26], - id: 512, - managing_portfolio: 3, - portfolio_id: 3, - nick_name: "", - number: "G99XXX8", - projects: [1000], - shared_portfolios: [], - updated_by: null, - updated_by_user: null, - updated_on: "2024-07-29T14:44:58.941288Z", - versions: [ - { - id: 512, - transaction_id: 229 - } - ] - }, - carry_forward_label: "Carry-Forward", - expiration_date: "09/01/2023", - }], - carry_forward_funding: 0, + cans: [ + { + can: { + appropriation_date: "2022-10-01T00:00:00.000000Z", + active_period: 1, + arrangement_type: "OPRE_APPROPRIATION", + authorizer: 26, + authorizer_id: 26, + budget_line_items: [15018, 15021], + can_type: null, + created_by: null, + created_by_user: null, + created_on: "2024-07-29T14:44:58.941288Z", + description: "Example CAN", + display_name: "G99XXX8", + division_id: 4, + expiration_date: "2023-09-01T00:00:00.000000Z", + external_authorizer_id: null, + funding_sources: [26], + id: 512, + managing_portfolio: 3, + portfolio_id: 3, + nick_name: "", + number: "G99XXX8", + projects: [1000], + shared_portfolios: [], + updated_by: null, + updated_by_user: null, + updated_on: "2024-07-29T14:44:58.941288Z", + versions: [ + { + id: 512, + transaction_id: 229 + } + ] + }, + carry_forward_label: "Carry-Forward", + expiration_date: "09/01/2023" + } + ], + carry_forward_funding: "1979500.00", expected_funding: "520000.00", in_execution_funding: 0, obligated_funding: "500.00", @@ -1338,45 +1342,47 @@ const canFundingCardData2 = { const canFundingCard_G994426 = { available_funding: "37000000.00", - cans: [{ - can: { - appropriation_date: "2023-10-01T00:00:00.000000Z", - active_period: 1, - arrangement_type: "OPRE_APPROPRIATION", - authorizer: 26, - authorizer_id: 26, - budget_line_items: [15000, 15001, 15012, 15022, 15023], - can_type: null, - created_by: null, - created_by_user: null, - created_on: "2024-08-02T13:45:56.155989Z", - description: "Head Start Research", - display_name: "G994426", - division_id: 4, - expiration_date: "2024-09-01T00:00:00.000000Z", - external_authorizer_id: null, - funding_sources: [26], - id: 504, - managing_portfolio: 2, - portfolio_id: 2, - nick_name: "HS", - number: "G994426", - projects: [], - shared_portfolios: [], - updated_by: null, - updated_by_user: null, - updated_on: "2024-08-02T13:45:56.155989Z", - versions: [ - { - id: 504, - transaction_id: 212 - } - ] - }, - carry_forward_label: "Carry-Forward", - expiration_date: "09/01/2024", - }], - carry_forward_funding: 0, + cans: [ + { + can: { + appropriation_date: "2023-10-01T00:00:00.000000Z", + active_period: 1, + arrangement_type: "OPRE_APPROPRIATION", + authorizer: 26, + authorizer_id: 26, + budget_line_items: [15000, 15001, 15012, 15022, 15023], + can_type: null, + created_by: null, + created_by_user: null, + created_on: "2024-08-02T13:45:56.155989Z", + description: "Head Start Research", + display_name: "G994426", + division_id: 4, + expiration_date: "2024-09-01T00:00:00.000000Z", + external_authorizer_id: null, + funding_sources: [26], + id: 504, + managing_portfolio: 2, + portfolio_id: 2, + nick_name: "HS", + number: "G994426", + projects: [], + shared_portfolios: [], + updated_by: null, + updated_by_user: null, + updated_on: "2024-08-02T13:45:56.155989Z", + versions: [ + { + id: 504, + transaction_id: 212 + } + ] + }, + carry_forward_label: "Carry-Forward", + expiration_date: "09/01/2024" + } + ], + carry_forward_funding: "37000000.00", expected_funding: "16000000.00", in_execution_funding: "2000000.00", obligated_funding: 0, diff --git a/frontend/src/components/CANs/CANFundingCard/CanFundingCard.test.jsx b/frontend/src/components/CANs/CANFundingCard/CanFundingCard.test.jsx index 481d780bb1..51126a9ca1 100644 --- a/frontend/src/components/CANs/CANFundingCard/CanFundingCard.test.jsx +++ b/frontend/src/components/CANs/CANFundingCard/CanFundingCard.test.jsx @@ -55,45 +55,47 @@ const canData = { const canFundingCardData = { available_funding: "14300000.00", - cans: [{ - can: { - appropriation_date: "2023-10-01T00:00:00.000000Z", - active_period: 1, - arrangement_type: "OPRE_APPROPRIATION", - authorizer: 26, - authorizer_id: 26, - budget_line_items: [15011, 15017, 15020], - can_type: null, - created_by: null, - created_by_user: null, - created_on: "2024-07-29T14:44:58.757452Z", - description: "Social Science Research and Development", - display_name: "G99PHS9", - division_id: 6, - expiration_date: "2024-09-01T00:00:00.000000Z", - external_authorizer_id: null, - funding_sources: [26], - id: 502, - managing_portfolio: 8, - portfolio_id: 8, - nick_name: "SSRD", - number: "G99PHS9", - projects: [], - shared_portfolios: [], - updated_by: null, - updated_by_user: null, - updated_on: "2024-07-29T14:44:58.757452Z", - versions: [ - { - id: 502, - transaction_id: 208 - } - ] - }, - carry_forward_label: "Carry-Forward", - expiration_date: "09/01/2024", - }], - carry_forward_funding: 0, + cans: [ + { + can: { + appropriation_date: "2023-10-01T00:00:00.000000Z", + active_period: 1, + arrangement_type: "OPRE_APPROPRIATION", + authorizer: 26, + authorizer_id: 26, + budget_line_items: [15011, 15017, 15020], + can_type: null, + created_by: null, + created_by_user: null, + created_on: "2024-07-29T14:44:58.757452Z", + description: "Social Science Research and Development", + display_name: "G99PHS9", + division_id: 6, + expiration_date: "2024-09-01T00:00:00.000000Z", + external_authorizer_id: null, + funding_sources: [26], + id: 502, + managing_portfolio: 8, + portfolio_id: 8, + nick_name: "SSRD", + number: "G99PHS9", + projects: [], + shared_portfolios: [], + updated_by: null, + updated_by_user: null, + updated_on: "2024-07-29T14:44:58.757452Z", + versions: [ + { + id: 502, + transaction_id: 208 + } + ] + }, + carry_forward_label: "Carry-Forward", + expiration_date: "09/01/2024" + } + ], + carry_forward_funding: "14300000.00", expected_funding: "5000000.00", in_draft_funding: 0, in_execution_funding: "2000000.00", diff --git a/frontend/src/components/CANs/CanCard/CanCard.test.jsx b/frontend/src/components/CANs/CanCard/CanCard.test.jsx index 806e812fb3..35c0471561 100644 --- a/frontend/src/components/CANs/CanCard/CanCard.test.jsx +++ b/frontend/src/components/CANs/CanCard/CanCard.test.jsx @@ -92,45 +92,47 @@ const mockFiscalYear = 2023; const mockCanFundingData = { available_funding: "7000000.00", - cans: [{ - can: { - appropriation_date: "2023-10-01T00:00:00.000000Z", - active_period: 1, - arrangement_type: "OPRE_APPROPRIATION", - authorizer: 26, - authorizer_id: 26, - budget_line_items: [15012, 15022, 15023, 15001, 15000], - can_type: null, - created_by: null, - created_by_user: null, - created_on: "2024-08-22T13:24:43.428178Z", - description: "Head Start Research", - display_name: "G994426", - division_id: 4, - expiration_date: "2024-09-01T00:00:00.000000Z", - external_authorizer_id: null, - funding_sources: [26], - id: 504, - managing_portfolio: 2, - portfolio_id: 2, - nick_name: "HS", - number: "G994426", - projects: [], - shared_portfolios: [], - updated_by: null, - updated_by_user: null, - updated_on: "2024-08-22T13:24:43.428178Z", - versions: [ - { - id: 504, - transaction_id: 216 - } - ] - }, - carry_forward_label: "Carry-Forward", - expiration_date: "09/01/2024", - }], - carry_forward_funding: 0, + cans: [ + { + can: { + appropriation_date: "2023-10-01T00:00:00.000000Z", + active_period: 1, + arrangement_type: "OPRE_APPROPRIATION", + authorizer: 26, + authorizer_id: 26, + budget_line_items: [15012, 15022, 15023, 15001, 15000], + can_type: null, + created_by: null, + created_by_user: null, + created_on: "2024-08-22T13:24:43.428178Z", + description: "Head Start Research", + display_name: "G994426", + division_id: 4, + expiration_date: "2024-09-01T00:00:00.000000Z", + external_authorizer_id: null, + funding_sources: [26], + id: 504, + managing_portfolio: 2, + portfolio_id: 2, + nick_name: "HS", + number: "G994426", + projects: [], + shared_portfolios: [], + updated_by: null, + updated_by_user: null, + updated_on: "2024-08-22T13:24:43.428178Z", + versions: [ + { + id: 504, + transaction_id: 216 + } + ] + }, + carry_forward_label: "Carry-Forward", + expiration_date: "09/01/2024" + } + ], + carry_forward_funding: "7000000.00", expected_funding: "4000000.00", in_draft_funding: 0, in_execution_funding: "2000000.00",