Search in sources :

Example 71 with KualiDecimal

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

the class CapitalAssetInformationActionBase method redistributeEqualAmountsForAccountingLineForCreateAssets.

/**
 * @param selectedCapitalAccountingLines
 * @param capitalAssetInformation
 * @param remainingAmountToDistribute
 */
protected void redistributeEqualAmountsForAccountingLineForCreateAssets(List<CapitalAccountingLines> selectedCapitalAccountingLines, List<CapitalAssetInformation> capitalAssetInformation, KualiDecimal remainingAmountToDistribute) {
    // get the total capital assets quantity
    int totalQuantity = getTotalQuantityOfCreateAssets(selectedCapitalAccountingLines, capitalAssetInformation);
    if (totalQuantity > 0) {
        KualiDecimal equalCreateAssetAmount = remainingAmountToDistribute.divide(new KualiDecimal(totalQuantity), true);
        int lastAssetIndex = 0;
        CapitalAssetInformation lastCapitalAsset = new CapitalAssetInformation();
        if (equalCreateAssetAmount.compareTo(KualiDecimal.ZERO) != 0) {
            for (CapitalAssetInformation capitalAsset : capitalAssetInformation) {
                if (KFSConstants.CapitalAssets.CAPITAL_ASSET_CREATE_ACTION_INDICATOR.equals(capitalAsset.getCapitalAssetActionIndicator()) && (KFSConstants.CapitalAssets.DISTRIBUTE_COST_EQUALLY_CODE.equalsIgnoreCase(capitalAsset.getDistributionAmountCode()))) {
                    if (capitalAssetExists(selectedCapitalAccountingLines, capitalAsset, KFSConstants.CapitalAssets.CAPITAL_ASSET_CREATE_ACTION_INDICATOR)) {
                        redistributeEqualAmounts(selectedCapitalAccountingLines, capitalAsset, equalCreateAssetAmount, totalQuantity);
                        if (ObjectUtils.isNotNull(capitalAsset.getCapitalAssetQuantity())) {
                            lastAssetIndex = lastAssetIndex + capitalAsset.getCapitalAssetQuantity();
                        }
                        // get a reference to the last capital create asset to fix any variances...
                        lastCapitalAsset = capitalAsset;
                    }
                }
            }
        }
        // apply any variance left to the last
        KualiDecimal varianceForAssets = remainingAmountToDistribute.subtract(equalCreateAssetAmount.multiply(new KualiDecimal(lastAssetIndex)));
        if (varianceForAssets.isNonZero()) {
            lastCapitalAsset.setCapitalAssetLineAmount(lastCapitalAsset.getCapitalAssetLineAmount().add(varianceForAssets));
            redistributeEqualAmountsOnLastCapitalAsset(selectedCapitalAccountingLines, lastCapitalAsset, capitalAssetInformation, KFSConstants.CapitalAssets.CAPITAL_ASSET_CREATE_ACTION_INDICATOR);
        }
    }
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 72 with KualiDecimal

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

the class CapitalAssetInformationActionBase method redistributeToGroupAccountingLinesFromAssetsByAmounts.

/**
 * when the user user hits refresh button, takes the amount in the amount field and
 * distributes to the group capital accounting lines for that asset only.
 *
 * @param selectedCapitalAccountingLines
 * @param capitalAsset
 */
protected void redistributeToGroupAccountingLinesFromAssetsByAmounts(List<CapitalAccountingLines> selectedCapitalAccountingLines, CapitalAssetInformation capitalAsset) {
    KualiDecimal amountToDistribute = capitalAsset.getCapitalAssetLineAmount();
    KualiDecimal amountDistributed = KualiDecimal.ZERO;
    KualiDecimal totalCapitalAccountsAmount = getTotalCapitalAccountsAmounts(selectedCapitalAccountingLines);
    // to capture the last group accounting line to update its amount with any variance.
    CapitalAssetAccountsGroupDetails lastGroupAccountLine = new CapitalAssetAccountsGroupDetails();
    List<CapitalAssetAccountsGroupDetails> groupAccountLines = capitalAsset.getCapitalAssetAccountsGroupDetails();
    for (CapitalAssetAccountsGroupDetails groupAccountLine : groupAccountLines) {
        BigDecimal linePercent = getCapitalAccountingLinePercent(selectedCapitalAccountingLines, groupAccountLine, totalCapitalAccountsAmount);
        // found the accounting line
        lastGroupAccountLine = groupAccountLine;
        KualiDecimal groupAccountLineAmount = capitalAsset.getCapitalAssetLineAmount().multiply(new KualiDecimal(linePercent));
        groupAccountLine.setAmount(groupAccountLineAmount);
        // keep track of amount distributed so far.
        amountDistributed = amountDistributed.add(groupAccountLineAmount);
    }
    // add any variance in the amounts to the last group accounting line.
    lastGroupAccountLine.setAmount(lastGroupAccountLine.getAmount().add(amountToDistribute.subtract(amountDistributed)));
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) CapitalAssetAccountsGroupDetails(org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails) BigDecimal(java.math.BigDecimal)

Example 73 with KualiDecimal

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

the class PaymentRequestItem method addToExtendedPrice.

public void addToExtendedPrice(KualiDecimal addThisValue) {
    if (getExtendedPrice() == null) {
        setExtendedPrice(KualiDecimal.ZERO);
    }
    KualiDecimal addedPrice = getExtendedPrice().add(addThisValue);
    setExtendedPrice(addedPrice);
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 74 with KualiDecimal

use of org.kuali.rice.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.rice.core.api.util.type.KualiInteger) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) CheckReconciliation(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation) Date(java.util.Date)

Example 75 with KualiDecimal

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

the class CheckReconciliationImportStep method getTotalNetAmount.

private KualiDecimal getTotalNetAmount(Collection<PaymentGroup> paymentGroups) {
    KualiDecimal total = new KualiDecimal(0.0);
    for (PaymentGroup paymentGroup : paymentGroups) {
        KualiDecimal kd = paymentGroup.getNetPaymentAmount();
        total = total.add(kd);
    }
    return total;
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

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