Search in sources :

Example 31 with CapitalAssetInformation

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

the class CapitalAssetInformationActionBase method refreshCapitalAssetModify.

/**
 * refreshes capital asset modify information to the modify 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 number.
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return action forward string
 * @throws Exception
 */
public ActionForward refreshCapitalAssetModify(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    LOG.debug("refreshCapitalAssetModify() - start");
    KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase = (KualiAccountingDocumentFormBase) form;
    List<CapitalAssetInformation> capitalAssetInformation = this.getCurrentCapitalAssetInformationObject(kualiAccountingDocumentFormBase);
    if (capitalAssetInformation == null) {
        return mapping.findForward(KFSConstants.MAPPING_BASIC);
    }
    int refreshIndex = getSelectedLine(request);
    if (capitalAssetInformation.get(refreshIndex).getCapitalAssetNumber() == null) {
        GlobalVariables.getMessageMap().putError(KFSConstants.EDIT_CAPITAL_ASSET_MODIFY_ERRORS, KFSKeyConstants.ERROR_DOCUMENT_CAPITAL_ASSET_NUMBER_REQUIRED);
    }
    // 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 32 with CapitalAssetInformation

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

the class CapitalAssetInformationActionBase method createNewModifyCapitalAsset.

/**
 * helper method to add accounting details for this new modify capital asset record
 *
 * @param capitalAccountingLines
 * @param currentCapitalAssetInformation
 * @param documentNumber
 * @param actionType
 * @param nextCapitalAssetLineNumber
 * @param capitalAssetNumber
 */
protected void createNewModifyCapitalAsset(List<CapitalAccountingLines> capitalAccountingLines, List<CapitalAssetInformation> currentCapitalAssetInformation, String documentNumber, String actionType, Integer nextCapitalAssetLineNumber, long capitalAssetNumber) {
    CapitalAssetInformation capitalAsset = new CapitalAssetInformation();
    capitalAsset.setCapitalAssetNumber(capitalAssetNumber);
    capitalAsset.setCapitalAssetLineAmount(KualiDecimal.ZERO);
    capitalAsset.setDocumentNumber(documentNumber);
    capitalAsset.setCapitalAssetLineNumber(nextCapitalAssetLineNumber);
    capitalAsset.setCapitalAssetActionIndicator(actionType);
    capitalAsset.setCapitalAssetProcessedIndicator(false);
    // now setup the account line information associated with this capital asset
    for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
        capitalAsset.setDistributionAmountCode(capitalAccountingLine.getDistributionAmountCode());
        createCapitalAssetAccountingLinesDetails(capitalAccountingLine, capitalAsset);
    }
    currentCapitalAssetInformation.add(capitalAsset);
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines)

Example 33 with CapitalAssetInformation

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

the class CapitalAssetInformationActionBase method createCapitalAssetForGroupAccountingLines.

/**
 * Populates capital asset information collection with capital accounting lines.
 * Based on actionType, capitalassetactionindicator attribute is filled with 'C' for create
 * and 'M' for modify assets, which will be used to differentiate to pull the records in
 * create asset screen or modify asset screen.
 *
 * @param calfb
 * @param actionType
 * @param distributionAmountCode
 */
