Search in sources :

Example 26 with KualiDecimal

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

the class CuLaborPendingEntryGenerator method generateBenefitClearingPendingEntries.

public static List<LaborLedgerPendingEntry> generateBenefitClearingPendingEntries(LaborLedgerPostingDocument document, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, String accountNumber, String chartOfAccountsCode) {
    List<LaborLedgerPendingEntry> benefitClearingPendingEntries = new ArrayList<LaborLedgerPendingEntry>();
    Map<String, Map<String, KualiDecimal>> sourceLineBenefitAmountSumByObjectCode = new HashMap<String, Map<String, KualiDecimal>>();
    List<ExpenseTransferSourceAccountingLine> sourceAccountingLines = document.getSourceAccountingLines();
    for (ExpenseTransferSourceAccountingLine accountingLine : sourceAccountingLines) {
        updateBenefitAmountSumObject(sourceLineBenefitAmountSumByObjectCode, accountingLine);
    }
    Map<String, Map<String, KualiDecimal>> targetLineBenefitAmountSumByObjectCode = new HashMap<String, Map<String, KualiDecimal>>();
    List<ExpenseTransferTargetAccountingLine> targetAccountingLines = document.getTargetAccountingLines();
    for (ExpenseTransferTargetAccountingLine accountingLine : targetAccountingLines) {
        updateBenefitAmountSumObject(targetLineBenefitAmountSumByObjectCode, accountingLine);
    }
    Set<String> benefitTypeCodes = new HashSet<String>();
    for (String key : targetLineBenefitAmountSumByObjectCode.keySet()) {
        benefitTypeCodes.add(key);
    }
    for (String key : sourceLineBenefitAmountSumByObjectCode.keySet()) {
        benefitTypeCodes.add(key);
    }
    for (String benefitTypeCode : benefitTypeCodes) {
        KualiDecimal targetAmount = KualiDecimal.ZERO;
        Map<String, KualiDecimal> targetBenefitSumsByObjectCode = new HashMap<String, KualiDecimal>();
        if (targetLineBenefitAmountSumByObjectCode.containsKey(benefitTypeCode)) {
            targetBenefitSumsByObjectCode = targetLineBenefitAmountSumByObjectCode.get(benefitTypeCode);
            for (String objCode : targetBenefitSumsByObjectCode.keySet()) {
                if (targetBenefitSumsByObjectCode.containsKey(objCode)) {
                    targetAmount = targetAmount.add(targetBenefitSumsByObjectCode.get(objCode));
                }
            }
        }
        KualiDecimal sourceAmount = KualiDecimal.ZERO;
        Map<String, KualiDecimal> sourceBenefitSumsByObjectCode = new HashMap<String, KualiDecimal>();
        if (sourceLineBenefitAmountSumByObjectCode.containsKey(benefitTypeCode)) {
            sourceBenefitSumsByObjectCode = sourceLineBenefitAmountSumByObjectCode.get(benefitTypeCode);
            for (String objCode : sourceBenefitSumsByObjectCode.keySet()) {
                if (sourceBenefitSumsByObjectCode.containsKey(objCode)) {
                    sourceAmount = sourceAmount.add(sourceBenefitSumsByObjectCode.get(objCode));
                }
            }
        }
        KualiDecimal clearingAmount = sourceAmount.subtract(targetAmount);
        KualiDecimal amountForObjectCode = KualiDecimal.ZERO;
        if (clearingAmount.isNonZero() && ObjectUtils.isNotNull(benefitTypeCode)) {
            for (String objCode : sourceBenefitSumsByObjectCode.keySet()) {
                amountForObjectCode = sourceBenefitSumsByObjectCode.get(objCode);
                benefitClearingPendingEntries.add(((CuLaborPendingEntryConverterServiceImpl) SpringContext.getBean(LaborPendingEntryConverterService.class)).getBenefitClearingPendingEntry(document, sequenceHelper, accountNumber, chartOfAccountsCode, benefitTypeCode, amountForObjectCode, objCode));
            }
            for (String objCode : targetBenefitSumsByObjectCode.keySet()) {
                amountForObjectCode = targetBenefitSumsByObjectCode.get(objCode);
                benefitClearingPendingEntries.add(((CuLaborPendingEntryConverterServiceImpl) SpringContext.getBean(LaborPendingEntryConverterService.class)).getBenefitClearingPendingEntry(document, sequenceHelper, accountNumber, chartOfAccountsCode, benefitTypeCode, amountForObjectCode.negated(), objCode));
            }
        }
    }
    // refresh nonupdateable references for financial object...
    refreshObjectCodeNonUpdateableReferences(benefitClearingPendingEntries);
    return benefitClearingPendingEntries;
}
Also used : ExpenseTransferSourceAccountingLine(org.kuali.kfs.module.ld.businessobject.ExpenseTransferSourceAccountingLine) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExpenseTransferTargetAccountingLine(org.kuali.kfs.module.ld.businessobject.ExpenseTransferTargetAccountingLine) LaborLedgerPendingEntry(org.kuali.kfs.module.ld.businessobject.LaborLedgerPendingEntry) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 27 with KualiDecimal

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

