Search in sources :

Example 11 with CapitalAssetAccountsGroupDetails

use of org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails in project cu-kfs by CU-CommunityApps.

the class CapitalAssetInformationActionBase method redistributeIndividualAmounts.

/**
 * @param selectedCapitalAccountingLines
 * @param capitalAsset
 */
protected void redistributeIndividualAmounts(List<CapitalAccountingLines> selectedCapitalAccountingLines, CapitalAssetInformation capitalAsset) {
    KualiDecimal capitalAssetAmount = capitalAsset.getCapitalAssetLineAmount();
    KualiDecimal totalCapitalAccountsAmount = getTotalCapitalAccountsAmounts(selectedCapitalAccountingLines);
    CapitalAssetAccountsGroupDetails lastAccountLine = new CapitalAssetAccountsGroupDetails();
    int lastAccountLineIndex = 0;
    KualiDecimal distributedAmount = KualiDecimal.ZERO;
    List<CapitalAssetAccountsGroupDetails> groupAccountLines = capitalAsset.getCapitalAssetAccountsGroupDetails();
    for (CapitalAssetAccountsGroupDetails groupAccountLine : groupAccountLines) {
        BigDecimal linePercent = getCapitalAccountingLinePercent(selectedCapitalAccountingLines, groupAccountLine, totalCapitalAccountsAmount);
        groupAccountLine.setAmount(new KualiDecimal(capitalAssetAmount.bigDecimalValue().multiply(linePercent)));
        lastAccountLine = groupAccountLine;
        distributedAmount = distributedAmount.add(groupAccountLine.getAmount());
        lastAccountLineIndex++;
    }
    lastAccountLine.setAmount(lastAccountLine.getAmount().add(capitalAssetAmount.subtract(distributedAmount)));
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) CapitalAssetAccountsGroupDetails(org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails) BigDecimal(java.math.BigDecimal)

Example 12 with CapitalAssetAccountsGroupDetails

use of org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails in project cu-kfs by CU-CommunityApps.

the class CapitalAssetInformationActionBase method redistributeEqualAmounts.

/**
 * redistributes the amounts to the capital asset and its related group accounting lines.
 * Adjusts any variance to the last capital asset accounting line.
 *
 * @param selectedCapitalAccountingLines
 * @param capitalAsset
 * @param amount
 * @param totalQuantity
 */
protected void redistributeEqualAmounts(List<CapitalAccountingLines> selectedCapitalAccountingLines, CapitalAssetInformation capitalAsset, KualiDecimal amount, int totalQuantity) {
    int assetQuantity = 0;
    KualiDecimal totalCapitalAssetQuantity = new KualiDecimal(totalQuantity);
    if (ObjectUtils.isNotNull(capitalAsset.getCapitalAssetQuantity())) {
        assetQuantity = capitalAsset.getCapitalAssetQuantity();
    }
    capitalAsset.setCapitalAssetLineAmount(capitalAsset.getCapitalAssetLineAmount().add(amount.multiply(new KualiDecimal(assetQuantity))));
    int lastAccountIndex = 0;
    KualiDecimal appliedAccountingLinesTotal = KualiDecimal.ZERO;
    CapitalAssetAccountsGroupDetails lastLine = new CapitalAssetAccountsGroupDetails();
    List<CapitalAssetAccountsGroupDetails> groupAccountLines = capitalAsset.getCapitalAssetAccountsGroupDetails();
    for (CapitalAssetAccountsGroupDetails groupAccountLine : groupAccountLines) {
        KualiDecimal capitalAccountingLineAmount = getCapitalAssetAccountLineAmount(selectedCapitalAccountingLines, groupAccountLine, capitalAsset);
        KualiDecimal calculatedLineAmount = capitalAccountingLineAmount.divide(totalCapitalAssetQuantity, true);
        groupAccountLine.setAmount(calculatedLineAmount.multiply(new KualiDecimal(assetQuantity)));
        appliedAccountingLinesTotal = appliedAccountingLinesTotal.add(groupAccountLine.getAmount());
        lastAccountIndex++;
        lastLine = groupAccountLine;
    }
    // apply any variance left to the last
    KualiDecimal varianceForLines = capitalAsset.getCapitalAssetLineAmount().subtract(appliedAccountingLinesTotal);
    if (varianceForLines.isNonZero()) {
        lastLine.setAmount(lastLine.getAmount().add(varianceForLines));
    }
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) CapitalAssetAccountsGroupDetails(org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails)

Example 13 with CapitalAssetAccountsGroupDetails

use of org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails in project cu-kfs by CU-CommunityApps.

the class CapitalAssetInformationActionBase method capitalAssetAmountAlreadyDistributedToGroupAccountingLines.

/**
 * checks if the capital asset amount already distributed to its group accounting lines
 *
 * @param capitalAsset
 * @return true if amount already distributed else return false.
 */
protected boolean capitalAssetAmountAlreadyDistributedToGroupAccountingLines(CapitalAssetInformation capitalAsset) {
    boolean amountDistributed = true;
    KualiDecimal capitalAssetAmount = capitalAsset.getCapitalAssetLineAmount();
    KualiDecimal totalAmountDistributed = KualiDecimal.ZERO;
    List<CapitalAssetAccountsGroupDetails> groupAccountLines = capitalAsset.getCapitalAssetAccountsGroupDetails();
    for (CapitalAssetAccountsGroupDetails groupAccountLine : groupAccountLines) {
        // keep track of amount distributed so far.
        totalAmountDistributed = totalAmountDistributed.add(groupAccountLine.getAmount());
    }
    return (capitalAssetAmount.compareTo(totalAmountDistributed) == 0);
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) CapitalAssetAccountsGroupDetails(org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails)

