Search in sources :

Example 46 with Fund

use of org.folio.rest.acq.model.finance.Fund in project mod-invoice by folio-org.

the class InvoiceHelper method mapExternalAcctNoToFundDistros.

private Map<FundExtNoExpenseClassExtNoPair, List<FundDistribution>> mapExternalAcctNoToFundDistros(Map<String, Map<String, List<FundDistribution>>> fundDistrosGroupedByFundIdAndExpenseClassExtNo, Map<String, List<Fund>> fundsGroupedByExternalAccountNo) {
    Map<FundExtNoExpenseClassExtNoPair, List<FundDistribution>> groupedFundDistribution = new HashMap<>();
    for (Map.Entry<String, List<Fund>> fundExternalAccountNoPair : fundsGroupedByExternalAccountNo.entrySet()) {
        String fundExternalAccountNo = fundExternalAccountNoPair.getKey();
        for (Fund fund : fundExternalAccountNoPair.getValue()) {
            Map<String, List<FundDistribution>> fundDistrsExpenseClassExtNo = fundDistrosGroupedByFundIdAndExpenseClassExtNo.get(fund.getId());
            for (Map.Entry<String, List<FundDistribution>> fundDistrs : fundDistrsExpenseClassExtNo.entrySet()) {
                String expenseClassExtAccountNo = fundDistrs.getKey();
                FundExtNoExpenseClassExtNoPair key = new FundExtNoExpenseClassExtNoPair(fundExternalAccountNo, expenseClassExtAccountNo);
                List<FundDistribution> fundDistributions = fundDistrs.getValue();
                updateFundDistributionsWithExpenseClassCode(fund, fundDistributions);
                Optional.ofNullable(groupedFundDistribution.get(key)).ifPresentOrElse(value -> value.addAll(fundDistributions), () -> groupedFundDistribution.put(key, fundDistributions));
            }
        }
    }
    return groupedFundDistribution;
}
Also used : FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) Fund(org.folio.rest.acq.model.finance.Fund) HashMap(java.util.HashMap) FundExtNoExpenseClassExtNoPair(org.folio.models.FundExtNoExpenseClassExtNoPair) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 47 with Fund

use of org.folio.rest.acq.model.finance.Fund in project mod-invoice by folio-org.

the class BudgetExpenseClassService method getFundIdExpenseClassIdParameters.

private List<Parameter> getFundIdExpenseClassIdParameters(InvoiceWorkflowDataHolder holder) {
    Fund fund = holder.getFund();
    ExpenseClass expenseClass = holder.getExpenseClass();
    return Arrays.asList(new Parameter().withKey(FUND_CODE).withValue(fund.getCode()), new Parameter().withKey(EXPENSE_CLASS_NAME).withValue(expenseClass.getName()));
}
Also used : ExpenseClass(org.folio.rest.acq.model.finance.ExpenseClass) BudgetExpenseClass(org.folio.rest.acq.model.finance.BudgetExpenseClass) Fund(org.folio.rest.acq.model.finance.Fund) Parameter(org.folio.rest.jaxrs.model.Parameter)

Aggregations

Fund (org.folio.rest.acq.model.finance.Fund)47 Test (org.junit.jupiter.api.Test)39 FundDistribution (org.folio.rest.jaxrs.model.FundDistribution)17 Budget (org.folio.rest.acq.model.finance.Budget)15 ArrayList (java.util.ArrayList)14 Transaction (org.folio.rest.acq.model.finance.Transaction)12 FiscalYear (org.folio.rest.acq.model.finance.FiscalYear)11 FundCollection (org.folio.rest.acq.model.finance.FundCollection)11 ReEncumbranceHolder (org.folio.models.ReEncumbranceHolder)10 Invoice (org.folio.rest.jaxrs.model.Invoice)10 InvoiceWorkflowDataHolder (org.folio.models.InvoiceWorkflowDataHolder)9 Error (org.folio.rest.jaxrs.model.Error)9 InvoiceLine (org.folio.rest.jaxrs.model.InvoiceLine)9 Matchers.containsString (org.hamcrest.Matchers.containsString)9 List (java.util.List)8 Headers (io.restassured.http.Headers)7 HttpException (org.folio.invoices.rest.exceptions.HttpException)7 JsonObject (io.vertx.core.json.JsonObject)6 Ledger (org.folio.rest.acq.model.finance.Ledger)6 ConversionQuery (javax.money.convert.ConversionQuery)5