Skip to content

Commit

Permalink
[MODFIN-402] Fixes to finance data endpoint (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
damien-git authored Feb 7, 2025
1 parent 4ba206e commit 6ae539f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ private Fund setNewValues(Fund fund, FyFinanceDataCollection entity) {
.orElseThrow();

fund.setDescription(fundFinanceData.getFundDescription());
fund.setFundStatus(Fund.FundStatus.fromValue(fundFinanceData.getFundStatus().value()));
if (fundFinanceData.getFundTags() != null && isNotEmpty(fundFinanceData.getFundTags().getTagList())) {
fund.setTags(new Tags().withTagList(fundFinanceData.getFundTags().getTagList()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ SELECT
'budgetName', budget.jsonb ->>'name',
'budgetStatus', budget.jsonb ->>'budgetStatus',
'budgetInitialAllocation', budget.jsonb ->>'initialAllocation',
'budgetCurrentAllocation', (budget.jsonb->'initialAllocation')::decimal + (budget.jsonb->'allocationTo')::decimal - (budget.jsonb->'allocationFrom')::decimal,
'budgetAllowableExpenditure', budget.jsonb ->>'allowableExpenditure',
'budgetAllowableEncumbrance', budget.jsonb ->>'allowableEncumbrance',
'budgetAcqUnitIds', budget.jsonb ->'acqUnitIds',
'groupId', groups.id,
'groupCode', groups.jsonb ->> 'code'
) as jsonb
FROM ${myuniversity}_${mymodule}.fiscal_year
LEFT OUTER JOIN ${myuniversity}_${mymodule}.ledger
ON ledger.fiscalyearoneid = fiscal_year.id
LEFT OUTER JOIN ${myuniversity}_${mymodule}.fund
INNER JOIN ${myuniversity}_${mymodule}.fiscal_year fy_one
ON fy_one.jsonb->>'series' = fiscal_year.jsonb->>'series'
INNER JOIN ${myuniversity}_${mymodule}.ledger
ON ledger.fiscalyearoneid = fy_one.id
INNER JOIN ${myuniversity}_${mymodule}.fund
ON fund.ledgerid = ledger.id
LEFT OUTER JOIN ${myuniversity}_${mymodule}.budget
ON fund.id = budget.fundid
ON budget.fundid = fund.id AND budget.fiscalYearId = fiscal_year.id
LEFT OUTER JOIN ${myuniversity}_${mymodule}.group_fund_fiscal_year
ON fund.id = group_fund_fiscal_year.fundid
ON group_fund_fiscal_year.fundid = fund.id
LEFT OUTER JOIN ${myuniversity}_${mymodule}.groups
ON group_fund_fiscal_year.groupid = groups.id;
ON groups.id = group_fund_fiscal_year.groupid;
3 changes: 2 additions & 1 deletion src/test/java/org/folio/rest/impl/FinanceDataApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void after() {

@Test
public void positive_testGetQuery() {
verifyCollectionQuantity(FINANCE_DATA_ENDPOINT + "?query=(fiscalYearId==7a4c4d30-3b63-4102-8e2d-3ee5792d7d02)", 21, TENANT_HEADER);
verifyCollectionQuantity(FINANCE_DATA_ENDPOINT + "?query=(fiscalYearId==7a4c4d30-3b63-4102-8e2d-3ee5792d7d02)", 24, TENANT_HEADER);
verifyCollectionQuantity(FINANCE_DATA_ENDPOINT + "?query=(fiscalYearId==9b1d00d1-1f3d-4f1c-8e4b-0f1e3b7b1b1b)", 0, TENANT_HEADER);

var response = getData(FINANCE_DATA_ENDPOINT + "?query=(fiscalYearId==7a4c4d30-3b63-4102-8e2d-3ee5792d7d02)", TENANT_HEADER);
Expand All @@ -74,6 +74,7 @@ public void positive_testGetQuery() {
assertNotNull(actualFyFinanceData.getBudgetName());
assertNotNull(actualFyFinanceData.getBudgetStatus());
assertNotNull(actualFyFinanceData.getBudgetInitialAllocation());
assertNotNull(actualFyFinanceData.getBudgetCurrentAllocation());
assertNotNull(actualFyFinanceData.getBudgetAllowableExpenditure());
assertNotNull(actualFyFinanceData.getBudgetAllowableEncumbrance());
assertNotNull(actualFyFinanceData.getBudgetAcqUnitIds());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private void verifyFundUpdates(FyFinanceDataCollection collection) {
assertNotEquals("CODE CHANGED", updatedFund.getCode());
assertNotEquals("NAME CHANGED", updatedFund.getName());

assertEquals(Fund.FundStatus.ACTIVE, updatedFund.getFundStatus());
assertEquals(Fund.FundStatus.INACTIVE, updatedFund.getFundStatus());
assertEquals("New Description", updatedFund.getDescription());
}

Expand Down Expand Up @@ -179,6 +179,7 @@ private FyFinanceDataCollection createTestFinanceDataCollection() {
.withBudgetName("NAME CHANGED")
.withBudgetStatus(FyFinanceData.BudgetStatus.INACTIVE)
.withBudgetInitialAllocation(1000.0)
.withBudgetCurrentAllocation(5000.0)
.withBudgetAllowableExpenditure(800.0)
.withBudgetAllowableEncumbrance(700.0)
.withBudgetAcqUnitIds(List.of("unit1"));
Expand Down

0 comments on commit 6ae539f

Please sign in to comment.