use of org.kuali.kfs.fp.businessobject.CapitalAssetInformation in project cu-kfs by CU-CommunityApps.
the class CapitalAssetInformationActionBase method copy.
/**
* Overridden to guarantee that form of copied document is set to whatever the entry mode of the document is
*
* @see org.kuali.rice.kns.web.struts.action.KualiTransactionalDocumentActionBase#copy(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
CapitalAccountingLinesFormBase capitalAccountingLinesFormBase = (CapitalAccountingLinesFormBase) form;
;
CapitalAccountingLinesDocumentBase caldb = (CapitalAccountingLinesDocumentBase) capitalAccountingLinesFormBase.getFinancialDocument();
List<CapitalAccountingLines> capitalAccountingLines = caldb.getCapitalAccountingLines();
List<CapitalAccountingLines> copiedCapitalAccountingLines = new ArrayList<>();
for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
copiedCapitalAccountingLines.add(capitalAccountingLine);
}
capitalAccountingLines.clear();
ActionForward forward = super.copy(mapping, form, request, response);
caldb.setCapitalAccountingLines(copiedCapitalAccountingLines);
// if the copied document has capital asset collection, remove the collection
KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase = (KualiAccountingDocumentFormBase) form;
AccountingDocument document = kualiAccountingDocumentFormBase.getFinancialDocument();
if (document instanceof CapitalAssetEditable) {
CapitalAssetEditable capitalAssetEditable = (CapitalAssetEditable) document;
List<CapitalAssetInformation> capitalAssets = capitalAssetEditable.getCapitalAssetInformation();
for (CapitalAssetInformation capitalAsset : capitalAssets) {
Long capitalAssetNumber = capitalAsset.getCapitalAssetNumber();
resetCapitalAssetInfo(capitalAsset);
// because resetCapitalAssetInfo cleared the value.
if (KFSConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR.equalsIgnoreCase(capitalAsset.getCapitalAssetActionIndicator())) {
capitalAsset.setCapitalAssetNumber(capitalAssetNumber);
}
capitalAsset.setCapitalAssetProcessedIndicator(false);
}
}
// setup the initial next sequence number column..
KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
setupIntialNextCapitalAssetLineNumber(kualiDocumentFormBase);
checkCapitalAccountingLinesSelected(capitalAccountingLinesFormBase);
return forward;
}
use of org.kuali.kfs.fp.businessobject.CapitalAssetInformation 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);
}
use of org.kuali.kfs.fp.businessobject.CapitalAssetInformation 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));
}
}
use of org.kuali.kfs.fp.businessobject.CapitalAssetInformation in project cu-kfs by CU-CommunityApps.
the class CapitalAssetInformationActionBase method checkCreateAssetsExist.
/**
* @param capitalAccountingLinesFormBase
* @return true if a capital asset with capital asset action indicator = 'C' else false;
*/
protected boolean checkCreateAssetsExist(CapitalAccountingLinesFormBase capitalAccountingLinesFormBase) {
boolean exists = false;
CapitalAssetInformationDocumentBase capitalAssetInformationDocumentBase = (CapitalAssetInformationDocumentBase) capitalAccountingLinesFormBase.getFinancialDocument();
List<CapitalAssetInformation> capitalAssets = capitalAssetInformationDocumentBase.getCapitalAssetInformation();
for (CapitalAssetInformation capitalAsset : capitalAssets) {
if (KFSConstants.CapitalAssets.CAPITAL_ASSET_CREATE_ACTION_INDICATOR.equals(capitalAsset.getCapitalAssetActionIndicator())) {
return true;
}
}
return exists;
}
use of org.kuali.kfs.fp.businessobject.CapitalAssetInformation in project cu-kfs by CU-CommunityApps.
the class CapitalAssetInformationActionBase method checkModifyAssetsExist.
/**
* @param capitalAccountingLinesFormBase
* @return true if a capital asset with capital asset action indicator = 'C' else false;
*/
protected boolean checkModifyAssetsExist(CapitalAccountingLinesFormBase capitalAccountingLinesFormBase) {
boolean exists = false;
CapitalAssetInformationDocumentBase capitalAssetInformationDocumentBase = (CapitalAssetInformationDocumentBase) capitalAccountingLinesFormBase.getFinancialDocument();
List<CapitalAssetInformation> capitalAssets = capitalAssetInformationDocumentBase.getCapitalAssetInformation();
for (CapitalAssetInformation capitalAsset : capitalAssets) {
if (KFSConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR.equals(capitalAsset.getCapitalAssetActionIndicator())) {
return true;
}
}
return exists;
}
Aggregations