use of org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase in project cu-kfs by CU-CommunityApps.
the class CapitalAssetInformationActionBase method DistributeCapitalAssetAmountToGroupAccountingLines.
/**
* This method redistributes the capital asset amount to its group accounting lines
* based on the accounting line's percent. Takes each capital assets amount and
* distributes to the capital asset group accounting lines.
*
* @param kualiAccountingDocumentFormBase
*/
protected void DistributeCapitalAssetAmountToGroupAccountingLines(KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase) {
CapitalAccountingLinesFormBase capitalAccountingLinesFormBase = (CapitalAccountingLinesFormBase) kualiAccountingDocumentFormBase;
checkSelectForCapitalAccountingLines(capitalAccountingLinesFormBase);
checkCapitalAccountingLinesSelected(capitalAccountingLinesFormBase);
calculatePercentsForSelectedCapitalAccountingLines(capitalAccountingLinesFormBase);
CapitalAccountingLinesDocumentBase caldb = (CapitalAccountingLinesDocumentBase) capitalAccountingLinesFormBase.getFinancialDocument();
String distributionAmountCode = capitalAccountingLinesFormBase.getCapitalAccountingLine().getDistributionCode();
List<CapitalAccountingLines> capitalAccountingLines = caldb.getCapitalAccountingLines();
List<CapitalAccountingLines> selectedCapitalAccountingLines = new ArrayList<CapitalAccountingLines>();
for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
if (capitalAccountingLine.isSelectLine() && !capitalAccountingLine.isAmountDistributed()) {
capitalAccountingLine.setDistributionAmountCode(distributionAmountCode);
selectedCapitalAccountingLines.add(capitalAccountingLine);
}
}
List<CapitalAssetInformation> capitalAssetInformation = this.getCurrentCapitalAssetInformationObject(kualiAccountingDocumentFormBase);
for (CapitalAssetInformation capitalAsset : capitalAssetInformation) {
// redistribute the capital asset modify amount to the group accounting lines based on amount.
if (!capitalAssetAmountAlreadyDistributedToGroupAccountingLines(capitalAsset)) {
redistributeToGroupAccountingLinesFromAssetsByAmounts(selectedCapitalAccountingLines, capitalAsset);
}
}
}
use of org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase 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.document.CapitalAccountingLinesDocumentBase 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);
}
}
}
use of org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase 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;
}
use of org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase in project cu-kfs by CU-CommunityApps.
the class CapitalAssetInformationActionBase method redistributeModifyCapitalAssetAmount.
/**
* redistributes the capital asset amount for the modify capital asset lines.
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws Exception
*/
public ActionForward redistributeModifyCapitalAssetAmount(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
LOG.debug("redistributeModifyCapitalAssetAmount() - 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.
redistributeAmountsForAccountingsLineForModifyAssets(selectedCapitalAccountingLines, capitalAssetInformation, remainingAmountToDistribute);
redistributeIndividualAmountsForAccountingLinesForModifyAssets(selectedCapitalAccountingLines, capitalAssetInformation);
// now process any capital assets that has distribution set to "by amount"
redistributeAmountsForAccountingsLineForModifyAssetsByAmounts(selectedCapitalAccountingLines, capitalAssetInformation, remainingAmountToDistribute);
// adjust any variance from capital accounting lines to the distributed accounting lines amounts....
adjustCapitalAssetsAccountingLinesAmounts(selectedCapitalAccountingLines, capitalAssetInformation);
processRemainingCapitalAssetInfo(form, capitalAssetInformation);
// redistribute capital asset amount to its group accounting lines on refresh
DistributeCapitalAssetAmountToGroupAccountingLines((KualiAccountingDocumentFormBase) form);
checkCapitalAccountingLinesSelected(calfb);
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Aggregations