protected void createCapitalAssetForGroupAccountingLines(CapitalAccountingLinesFormBase calfb, String actionType, String distributionAmountCode) {
    CapitalAccountingLinesDocumentBase caldb = (CapitalAccountingLinesDocumentBase) calfb.getFinancialDocument();
    List<CapitalAccountingLines> capitalAccountingLines = caldb.getCapitalAccountingLines();
    KualiAccountingDocumentFormBase kadfb = calfb;
    List<CapitalAssetInformation> currentCapitalAssetInformation = this.getCurrentCapitalAssetInformationObject(kadfb);
    String documentNumber = calfb.getDocument().getDocumentNumber();
    calfb.setSystemControlAmount(KualiDecimal.ZERO);
    List<CapitalAccountingLines> selectedCapitalAccountingLines = new ArrayList<>();
    for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
        if (capitalAccountingLine.isSelectLine() && !capitalAccountingLine.isAmountDistributed()) {
            capitalAccountingLine.setDistributionAmountCode(distributionAmountCode);
            selectedCapitalAccountingLines.add(capitalAccountingLine);
        }
    }
    CapitalAssetInformation existingCapitalAsset = capitalAssetCreated(selectedCapitalAccountingLines, currentCapitalAssetInformation);
    if (ObjectUtils.isNotNull(existingCapitalAsset)) {
        if (!accountingLinesAmountDistributed(selectedCapitalAccountingLines, existingCapitalAsset)) {
            // accounting line amount not completely distributed yet so we need to create more assets
            // add the capital information record to the list of asset information
            createNewCapitalAsset(selectedCapitalAccountingLines, currentCapitalAssetInformation, documentNumber, actionType, getNextCapitalAssetLineNumber(kadfb));
        }
    } else {
        // add the capital information record to the list of asset information
        createNewCapitalAsset(selectedCapitalAccountingLines, currentCapitalAssetInformation, documentNumber, actionType, getNextCapitalAssetLineNumber(kadfb));
    }
}
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 34 with CapitalAssetInformation

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

the class CapitalAssetInformationActionBase method refresh.

/**
 * Multi-value asset lookup is implemented through the integration package by module's service
 * to gather the results. The results are processed for any capital accounting lines where
 * the line is marked for selection.  After the capital assets are populated with the
 * selected asset numbers, the system control amount is redistributed equally among the assets
 * when the distribution method is "distribute cost equally".
 *
 * @see org.kuali.rice.kns.web.struts.action.KualiAction#refresh(org.apache.struts.action.ActionMapping,
 * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    super.refresh(mapping, form, request, response);
    // process the multiple value lookup data
    CapitalAssetInformationFormBase capitalAssetInformationFormBase = (CapitalAssetInformationFormBase) form;
    Collection<PersistableBusinessObject> rawValues = null;
    Map<String, Set<String>> segmentedSelection = new HashMap<>();
    // If multiple asset lookup was used to select the assets, then....
    if (StringUtils.equals(KFSConstants.MULTIPLE_VALUE, capitalAssetInformationFormBase.getRefreshCaller())) {
        String lookupResultsSequenceNumber = capitalAssetInformationFormBase.getLookupResultsSequenceNumber();
        if (StringUtils.isNotBlank(lookupResultsSequenceNumber)) {
            // actually returning from a multiple value lookup
            Set<String> selectedIds = SpringContext.getBean(SegmentedLookupResultsService.class).retrieveSetOfSelectedObjectIds(lookupResultsSequenceNumber, GlobalVariables.getUserSession().getPerson().getPrincipalId());
            for (String selectedId : selectedIds) {
                String selectedObjId = StringUtils.substringBefore(selectedId, ".");
                if (!segmentedSelection.containsKey(selectedObjId)) {
                    segmentedSelection.put(selectedObjId, new HashSet<>());
                }
            }
            // Retrieving selected data from table.
            if (LOG.isDebugEnabled()) {
                LOG.debug("Asking segmentation service for object ids " + segmentedSelection.keySet());
            }
            rawValues = SpringContext.getBean(SegmentedLookupResultsService.class).retrieveSelectedResultBOs(lookupResultsSequenceNumber, segmentedSelection.keySet(), Asset.class, GlobalVariables.getUserSession().getPerson().getPrincipalId());
        }
        if (rawValues == null || rawValues.size() == 0) {
            // redistribute capital asset amount to its group accounting lines on refresh
            DistributeCapitalAssetAmountToGroupAccountingLines((KualiAccountingDocumentFormBase) form);
            return mapping.findForward(KFSConstants.MAPPING_BASIC);
        }
        KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase = (KualiAccountingDocumentFormBase) form;
        CapitalAccountingLinesFormBase calfb = (CapitalAccountingLinesFormBase) form;
        CapitalAccountingLinesDocumentBase caldb = (CapitalAccountingLinesDocumentBase) calfb.getFinancialDocument();
        List<CapitalAccountingLines> capitalAccountingLines = caldb.getCapitalAccountingLines();
        List<CapitalAssetInformation> capitalAssetInformation = this.getCurrentCapitalAssetInformationObject(kualiAccountingDocumentFormBase);
        List<CapitalAccountingLines> selectedCapitalAccountingLines = new ArrayList<>();
        for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
            if (capitalAccountingLine.isSelectLine() && !capitalAccountingLine.isAmountDistributed()) {
                selectedCapitalAccountingLines.add(capitalAccountingLine);
            }
        }
        // where capital accounting line is "selected" and its amount is greater than already allocated.
        if (rawValues != null) {
            for (PersistableBusinessObject bo : rawValues) {
                Asset asset = (Asset) bo;
                boolean addIt = modifyAssetAlreadyExists(capitalAssetInformation, asset.getCapitalAssetNumber());
                // If it doesn't already exist in the list add it.
                if (addIt) {
                    createNewModifyCapitalAsset(selectedCapitalAccountingLines, capitalAssetInformation, calfb.getDocument().getDocumentNumber(), KFSConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR, getNextCapitalAssetLineNumber(kualiAccountingDocumentFormBase), asset.getCapitalAssetNumber());
                }
            }
            checkCapitalAccountingLinesSelected(calfb);
            // remove the blank capital asset modify records now...
            removeEmptyCapitalAssetModify(capitalAssetInformation);
            // now redistribute the amount for all assets if needed....
            redistributeModifyCapitalAssetAmount(mapping, form, request, response);
        }
    }
    // redistribute capital asset amount to its group accounting lines on refresh
    DistributeCapitalAssetAmountToGroupAccountingLines((KualiAccountingDocumentFormBase) form);
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SegmentedLookupResultsService(org.kuali.kfs.sys.service.SegmentedLookupResultsService) CapitalAccountingLinesDocumentBase(org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase) PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines) Asset(org.kuali.kfs.integration.cam.businessobject.Asset) KualiAccountingDocumentFormBase(org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)

Example 35 with CapitalAssetInformation

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

the class CapitalAssetInformationActionBase method redistributeCreateCapitalAssetAmount.

/**
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return actionForward
 * @throws Exception
 */
