Search in sources :

Example 66 with KualiDecimal

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

the class CapitalAssetInformationActionBase method accountingLinesAmountDistributed.

/**
 * @param capitalAccountingLines
 * @param existingCapitalAsset
 * @return true if accounting line amount equals to capital asset amount, else false.
 */
protected boolean accountingLinesAmountDistributed(List<CapitalAccountingLines> capitalAccountingLines, CapitalAssetInformation existingCapitalAsset) {
    KualiDecimal accountingLineAmount = KualiDecimal.ZERO;
    for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
        accountingLineAmount = accountingLineAmount.add(capitalAccountingLine.getAmount().abs());
    }
    KualiDecimal capitalAssetsAmount = existingCapitalAsset.getCapitalAssetLineAmount();
    return accountingLineAmount.equals(capitalAssetsAmount);
}
Also used : CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 67 with KualiDecimal

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

the class CapitalAssetInformationActionBase method getAccountingLineAmount.

/**
 * Returns the amount of the group accounting line from the capital asset information that
 * matches the capital accounting lines (only one lines, of course). If none exists, zero is returned.
 *
 * @param capitalAsset
 * @param capitalAccountingLine
 * @return accountLineAmount
 */
protected KualiDecimal getAccountingLineAmount(CapitalAssetInformation capitalAsset, CapitalAccountingLines capitalAccountingLine) {
    KualiDecimal accountLineAmount = KualiDecimal.ZERO;
    List<CapitalAssetAccountsGroupDetails> groupAccountLines = capitalAsset.getCapitalAssetAccountsGroupDetails();
    for (CapitalAssetAccountsGroupDetails groupAccountLine : groupAccountLines) {
        if (groupAccountLine.getCapitalAssetLineNumber().compareTo(capitalAsset.getCapitalAssetLineNumber()) == 0 && groupAccountLine.getSequenceNumber().compareTo(capitalAccountingLine.getSequenceNumber()) == 0 && groupAccountLine.getFinancialDocumentLineTypeCode().equals(KFSConstants.SOURCE.equals(capitalAccountingLine.getLineType()) ? KFSConstants.SOURCE_ACCT_LINE_TYPE_CODE : KFSConstants.TARGET_ACCT_LINE_TYPE_CODE) && groupAccountLine.getChartOfAccountsCode().equals(capitalAccountingLine.getChartOfAccountsCode()) && groupAccountLine.getAccountNumber().equals(capitalAccountingLine.getAccountNumber()) && groupAccountLine.getFinancialObjectCode().equals(capitalAccountingLine.getFinancialObjectCode())) {
            return groupAccountLine.getAmount();
        }
    }
    return accountLineAmount;
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) CapitalAssetAccountsGroupDetails(org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails)

Example 68 with KualiDecimal

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

the class CapitalAssetInformationActionBase method capitalAccountingLineAmountDistributed.

/**
 * Checks to see if all the capital assets' distributed amount is the same as
 * the capital accounting lines (there is only one lines, of course).
 *
 * @param capitalAccountingLine
 * @param capitalAssetsInformation
 * @return true if accounting line amount equals to capital asset amount, else false.
 */
