Search in sources :

Example 1 with KualiDecimal

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

the class ConcurStandardAccountExtractPdpEntryServiceImpl method cleanAccountingEntriesInDetailEntry.

protected void cleanAccountingEntriesInDetailEntry(PdpFeedDetailEntry newDetailEntry) {
    Map<DebitCreditTotal, KualiDecimal> totals = calculateTotals(newDetailEntry);
    KualiDecimal originalDebitTotal = totals.get(DebitCreditTotal.DEBIT);
    KualiDecimal originalCreditTotal = totals.get(DebitCreditTotal.CREDIT);
    if (areThereMoreCreditsThanDebits(originalDebitTotal, originalCreditTotal)) {
        LOG.info("cleanAccountingEntriesInDetailEntry, credits are greater than or equal to debits, so removing PDP transactions");
        newDetailEntry.getAccounting().clear();
    } else if (shouldDeductCreditsFromDebits(originalDebitTotal, originalCreditTotal)) {
        LOG.info("cleanAccountingEntriesInDetailEntry, deduct credits from debits required");
        deductCreditAmountsFromDebitTransactions(newDetailEntry, originalCreditTotal);
    } else {
        LOG.info("cleanAccountingEntriesInDetailEntry, no changes required to the accounting entries");
    }
    removeNonPositiveAccountingEntriesFromDetailEntry(newDetailEntry);
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 2 with KualiDecimal

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

the class ConcurStandardAccountExtractPdpEntryServiceImpl method buildPdpFeedTrailerEntry.

@Override
public PdpFeedTrailerEntry buildPdpFeedTrailerEntry(PdpFeedFileBaseEntry pdpFeedFileBaseEntry, ConcurStandardAccountingExtractBatchReportData reportData) {
    PdpFeedTrailerEntry trailerEntry = new PdpFeedTrailerEntry();
    KualiDecimal pdpTotal = KualiDecimal.ZERO;
    int numberOfDetails = 0;
    for (PdpFeedGroupEntry group : pdpFeedFileBaseEntry.getGroup()) {
        numberOfDetails += group.getDetail().size();
        for (PdpFeedDetailEntry detailEntry : group.getDetail()) {
            for (PdpFeedAccountingEntry accountingEntry : detailEntry.getAccounting()) {
                pdpTotal = pdpTotal.add(accountingEntry.getAmount());
            }
        }
    }
    trailerEntry.setDetailCount(numberOfDetails);
    trailerEntry.setDetailTotAmt(pdpTotal);
    reportData.getPdpRecordsProcessed().setRecordCount(numberOfDetails);
    reportData.getPdpRecordsProcessed().setDollarAmount(pdpTotal);
    return trailerEntry;
}
Also used : PdpFeedDetailEntry(edu.cornell.kfs.concur.batch.xmlObjects.PdpFeedDetailEntry) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) PdpFeedTrailerEntry(edu.cornell.kfs.concur.batch.xmlObjects.PdpFeedTrailerEntry) PdpFeedGroupEntry(edu.cornell.kfs.concur.batch.xmlObjects.PdpFeedGroupEntry) PdpFeedAccountingEntry(edu.cornell.kfs.concur.batch.xmlObjects.PdpFeedAccountingEntry)

Example 3 with KualiDecimal

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

the class ConcurStandardAccountingExtractServiceImpl method buildPdpFeedFileBaseEntry.

private PdpFeedFileBaseEntry buildPdpFeedFileBaseEntry(ConcurStandardAccountingExtractFile concurStandardAccountingExtractFile, ConcurStandardAccountingExtractBatchReportData reportData) {
    PdpFeedFileBaseEntry pdpFeedFileBaseEntry = new PdpFeedFileBaseEntry();
    pdpFeedFileBaseEntry.setVersion(ConcurConstants.FEED_FILE_ENTRY_HEADER_VERSION);
    pdpFeedFileBaseEntry.setHeader(getConcurStandardAccountExtractPdpEntryService().buildPdpFeedHeaderEntry(concurStandardAccountingExtractFile.getBatchDate()));
    int totalReimbursementLineCount = 0;
    KualiDecimal totalReimbursementDollarAmount = KualiDecimal.ZERO;
    for (ConcurStandardAccountingExtractDetailLine line : concurStandardAccountingExtractFile.getConcurStandardAccountingExtractDetailLines()) {
        if (shouldProcessSAELineToPDP(line)) {
            if (shouldLineTotalsBeAddedToReimbursementReportTotals(line)) {
                totalReimbursementLineCount++;
                totalReimbursementDollarAmount = totalReimbursementDollarAmount.add(line.getJournalAmount());
            }
            logJournalAccountCodeOverridden(line, reportData);
            String overriddenObjectCode = getParameterService().getParameterValueAsString(CUKFSConstants.ParameterNamespaces.CONCUR, CUKFSParameterKeyConstants.ALL_COMPONENTS, ConcurParameterConstants.CONCUR_SAE_PDP_DEFAULT_OBJECT_CODE);
            String overriddenSubObjectCode = StringUtils.EMPTY;
            if (getConcurStandardAccountingExtractValidationService().validateConcurStandardAccountingExtractDetailLineWithObjectCodeOverrideForPdp(line, reportData, overriddenObjectCode, overriddenSubObjectCode)) {
                buildAndUpdateAccountingEntryFromLine(pdpFeedFileBaseEntry, line, concurStandardAccountingExtractFile);
            }
        }
    }
    reportData.getReimbursementsInExpenseReport().setRecordCount(totalReimbursementLineCount);
    reportData.getReimbursementsInExpenseReport().setDollarAmount(totalReimbursementDollarAmount);
    pdpFeedFileBaseEntry.setTrailer(getConcurStandardAccountExtractPdpEntryService().buildPdpFeedTrailerEntry(pdpFeedFileBaseEntry, reportData));
    return pdpFeedFileBaseEntry;
}
Also used : PdpFeedFileBaseEntry(edu.cornell.kfs.concur.batch.xmlObjects.PdpFeedFileBaseEntry) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) ConcurStandardAccountingExtractDetailLine(edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine)

