Search in sources :

Example 16 with CapitalAssetInformation

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

the class CapitalAssetInformationActionBase method addCapitalAssetTagLocationInfo.

/**
 * inserts capital asset information into capital assets list.
 * Also recalculates the system control and system control remaining amounts.
 * Puts a global error message if the user does not enter capital asset quantity.
 * If the quantity is > 1, it will insert that many tag/location detail records for this
 * capital asset item.
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return action forward string
 * @throws Exception
 */
public ActionForward addCapitalAssetTagLocationInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    LOG.debug("addCapitalAssetTagLocationInfo() - start");
    KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase = (KualiAccountingDocumentFormBase) form;
    List<CapitalAssetInformation> capitalAssetInformation = this.getCurrentCapitalAssetInformationObject(kualiAccountingDocumentFormBase);
    if (capitalAssetInformation == null) {
        return mapping.findForward(KFSConstants.MAPPING_BASIC);
    }
    int addIndex = getSelectedLine(request);
    if (capitalAssetInformation.get(addIndex).getCapitalAssetQuantity() == null || capitalAssetInformation.get(addIndex).getCapitalAssetQuantity() <= 0) {
        GlobalVariables.getMessageMap().putError(KFSConstants.EDIT_CAPITAL_ASSET_INFORMATION_ERRORS, KFSKeyConstants.ERROR_DOCUMENT_CAPITAL_ASSET_QUANTITY_REQUIRED);
    } else {
        this.addCapitalAssetInfoDetailLines(capitalAssetInformation.get(addIndex));
    }
    // now process the remaining capital asset records
    processRemainingCapitalAssetInfo(form, capitalAssetInformation);
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) KualiAccountingDocumentFormBase(org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)

Example 17 with CapitalAssetInformation

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

the class CapitalAssetInformationActionBase method uncheckCapitalAccountingLinesSelected.

/**
 * unchecks the capital accounting lines select when there are no capital assets created yet.
 *
 * @param calfb
 */
protected void uncheckCapitalAccountingLinesSelected(CapitalAccountingLinesFormBase calfb) {
    CapitalAccountingLinesDocumentBase caldb = (CapitalAccountingLinesDocumentBase) calfb.getDocument();
    List<CapitalAccountingLines> capitalAccountingLines = caldb.getCapitalAccountingLines();
    KualiAccountingDocumentFormBase kadfb = calfb;
    List<CapitalAssetInformation> currentCapitalAssetInformation = this.getCurrentCapitalAssetInformationObject(kadfb);
    List<CapitalAccountingLines> selectedCapitalAccountingLines = new ArrayList<CapitalAccountingLines>();
    for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
        if (capitalAccountingLine.isSelectLine() && !capitalAccountingLine.isAmountDistributed()) {
            calfb.setSystemControlAmount(calfb.getSystemControlAmount().add(capitalAccountingLine.getAmount()));
            selectedCapitalAccountingLines.add(capitalAccountingLine);
        }
    }
    CapitalAssetInformation existingCapitalAsset = capitalAssetCreated(selectedCapitalAccountingLines, currentCapitalAssetInformation);
    for (CapitalAccountingLines capitalAccountingLine : selectedCapitalAccountingLines) {
        if (ObjectUtils.isNull(existingCapitalAsset)) {
            capitalAccountingLine.setSelectLine(false);
        }
    }
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines) ArrayList(java.util.ArrayList) CapitalAccountingLinesDocumentBase(org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase) KualiAccountingDocumentFormBase(org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)

Example 18 with CapitalAssetInformation

use of org.kuali.kfs.fp.businessobject.CapitalAssetInformation 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)

Example 19 with CapitalAssetInformation

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

the class CapitalAssetInformationActionBase method insertCapitalAssetInfo.

/**
 * inserts capital asset information into capital assets list.
 * Also recalculates the system control and system control remaining amounts.
 * Puts a global error message if the user does not enter capital asset quantity.
 * If the quantity is > 1, it will insert that many tag/location detail records for this
 * capital asset item.
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return action forward string
 * @throws Exception
 */
public ActionForward insertCapitalAssetInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    LOG.debug("insertCapitalAssetInfo() - start");
    KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase = (KualiAccountingDocumentFormBase) form;
    List<CapitalAssetInformation> capitalAssetInformation = this.getCurrentCapitalAssetInformationObject(kualiAccountingDocumentFormBase);
    if (capitalAssetInformation == null) {
        return mapping.findForward(KFSConstants.MAPPING_BASIC);
    }
    int addIndex = getSelectedLine(request);
    if (capitalAssetInformation.get(addIndex).getCapitalAssetQuantity() == null || capitalAssetInformation.get(addIndex).getCapitalAssetQuantity() <= 0) {
        GlobalVariables.getMessageMap().putError(KFSConstants.EDIT_CAPITAL_ASSET_INFORMATION_ERRORS, KFSKeyConstants.ERROR_DOCUMENT_CAPITAL_ASSET_QUANTITY_REQUIRED);
    } else {
        this.addCapitalAssetInfoDetailLines(capitalAssetInformation.get(addIndex));
    }
    // now process the remaining capital asset records
    processRemainingCapitalAssetInfo(form, capitalAssetInformation);
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) KualiAccountingDocumentFormBase(org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)

Example 20 with CapitalAssetInformation

use of org.kuali.kfs.fp.businessobject.CapitalAssetInformation 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)

Aggregations

CapitalAssetInformation (org.kuali.kfs.fp.businessobject.CapitalAssetInformation)46 KualiAccountingDocumentFormBase (org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)18 CapitalAccountingLines (org.kuali.kfs.fp.businessobject.CapitalAccountingLines)15 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)14 ArrayList (java.util.ArrayList)12 CapitalAccountingLinesDocumentBase (org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase)11 CapitalAssetInformationDocumentBase (org.kuali.kfs.fp.document.CapitalAssetInformationDocumentBase)6 HashMap (java.util.HashMap)4 CapitalAssetAccountsGroupDetails (org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails)4 GeneralLedgerEntry (org.kuali.kfs.module.cam.businessobject.GeneralLedgerEntry)4 CapitalAssetEditable (org.kuali.kfs.fp.document.CapitalAssetEditable)3 NonTransactional (org.kuali.kfs.sys.service.NonTransactional)3 CapitalAssetInformationDetailExtendedAttribute (edu.cornell.kfs.fp.businessobject.CapitalAssetInformationDetailExtendedAttribute)2 List (java.util.List)2 CapitalAssetInformationDetail (org.kuali.kfs.fp.businessobject.CapitalAssetInformationDetail)2 AssetPaymentAssetDetail (org.kuali.kfs.module.cam.businessobject.AssetPaymentAssetDetail)2 AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)2 ProcurementCardTransactionExtendedAttribute (edu.cornell.kfs.fp.businessobject.ProcurementCardTransactionExtendedAttribute)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1