Search in sources :

Example 26 with KualiDecimal

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

the class CheckReconciliationImportStep method setCheckReconciliationAttributes.

/**
 * Set CheckReconciliation Attributes
 *
 * @param hash
 * @return
 * @throws ParseException
 */
private CheckReconciliation setCheckReconciliationAttributes(Map<Integer, String> hash) throws ParseException {
    String checkNumber = null;
    Date checkDate = null;
    KualiDecimal amount = null;
    String accountNumber = null;
    String status = null;
    Date issueDate = null;
    String payeeName = "";
    String payeeID = "";
    // Cornell Columns
    Integer payeeNameCol = Integer.parseInt("12");
    Integer issueDateCol = Integer.parseInt("7");
    Integer payeeIDCol = Integer.parseInt("6");
    checkNumber = hash.get(checkNumCol);
    String rawCheckDate = hash.get(checkDateCol);
    if (rawCheckDate == null || rawCheckDate.equals("") || rawCheckDate.equals("000000"))
        rawCheckDate = "991231";
    checkDate = getGregorianCalendar(rawCheckDate).getTime();
    // checkDate     = dateformat.parse(rawCheckDate);  //Date Paid
    amount = isAmountDecimalValue ? new KualiDecimal(addDecimalPoint(hash.get(amountCol))) : new KualiDecimal(hash.get(amountCol));
    if (accountNumCol > 0)
        accountNumber = isAccountNumHeaderValue ? getHeaderValue(accountNumCol) : hash.get(accountNumCol);
    else
        accountNumber = getParameterService().getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.ACCOUNT_NUM);
    status = hash.get(statusCol);
    String issueDateRawValue = hash.get(issueDateCol);
    payeeName = hash.get(payeeNameCol);
    payeeID = hash.get(payeeIDCol);
    if (issueDateRawValue == null || issueDateRawValue.equals("") || issueDateRawValue.equals("000000"))
        issueDateRawValue = "991231";
    // issueDate = dateformat.parse(issueDateRawValue);
    issueDate = getGregorianCalendar(issueDateRawValue).getTime();
    CheckReconciliation cr = new CheckReconciliation();
    cr.setAmount(amount);
    cr.setCheckDate(new java.sql.Date(issueDate.getTime()));
    cr.setCheckNumber(new KualiInteger(checkNumber));
    cr.setBankAccountNumber(accountNumber);
    cr.setStatus(status);
    cr.setStatusChangeDate(new java.sql.Date(checkDate.getTime()));
    cr.setGlTransIndicator(false);
    cr.setPayeeName(payeeName);
    cr.setPayeeId(payeeID);
    return cr;
}
Also used : KualiInteger(org.kuali.kfs.core.api.util.type.KualiInteger) KualiInteger(org.kuali.kfs.core.api.util.type.KualiInteger) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) CheckReconciliation(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation) Date(java.util.Date)

Example 27 with KualiDecimal

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

the class CheckReconciliationImportStep method updateCheckStatus.

/**
 * Get Check Status  and update pdp
 *
 * @param cr Check Reconciliation Object
 * @return String
 */