the class UserFavoriteAccountServiceImpl method populateIWantAccountingLine.

protected void populateIWantAccountingLine(FavoriteAccount account, IWantAccount acctLine) {
    final int ONE_HUNDRED = 100;
    acctLine.setAccountNumber(account.getAccountNumber());
    acctLine.setChartOfAccountsCode(account.getChartOfAccountsCode());
    acctLine.setSubAccountNumber(account.getSubAccountNumber());
    acctLine.setFinancialObjectCode(account.getFinancialObjectCode());
    acctLine.setFinancialSubObjectCode(account.getFinancialSubObjectCode());
    acctLine.setProjectCode(account.getProjectCode());
    acctLine.setOrganizationReferenceId(account.getOrganizationReferenceId());
    acctLine.setUseAmountOrPercent(CUPurapConstants.PERCENT);
    acctLine.setAmountOrPercent(new KualiDecimal(ONE_HUNDRED));
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 28 with KualiDecimal

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

the class PaymentGroup method getNetPaymentAmount.

/**
 * Get the total of all the detail items
 *
 * @return
 */
public KualiDecimal getNetPaymentAmount() {
    KualiDecimal amt = KualiDecimal.ZERO;
    for (Iterator iter = this.getPaymentDetails().iterator(); iter.hasNext(); ) {
        PaymentDetail element = (PaymentDetail) iter.next();
        amt = amt.add(element.getNetPaymentAmount());
    }
    return amt;
}
Also used : Iterator(java.util.Iterator) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 29 with KualiDecimal

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

the class PaymentSourceExtractionServiceImpl method extractImmediatePaymentsForCampus.

/**
 * Builds payment batch for Disbursement Vouchers marked as immediate
 *
 * @param campusCode the campus code the disbursement vouchers should be associated with
 * @param user the user responsible building the payment batch (typically the System User, kfs)
 * @param processRunDate the time that the job to build immediate payments is run
 */
protected void extractImmediatePaymentsForCampus(String campusCode, String principalId, Date processRunDate, List<? extends PaymentSource> documents) {
    LOG.debug("extractImmediatesPaymentsForCampus() started for campus: " + campusCode);
    if (!documents.isEmpty()) {
        final PaymentSource firstPaymentSource = documents.get(0);
        Batch batch = createBatch(campusCode, principalId, processRunDate);
        Integer count = 0;
        KualiDecimal totalAmount = KualiDecimal.ZERO;
        for (PaymentSource document : documents) {
            if (getPaymentSourceToExtractService().shouldExtractPayment(document)) {
                addPayment(document, batch, processRunDate, false);
                count++;
                totalAmount = totalAmount.add(getPaymentSourceToExtractService().getPaymentAmount(document));
            }
        }
        batch.setPaymentCount(new KualiInteger(count));
        batch.setPaymentTotalAmount(totalAmount);
        businessObjectService.save(batch);
        paymentFileEmailService.sendLoadEmail(batch);
    }
}
Also used : KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) Batch(org.kuali.kfs.pdp.businessobject.Batch) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) PaymentSource(org.kuali.kfs.sys.document.PaymentSource) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 30 with KualiDecimal

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

the class PaymentSourceExtractionServiceImpl method extractPaymentsForCampus.

/**
 * This method extracts all outstanding payments from all the disbursement vouchers in approved status for a given campus and
 * adds these payments to a batch file that is uploaded for processing.
 *
 * @param campusCode The id code of the campus the payments will be retrieved for.
 * @param user The user object used when creating the batch file to upload with outstanding payments.
 * @param processRunDate This is the date that the batch file is created, often this value will be today's date.
 */
protected void extractPaymentsForCampus(String campusCode, String principalId, Date processRunDate, List<? extends PaymentSource> documents) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("extractPaymentsForCampus() started for campus: " + campusCode);
    }
    Batch batch = createBatch(campusCode, principalId, processRunDate);
    Integer count = 0;
    KualiDecimal totalAmount = KualiDecimal.ZERO;
    for (PaymentSource document : documents) {
        if (getPaymentSourceToExtractService().shouldExtractPayment(document)) {
            addPayment(document, batch, processRunDate, false);
            count++;
            totalAmount = totalAmount.add(getPaymentSourceToExtractService().getPaymentAmount(document));
        }
    }
    batch.setPaymentCount(new KualiInteger(count));
    batch.setPaymentTotalAmount(totalAmount);
    businessObjectService.save(batch);
    paymentFileEmailService.sendLoadEmail(batch);
}
Also used : KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) Batch(org.kuali.kfs.pdp.businessobject.Batch) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) PaymentSource(org.kuali.kfs.sys.document.PaymentSource)

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