Example 14 with CapitalAssetAccountsGroupDetails

use of org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails in project cu-kfs by CU-CommunityApps.

the class CapitalAssetInformationActionBase method adjustAccountingLinesAmounts.

/**
 * for each capital account line, compares its amounts to the accounting lines
 * on capital assets and adjusts its accounting lines amounts for any variances.
 *
 * @param capitalAcctLine
 * @param capitalAssetInformation
 */
protected void adjustAccountingLinesAmounts(CapitalAccountingLines capitalAcctLine, List<CapitalAssetInformation> capitalAssetInformation) {
    CapitalAssetAccountsGroupDetails lastAcctLine = null;
    KualiDecimal totalAccountsAmount = KualiDecimal.ZERO;
    for (CapitalAssetInformation capitalAsset : capitalAssetInformation) {
        if (capitalAsset.getCapitalAssetLineAmount().compareTo(getAccountingLinesTotalAmount(capitalAsset)) != 0) {
            List<CapitalAssetAccountsGroupDetails> groupAccountLines = capitalAsset.getCapitalAssetAccountsGroupDetails();
            for (CapitalAssetAccountsGroupDetails groupAccountLine : groupAccountLines) {
                if (groupAccountLine.getCapitalAssetLineNumber().compareTo(capitalAsset.getCapitalAssetLineNumber()) == 0 && groupAccountLine.getSequenceNumber().compareTo(capitalAcctLine.getSequenceNumber()) == 0 && groupAccountLine.getFinancialDocumentLineTypeCode().equals(KFSConstants.SOURCE.equals(capitalAcctLine.getLineType()) ? KFSConstants.SOURCE_ACCT_LINE_TYPE_CODE : KFSConstants.TARGET_ACCT_LINE_TYPE_CODE) && groupAccountLine.getChartOfAccountsCode().equals(capitalAcctLine.getChartOfAccountsCode()) && groupAccountLine.getAccountNumber().equals(capitalAcctLine.getAccountNumber()) && groupAccountLine.getFinancialObjectCode().equals(capitalAcctLine.getFinancialObjectCode())) {
                    totalAccountsAmount = totalAccountsAmount.add(groupAccountLine.getAmount());
                    lastAcctLine = groupAccountLine;
                }
            }
        }
    }
    KualiDecimal variance = capitalAcctLine.getAmount().subtract(totalAccountsAmount);
    if (variance.isNonZero() && ObjectUtils.isNotNull(lastAcctLine)) {
        lastAcctLine.setAmount(lastAcctLine.getAmount().add(variance));
    }
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) CapitalAssetAccountsGroupDetails(org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails)

Example 15 with CapitalAssetAccountsGroupDetails

use of org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails in project cu-kfs by CU-CommunityApps.

the class GlLineServiceImpl method createCapitalAssetAccountingLinesDetails.

/**
 * @param capitalAccountingLine
 * @param capitalAsset
 */
protected void createCapitalAssetAccountingLinesDetails(CapitalAccountingLines capitalAccountingLine, CapitalAssetInformation capitalAsset) {
    // now setup the account line information associated with this capital asset
    CapitalAssetAccountsGroupDetails capitalAssetAccountLine = new CapitalAssetAccountsGroupDetails();
    capitalAssetAccountLine.setDocumentNumber(capitalAsset.getDocumentNumber());
    capitalAssetAccountLine.setChartOfAccountsCode(capitalAccountingLine.getChartOfAccountsCode());
    capitalAssetAccountLine.setAccountNumber(capitalAccountingLine.getAccountNumber());
    capitalAssetAccountLine.setSubAccountNumber(capitalAccountingLine.getSubAccountNumber());
    capitalAssetAccountLine.setFinancialDocumentLineTypeCode(KFSConstants.SOURCE.equals(capitalAccountingLine.getLineType()) ? KFSConstants.SOURCE_ACCT_LINE_TYPE_CODE : KFSConstants.TARGET_ACCT_LINE_TYPE_CODE);
    capitalAssetAccountLine.setCapitalAssetAccountLineNumber(getNextAccountingLineNumber(capitalAccountingLine, capitalAsset));
    capitalAssetAccountLine.setCapitalAssetLineNumber(capitalAsset.getCapitalAssetLineNumber());
    capitalAssetAccountLine.setFinancialObjectCode(capitalAccountingLine.getFinancialObjectCode());
    capitalAssetAccountLine.setFinancialSubObjectCode(capitalAccountingLine.getFinancialSubObjectCode());
    capitalAssetAccountLine.setProjectCode(capitalAccountingLine.getProjectCode());
    capitalAssetAccountLine.setOrganizationReferenceId(capitalAccountingLine.getOrganizationReferenceId());
    capitalAssetAccountLine.setSequenceNumber(capitalAccountingLine.getSequenceNumber());
    capitalAssetAccountLine.setAmount(capitalAccountingLine.getAmount());
    capitalAsset.getCapitalAssetAccountsGroupDetails().add(capitalAssetAccountLine);
}
Also used : CapitalAssetAccountsGroupDetails(org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails)

Aggregations

CapitalAssetAccountsGroupDetails (org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails)18 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)8 CapitalAssetInformation (org.kuali.kfs.fp.businessobject.CapitalAssetInformation)4 BigDecimal (java.math.BigDecimal)2 GeneralLedgerEntry (org.kuali.kfs.module.cam.businessobject.GeneralLedgerEntry)2 ArrayList (java.util.ArrayList)1 CapitalAccountingLines (org.kuali.kfs.fp.businessobject.CapitalAccountingLines)1 AssetPaymentDetail (org.kuali.kfs.module.cam.businessobject.AssetPaymentDetail)1 KualiAccountingDocumentFormBase (org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)1