Skip to content

Commit

Permalink
Update Carry Forward Funding Calculation (#3313)
Browse files Browse the repository at this point in the history
* feat: update carry forward to total minus spent

* test: fix fe data

* chore: add comment to note carry forward is available
  • Loading branch information
maiyerlee authored Jan 21, 2025
1 parent f396937 commit 9597a43
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 203 deletions.
6 changes: 1 addition & 5 deletions backend/ops_api/ops/utils/cans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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,
Expand Down
Loading

0 comments on commit 9597a43

Please sign in to comment.