Example 4 with KualiDecimal

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

the class ConcurStandardAccountingExtractServiceImpl method buildAndUpdateAccountingEntryFromLine.

private void buildAndUpdateAccountingEntryFromLine(PdpFeedFileBaseEntry pdpFeedFileBaseEntry, ConcurStandardAccountingExtractDetailLine line, ConcurStandardAccountingExtractFile concurStandardAccountingExtractFile) {
    PdpFeedGroupEntry currentGroup = getGroupEntryForLine(pdpFeedFileBaseEntry, line);
    PdpFeedDetailEntry currentDetail = getDetailEntryForLine(currentGroup, line);
    PdpFeedAccountingEntry currentAccounting = getAccountingEntryForLine(currentDetail, line, concurStandardAccountingExtractFile);
    KualiDecimal newAmount = line.getJournalAmount().add(currentAccounting.getAmount());
    currentAccounting.setAmount(newAmount);
}
Also used : PdpFeedDetailEntry(edu.cornell.kfs.concur.batch.xmlObjects.PdpFeedDetailEntry) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) PdpFeedGroupEntry(edu.cornell.kfs.concur.batch.xmlObjects.PdpFeedGroupEntry) PdpFeedAccountingEntry(edu.cornell.kfs.concur.batch.xmlObjects.PdpFeedAccountingEntry)

Example 5 with KualiDecimal

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

the class ConcurStandardAccountingExtractValidationServiceImpl method validateAmountsAndDebitCreditCode.

@Override
public boolean validateAmountsAndDebitCreditCode(ConcurStandardAccountingExtractFile concurStandardAccountingExtractFile, ConcurStandardAccountingExtractBatchReportData reportData) {
    KualiDecimal journalTotal = concurStandardAccountingExtractFile.getJournalAmountTotal();
    KualiDecimal detailTotal = KualiDecimal.ZERO;
    boolean debitCreditValid = true;
    boolean employeeGroupIdValid = true;
    boolean journalTotalValidation = true;
    for (ConcurStandardAccountingExtractDetailLine line : concurStandardAccountingExtractFile.getConcurStandardAccountingExtractDetailLines()) {
        if (line.getJournalAmount() != null) {
            detailTotal = detailTotal.add(line.getJournalAmount());
        } else {
            String validationError = "Parsed a null KualiDecimal from the original value of " + line.getJournalAmountString();
            reportData.addValidationErrorFileLine(new ConcurBatchReportLineValidationErrorItem(line, validationError));
            LOG.error("validateAmountsAndDebitCreditCode, " + validationError);
            journalTotalValidation = false;
        }
        debitCreditValid &= validateDebitCreditField(line, reportData);
        employeeGroupIdValid &= validateEmployeeGroupId(line, reportData);
    }
    journalTotalValidation = journalTotalValidation && detailTotal.equals(journalTotal);
    if (journalTotalValidation) {
        LOG.debug("validateAmounts, journal total: " + journalTotal.doubleValue() + " and detailTotal: " + detailTotal.doubleValue() + " do match.");
    } else {
        String validationError = "The journal total (" + journalTotal + ") does not equal the detail line total (" + detailTotal + ")";
        reportData.addHeaderValidationError(validationError);
        LOG.error("validateAmounts, " + validationError);
    }
    return journalTotalValidation && debitCreditValid && employeeGroupIdValid;
}
Also used : ConcurBatchReportLineValidationErrorItem(edu.cornell.kfs.concur.batch.report.ConcurBatchReportLineValidationErrorItem) 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