public ActionForward redistributeCreateCapitalAssetAmount(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    LOG.debug("redistributeCreateCapitalAssetAmount() - start");
    KualiDecimal remainingAmountToDistribute = KualiDecimal.ZERO;
    CapitalAccountingLinesFormBase calfb = (CapitalAccountingLinesFormBase) form;
    CapitalAccountingLinesDocumentBase caldb = (CapitalAccountingLinesDocumentBase) calfb.getFinancialDocument();
    List<CapitalAccountingLines> selectedCapitalAccountingLines = new ArrayList<CapitalAccountingLines>();
    String distributionCode = calfb.getCapitalAccountingLine().getDistributionCode();
    remainingAmountToDistribute = getRemainingAmounToDistribute(selectedCapitalAccountingLines, form);
    KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase = (KualiAccountingDocumentFormBase) form;
    List<CapitalAssetInformation> capitalAssetInformation = this.getCurrentCapitalAssetInformationObject(kualiAccountingDocumentFormBase);
    // run the process to redistribute the accounting line amount to the capital assets.
    redistributeEqualAmountsForAccountingLineForCreateAssets(selectedCapitalAccountingLines, capitalAssetInformation, remainingAmountToDistribute);
    redistributeIndividualAmountsForAccountingLinesForCreateAssets(selectedCapitalAccountingLines, capitalAssetInformation);
    // adjust any variance from capital accounting lines to the distributed accounting lines amounts....
    adjustCapitalAssetsAccountingLinesAmounts(selectedCapitalAccountingLines, capitalAssetInformation);
    // now perform calculations of adjusting variance when asset amounts are odd
    // ///    adjustVarianceOnCapitalAssets(capitalAssetInformation);
    checkCapitalAccountingLinesSelected(calfb);
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines) ArrayList(java.util.ArrayList) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) CapitalAccountingLinesDocumentBase(org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase) KualiAccountingDocumentFormBase(org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)

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