private String updateCheckStatus(CheckReconciliation cr, Collection<Bank> banks, List<CheckReconError> records) throws Exception {
    String defaultStatus = CRConstants.EXCP;
    String oldStatus = CRConstants.EXCP;
    List<String> bankCodes = new ArrayList<String>();
    // Generate list of valid bank codes
    for (Bank bank : banks) {
        if (bank.getBankAccountNumber().equals(cr.getBankAccountNumber())) {
            bankCodes.add(bank.getBankCode());
        }
    }
    if (bankCodes.size() == 0) {
        throw new Exception("Invalid Bank Account Number : " + cr.getBankAccountNumber());
    }
    Collection<PaymentGroup> paymentGroups = glTransactionService.getAllPaymentGroupForSearchCriteria(cr.getCheckNumber(), bankCodes);
    KualiDecimal totalNetAmount = getTotalNetAmount(paymentGroups);
    for (PaymentGroup paymentGroup : paymentGroups) {
        /*
        	 * At Cornell Check amount may consist of one or more payment group amounts.  
        	 * 
            if( !cr.getAmount().equals(paymentGroup.getNetPaymentAmount()) ) {
                records.add(getCheckReconError(cr, "The check amount does not match payment net amount."));
            }
            */
        if (!(totalNetAmount.doubleValue() == cr.getAmount().doubleValue())) {
            records.add(getCheckReconError(cr, "The check amount does not match payment net amount from the payment groups."));
        }
        if (statusMap.get(cr.getStatus()) != null) {
            defaultStatus = statusMap.get(cr.getStatus());
            oldStatus = paymentGroup.getPaymentStatusCode();
            // Update PDP status and save
            KualiCode code = businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, defaultStatus);
            if (paymentGroup.getPaymentStatus() != ((PaymentStatus) code)) {
                paymentGroup.setPaymentStatus((PaymentStatus) code);
                paymentGroup.setLastUpdatedTimestamp(new Timestamp(cr.getStatusChangeDate().getTime()));
            }
            if (defaultStatus.equals(CRConstants.CLEARED)) {
                if (PaymentStatusCodes.EXTRACTED.equals(oldStatus)) {
                    businessObjectService.save(paymentGroup);
                    LOG.info("Check Status in the bank file is cleared. Updated Payment Group : " + paymentGroup.getId() + " Disbursement  " + paymentGroup.getDisbursementNbr());
                } else {
                    LOG.warn("Check Status in the bank file is cleared, but Payment Group " + paymentGroup.getId() + " for Disbursement " + paymentGroup.getDisbursementNbr() + " has a current status of " + oldStatus + " and cannot be cleared.");
                }
            }
        } else {
            LOG.warn("Update Payment Group Failed ( " + cr.getStatus() + ") ID : " + paymentGroup.getId());
        }
    }
    if (paymentGroups == null) {
        LOG.info("No Payments Found : " + cr.getBankAccountNumber() + "-" + cr.getCheckNumber());
    } else if (paymentGroups.size() == 0) {
        LOG.info("No Payments Found : " + cr.getBankAccountNumber() + "-" + cr.getCheckNumber());
    }
    return defaultStatus;
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) Bank(org.kuali.kfs.sys.businessobject.Bank) KualiCode(org.kuali.kfs.krad.bo.KualiCode) ArrayList(java.util.ArrayList) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) Timestamp(java.sql.Timestamp) ParseException(java.text.ParseException) PaymentStatus(org.kuali.kfs.pdp.businessobject.PaymentStatus)

Example 28 with KualiDecimal

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

the class ConcurCreateCashAdvancePdpFeedFileServiceImpl method buildPdpFeedBaseEntry.

private PdpFeedFileBaseEntry buildPdpFeedBaseEntry(ConcurStandardAccountingExtractFile standardAccountingExtractFile, ConcurSaeRequestedCashAdvanceBatchReportData reportData) {
    int totalPdpDetailRecordsCount = 0;
    KualiDecimal totalPdpDetailRecordsAmount = KualiDecimal.ZERO;
    PdpFeedFileBaseEntry pdpBaseEntry = new PdpFeedFileBaseEntry();
    pdpBaseEntry.setHeader(buildPdpFeedHeaderEntry(standardAccountingExtractFile.getBatchDate()));
    List<PdpFeedGroupEntry> groupEntries = new ArrayList<PdpFeedGroupEntry>();
    for (ConcurStandardAccountingExtractDetailLine detailFileLine : standardAccountingExtractFile.getConcurStandardAccountingExtractDetailLines()) {
        if (isDetailFileLineValidCashAdvanceRequest(detailFileLine)) {
            PdpFeedDetailEntry pdpDetailEntry = buildPdpFeedDetailEntry(detailFileLine, buildPdpFeedAccountingEntry(detailFileLine));
            List<PdpFeedDetailEntry> pdpDetailEntries = new ArrayList<PdpFeedDetailEntry>();
            pdpDetailEntries.add(pdpDetailEntry);
            groupEntries.add(buildPdpFeedGroupEntry(detailFileLine, buildPdpFeedPayeeIdEntry(detailFileLine), pdpDetailEntries));
            recordCashAdvanceGenerationInDuplicateTrackingTable(detailFileLine, pdpDetailEntry.getSourceDocNbr(), standardAccountingExtractFile.getOriginalFileName());
            totalPdpDetailRecordsCount++;
            totalPdpDetailRecordsAmount = totalPdpDetailRecordsAmount.add(detailFileLine.getCashAdvanceAmount());
        }
        updateReportDataForDetailFileLineBeingProcessed(reportData, detailFileLine, totalPdpDetailRecordsCount, totalPdpDetailRecordsAmount);
    }
    pdpBaseEntry.setGroup(groupEntries);
    pdpBaseEntry.setTrailer(buildPdpFeedTrailerEntry(totalPdpDetailRecordsCount, totalPdpDetailRecordsAmount));
    pdpBaseEntry.setVersion(ConcurConstants.FEED_FILE_ENTRY_HEADER_VERSION);
    return pdpBaseEntry;
}
Also used : PdpFeedFileBaseEntry(edu.cornell.kfs.concur.batch.xmlObjects.PdpFeedFileBaseEntry) ArrayList(java.util.ArrayList) PdpFeedDetailEntry(edu.cornell.kfs.concur.batch.xmlObjects.PdpFeedDetailEntry) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) PdpFeedGroupEntry(edu.cornell.kfs.concur.batch.xmlObjects.PdpFeedGroupEntry) ConcurStandardAccountingExtractDetailLine(edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine)

