Search in sources :

Example 6 with KualiDecimal

use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class ConcurDetailLineGroupForCollector method buildOriginEntryForPaymentOffset.

protected Optional<OriginEntryFull> buildOriginEntryForPaymentOffset(OriginEntryFull cashEntry, List<ConcurStandardAccountingExtractDetailLine> cashLines) {
    KualiDecimal cashAmount = getSignedAmountFromOriginEntry(cashEntry);
    KualiDecimal cashAdvanceAmount = calculateAndUpdateUsableAmountForCashAdvanceLinesReferencedByRegularLines(cashLines);
    KualiDecimal cashAmountToOffset = cashAmount.add(cashAdvanceAmount);
    if (cashAmountToOffset.isZero()) {
        return Optional.empty();
    }
    OriginEntryFull offsetEntry = buildOffsetOriginEntry(cashEntry, cashAmountToOffset);
    offsetEntry.setFinancialObjectCode(collectorHelper.getPaymentOffsetObjectCode());
    offsetEntry.setFinancialSubObjectCode(collectorHelper.getDashOnlyPropertyValue(KFSPropertyConstants.SUB_OBJECT_CODE));
    return Optional.of(offsetEntry);
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) OriginEntryFull(org.kuali.kfs.gl.businessobject.OriginEntryFull)

Example 7 with KualiDecimal

use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class ConcurDetailLineGroupForCollector method addOffsetOriginEntriesForUnusedAtmCashAdvanceAmountLines.

protected void addOffsetOriginEntriesForUnusedAtmCashAdvanceAmountLines(Consumer<OriginEntryFull> entryConsumer, List<ConcurStandardAccountingExtractDetailLine> unusedAtmAmountLines) {
    if (CollectionUtils.isEmpty(unusedAtmAmountLines)) {
        return;
    }
    KualiDecimal totalAmount = calculateTotalAmountForLines(unusedAtmAmountLines);
    if (totalAmount.isNonZero()) {
        OriginEntryFull offsetEntry = this.buildOriginEntryForUnusedAtmAmountOffset(unusedAtmAmountLines, totalAmount);
        entryConsumer.accept(offsetEntry);
    }
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) OriginEntryFull(org.kuali.kfs.gl.businessobject.OriginEntryFull)

Example 8 with KualiDecimal

use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class ConcurDetailLineGroupForCollector method calculateTotalAmountForCashAdvanceLinesReferencedByRegularLines.

protected KualiDecimal calculateTotalAmountForCashAdvanceLinesReferencedByRegularLines(List<ConcurStandardAccountingExtractDetailLine> regularDetailLines) {
    if (totalCashAdvanceAmountsByReportEntryId.isEmpty()) {
        return KualiDecimal.ZERO;
    }
    KualiDecimal totalAmount = KualiDecimal.ZERO;
    String[] reportEntryIds = regularDetailLines.stream().map(ConcurStandardAccountingExtractDetailLine::getReportEntryId).distinct().toArray(String[]::new);
    for (String reportEntryId : reportEntryIds) {
        KualiDecimal subTotalAmount = totalCashAdvanceAmountsByReportEntryId.get(reportEntryId);
        if (subTotalAmount != null) {
            totalAmount = totalAmount.add(subTotalAmount);
        }
    }
    return totalAmount;
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) ConcurStandardAccountingExtractDetailLine(edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine)

Example 9 with KualiDecimal

use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class ConcurDetailLineGroupForCollector method calculateAndUpdateUsableAmountForCashAdvanceLinesReferencedByRegularLines.

protected KualiDecimal calculateAndUpdateUsableAmountForCashAdvanceLinesReferencedByRegularLines(List<ConcurStandardAccountingExtractDetailLine> regularDetailLines) {
    if (unusedCashAdvanceAmountsByReportEntryId.isEmpty()) {
        return KualiDecimal.ZERO;
    }
    KualiDecimal usableAmount = KualiDecimal.ZERO;
    for (ConcurStandardAccountingExtractDetailLine detailLine : regularDetailLines) {
        KualiDecimal lineAmount = detailLine.getJournalAmount();
        KualiDecimal oldUnusedAmount = unusedCashAdvanceAmountsByReportEntryId.getOrDefault(detailLine.getReportEntryId(), KualiDecimal.ZERO);
        if (lineAmount.isPositive() && oldUnusedAmount.isNegative()) {
            KualiDecimal newUnusedAmount = unusedCashAdvanceAmountsByReportEntryId.merge(detailLine.getReportEntryId(), lineAmount, KualiDecimal::add);
            if (newUnusedAmount.isPositive()) {
                usableAmount = usableAmount.add(oldUnusedAmount);
            } else {
                usableAmount = usableAmount.add(lineAmount.negated());
            }
        }
    }
    return usableAmount;
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) ConcurStandardAccountingExtractDetailLine(edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine)

Example 10 with KualiDecimal

use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class ConcurDetailLineGroupForCollector method calculateTotalCashAmountNotOffsetByCashAdvances.

protected KualiDecimal calculateTotalCashAmountNotOffsetByCashAdvances() {
    List<ConcurStandardAccountingExtractDetailLine> allCashLines = getSubGroupsOfType(ConcurSAECollectorLineType.CASH).stream().flatMap(List::stream).collect(Collectors.toCollection(ArrayList::new));
    KualiDecimal totalCashAmount = calculateTotalAmountForLines(allCashLines);
    KualiDecimal totalCashAdvanceAmount = calculateTotalAmountForCashAdvanceLinesReferencedByRegularLines(allCashLines);
    return totalCashAmount.add(totalCashAdvanceAmount);
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) ConcurStandardAccountingExtractDetailLine(edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine)

Aggregations

KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)209 ArrayList (java.util.ArrayList)37 HashMap (java.util.HashMap)19 Test (org.junit.Test)19 List (java.util.List)15 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)15 CapitalAssetInformation (org.kuali.kfs.fp.businessobject.CapitalAssetInformation)14 BigDecimal (java.math.BigDecimal)13 Date (java.sql.Date)13 Iterator (java.util.Iterator)12 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)12 KualiInteger (org.kuali.rice.core.api.util.type.KualiInteger)12 PaymentRequestItem (org.kuali.kfs.module.purap.businessobject.PaymentRequestItem)11 IOException (java.io.IOException)10 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)10 Map (java.util.Map)9 CapitalAccountingLines (org.kuali.kfs.fp.businessobject.CapitalAccountingLines)9 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)9 PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)9 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)8