protected boolean capitalAccountingLineAmountDistributed(CapitalAccountingLines capitalAccountingLine, List<CapitalAssetInformation> capitalAssetsInformation) {
    KualiDecimal amountDistributed = KualiDecimal.ZERO;
    for (CapitalAssetInformation capitalAsset : capitalAssetsInformation) {
        amountDistributed = amountDistributed.add(getAccountingLineAmount(capitalAsset, capitalAccountingLine));
    }
    KualiDecimal capitalAccountingLineAmount = capitalAccountingLine.getAmount();
    return amountDistributed.equals(capitalAccountingLineAmount);
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 69 with KualiDecimal

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

the class CapitalAssetInformationActionBase method adjustVarianceOnCapitalAssets.

/**
 * adjusts variances on capital assets where distribution method is set
 * as "distribute evenly" and capital asset amount is odd value.  Reduce the
 * capital asset amount line by 0.01 and then adjust the account amounts. Finally
 * any variance between capital accounting lines and capital assets is added
 * to the last capital asset and its accounting lines.
 *
 * @param capitalAssetInformation
 */
protected void adjustVarianceOnCapitalAssets(List<CapitalAssetInformation> capitalAssetInformation) {
    KualiDecimal adjustedCapitalAssetBalance = KualiDecimal.ZERO;
    CapitalAssetInformation lastCapitalAsset = null;
    for (CapitalAssetInformation capitalAsset : capitalAssetInformation) {
        // look at only cost equal assets...
        if (KFSConstants.CapitalAssets.DISTRIBUTE_COST_EQUALLY_CODE.equalsIgnoreCase(capitalAsset.getDistributionAmountCode())) {
            if (capitalAsset.getCapitalAssetLineAmount().mod(new KualiDecimal(2)) != KualiDecimal.ZERO) {
                capitalAsset.setCapitalAssetLineAmount(capitalAsset.getCapitalAssetLineAmount().subtract(new KualiDecimal(0.01)));
                adjustedCapitalAssetBalance = adjustedCapitalAssetBalance.add(new KualiDecimal(0.01));
                lastCapitalAsset = capitalAsset;
            }
        }
    }
    if (ObjectUtils.isNotNull(lastCapitalAsset) && adjustedCapitalAssetBalance.isNonZero()) {
        lastCapitalAsset.setCapitalAssetLineAmount(lastCapitalAsset.getCapitalAssetLineAmount().add(adjustedCapitalAssetBalance));
    }
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 70 with KualiDecimal

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

the class CapitalAssetInformationActionBase method getRemainingAmounToDistribute.

/**
 * Calculates the remaining amount to distribute by taking selecte capital accounting lines
 * and subtracting the allocated capital asset accounting lines amounts totals.
 *
 * @param selectedCapitalAccountingLines
 * @param form
 * @return remainingAmountToDistribute
 */
protected KualiDecimal getRemainingAmounToDistribute(List<CapitalAccountingLines> selectedCapitalAccountingLines, ActionForm form) {
    KualiDecimal remainingAmountToDistribute = KualiDecimal.ZERO;
    KualiDecimal capitalAccountsAmountToDistribute = KualiDecimal.ZERO;
    KualiDecimal capitalAssetsAllocatedAmount = KualiDecimal.ZERO;
    CapitalAccountingLinesFormBase calfb = (CapitalAccountingLinesFormBase) form;
    CapitalAssetInformationDocumentBase capitalAssetInformationDocumentBase = (CapitalAssetInformationDocumentBase) calfb.getFinancialDocument();
    List<CapitalAssetInformation> capitalAssets = capitalAssetInformationDocumentBase.getCapitalAssetInformation();
    CapitalAccountingLinesDocumentBase caldb = (CapitalAccountingLinesDocumentBase) calfb.getFinancialDocument();
    List<CapitalAccountingLines> capitalAccountingLines = caldb.getCapitalAccountingLines();
    for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
        if (capitalAccountingLine.isSelectLine() && !capitalAccountingLine.isAmountDistributed()) {
            selectedCapitalAccountingLines.add(capitalAccountingLine);
            capitalAccountsAmountToDistribute = capitalAccountsAmountToDistribute.add(capitalAccountingLine.getAmount());
            capitalAssetsAllocatedAmount = capitalAssetsAllocatedAmount.add(getCapitalAssetsAmountAllocated(capitalAssets, capitalAccountingLine));
        }
    }
    remainingAmountToDistribute = capitalAccountsAmountToDistribute.subtract(capitalAssetsAllocatedAmount);
    return remainingAmountToDistribute;
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) CapitalAssetInformationDocumentBase(org.kuali.kfs.fp.document.CapitalAssetInformationDocumentBase) CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) CapitalAccountingLinesDocumentBase(org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase)

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