Search in sources :

Example 1 with ConcurStandardAccountingExtractDetailLine

use of edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine in project cu-kfs by CU-CommunityApps.

the class ConcurStandardAccountingExtractCashAdvanceServiceImpl method findAccountingInfoForCashAdvanceLine.

@Override
public ConcurAccountInfo findAccountingInfoForCashAdvanceLine(ConcurStandardAccountingExtractDetailLine cashAdvanceLine, List<ConcurStandardAccountingExtractDetailLine> saeLines) {
    LOG.debug("findAccountingInfoForCashAdvanceLine, entering");
    ConcurAccountInfo info = new ConcurAccountInfo();
    String cashAdvanceReportEntryId = cashAdvanceLine.getReportEntryId();
    if (LOG.isDebugEnabled()) {
        LOG.debug("findAccountingInfoForCashAdvanceLine, cashAdvanceReportEntryId: " + cashAdvanceReportEntryId);
    }
    for (ConcurStandardAccountingExtractDetailLine line : saeLines) {
        if (StringUtils.equalsIgnoreCase(line.getReportEntryId(), cashAdvanceReportEntryId) && !isCashAdvanceLine(line)) {
            info.setChart(line.getChartOfAccountsCode());
            info.setAccountNumber(line.getAccountNumber());
            info.setSubAccountNumber(line.getSubAccountNumber());
            info.setObjectCode(line.getJournalAccountCode());
            info.setSubObjectCode(line.getSubObjectCode());
            info.setProjectCode(line.getProjectCode());
            info.setOrgRefId(line.getOrgRefId());
            if (LOG.isDebugEnabled()) {
                LOG.debug("findAccountingInfoForCashAdvanceLine, returning Concur account info: " + info.toString());
            }
            break;
        }
    }
    return info;
}
Also used : ConcurAccountInfo(edu.cornell.kfs.concur.businessobjects.ConcurAccountInfo) ConcurStandardAccountingExtractDetailLine(edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine)

Example 2 with ConcurStandardAccountingExtractDetailLine

use of edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine 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 3 with ConcurStandardAccountingExtractDetailLine

use of edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine 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)

Example 4 with ConcurStandardAccountingExtractDetailLine

use of edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine 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 5 with ConcurStandardAccountingExtractDetailLine

use of edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine 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)

Aggregations

ConcurStandardAccountingExtractDetailLine (edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine)19 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)8 Test (org.junit.Test)3 OriginEntryFull (org.kuali.kfs.gl.businessobject.OriginEntryFull)3 ConcurAccountInfo (edu.cornell.kfs.concur.businessobjects.ConcurAccountInfo)2 ConcurSAEDetailLineFixture (edu.cornell.kfs.concur.batch.fixture.ConcurSAEDetailLineFixture)1 ConcurBatchReportLineValidationErrorItem (edu.cornell.kfs.concur.batch.report.ConcurBatchReportLineValidationErrorItem)1 PdpFeedFileBaseEntry (edu.cornell.kfs.concur.batch.xmlObjects.PdpFeedFileBaseEntry)1 ArrayList (java.util.ArrayList)1