Example 29 with KualiDecimal

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

the class ConcurCreateCashAdvancePdpFeedFileServiceImpl method updateReportDataRequestExtractFileTotalCountAndAmountTotals.

private void updateReportDataRequestExtractFileTotalCountAndAmountTotals(ConcurSaeRequestedCashAdvanceBatchReportData reportData, ConcurStandardAccountingExtractDetailLine detailFileLine) {
    reportData.getTotalsForFile().incrementRecordCount();
    KualiDecimal amountForTotal = ObjectUtils.isNotNull(detailFileLine.getCashAdvanceAmount()) ? detailFileLine.getCashAdvanceAmount() : detailFileLine.getJournalAmount();
    reportData.getTotalsForFile().addDollarAmount(amountForTotal);
}
Also used : KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal)

Example 30 with KualiDecimal

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

the class AssetGlobalServiceImpl method totalPaymentByAsset.

/**
 * We need to calculate asset total amount from the sum of its payments. Otherwise, the asset total amount could
 * mismatch with the sum of payments.
 */
@Override
public KualiDecimal totalPaymentByAsset(AssetGlobal assetGlobal, boolean lastEntry) {
    KualiDecimal assetTotalAmount = KualiDecimal.ZERO;
    List<AssetPaymentDetail> assetPaymentDetails = assetGlobal.getAssetPaymentDetails();
    int numberOfTotalAsset = assetGlobal.getAssetGlobalDetails().size();
    if (numberOfTotalAsset > 0) {
        for (AssetPaymentDetail assetPaymentDetail : assetPaymentDetails) {
            KualiDecimal assetPaymentUnitCost = assetPaymentDetail.getAmount().divide(new KualiDecimal(numberOfTotalAsset));
            if (lastEntry) {
                assetPaymentUnitCost = assetPaymentDetail.getAmount().subtract(assetPaymentUnitCost.multiply(new KualiDecimal(numberOfTotalAsset - 1)));
            }
            assetTotalAmount = assetTotalAmount.add(assetPaymentUnitCost);
        }
    }
    return assetTotalAmount;
}
Also used : AssetPaymentDetail(org.kuali.kfs.module.cam.businessobject.AssetPaymentDetail) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal)

Aggregations

KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)280 ArrayList (java.util.ArrayList)46 HashMap (java.util.HashMap)36 Test (org.junit.Test)28 AbstractKualiDecimal (org.kuali.kfs.core.api.util.type.AbstractKualiDecimal)21 BigDecimal (java.math.BigDecimal)18 List (java.util.List)18 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)15 Date (java.sql.Date)14 CapitalAssetInformation (org.kuali.kfs.fp.businessobject.CapitalAssetInformation)14 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)14 ConcurStandardAccountingExtractDetailLine (edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine)11 KualiInteger (org.kuali.kfs.core.api.util.type.KualiInteger)11 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)11 IOException (java.io.IOException)10 InvoiceDetailAccountObjectCode (org.kuali.kfs.module.ar.businessobject.InvoiceDetailAccountObjectCode)10 Map (java.util.Map)9 ParameterEvaluator (org.kuali.kfs.core.api.parameter.ParameterEvaluator)9 CapitalAccountingLines (org.kuali.kfs.fp.businessobject.CapitalAccountingLines)9 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)8