use of org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails in project cu-kfs by CU-CommunityApps.
the class GlLineServiceImpl method createAssetPaymentDetails.
/**
* Creates asset payment details based on accounting lines distributed
* for the given capital asset.
*
* @param entry
* @param document
* @param seqNo
* @param capitalAssetLineNumber
* @return List<AssetPaymentDetail>
*/
protected List<AssetPaymentDetail> createAssetPaymentDetails(GeneralLedgerEntry entry, Document document, int seqNo, Integer capitalAssetLineNumber) {
List<AssetPaymentDetail> appliedPayments = new ArrayList<AssetPaymentDetail>();
CapitalAssetInformation capitalAssetInformation = findCapitalAssetInformation(entry.getDocumentNumber(), capitalAssetLineNumber);
Collection<GeneralLedgerEntry> documentGlEntries = findAllGeneralLedgerEntry(entry.getDocumentNumber());
if (ObjectUtils.isNotNull(capitalAssetInformation)) {
List<CapitalAssetAccountsGroupDetails> groupAccountingLines = capitalAssetInformation.getCapitalAssetAccountsGroupDetails();
Integer paymentSequenceNumber = 1;
for (CapitalAssetAccountsGroupDetails accountingLine : groupAccountingLines) {
AssetPaymentDetail detail = new AssetPaymentDetail();
// find matching gl entry for asset accounting line
for (GeneralLedgerEntry glEntry : documentGlEntries) {
if (doesGeneralLedgerEntryMatchAssetAccountingDetails(glEntry, accountingLine)) {
entry = glEntry;
}
}
// TODO
// sub-object code, as well as sub-account, project code, and org ref id, shall not be populated from GL entry;
// instead, they need to be passed from the original FP document for each individual accounting line to be stored in CapitalAssetAccountsGroupDetails,
// and copied into each corresponding accounting line in Asset Payment here.
detail.setDocumentNumber(document.getDocumentNumber());
detail.setSequenceNumber(paymentSequenceNumber++);
detail.setPostingYear(entry.getUniversityFiscalYear());
detail.setPostingPeriodCode(entry.getUniversityFiscalPeriodCode());
detail.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
detail.setAccountNumber(replaceFiller(accountingLine.getAccountNumber()));
detail.setSubAccountNumber(replaceFiller(accountingLine.getSubAccountNumber()));
detail.setFinancialObjectCode(replaceFiller(accountingLine.getFinancialObjectCode()));
detail.setFinancialSubObjectCode(replaceFiller(accountingLine.getFinancialSubObjectCode()));
detail.setProjectCode(replaceFiller(accountingLine.getProjectCode()));
detail.setOrganizationReferenceId(replaceFiller(accountingLine.getOrganizationReferenceId()));
// detail.setAmount(KFSConstants.GL_CREDIT_CODE.equals(debitCreditCode) ? accountingLine.getAmount().negated() : accountingLine.getAmount());
detail.setAmount(getAccountingLineAmountForPaymentDetail(entry, accountingLine));
detail.setExpenditureFinancialSystemOriginationCode(replaceFiller(entry.getFinancialSystemOriginationCode()));
detail.setExpenditureFinancialDocumentNumber(entry.getDocumentNumber());
detail.setExpenditureFinancialDocumentTypeCode(replaceFiller(entry.getFinancialDocumentTypeCode()));
detail.setExpenditureFinancialDocumentPostedDate(entry.getTransactionDate());
detail.setPurchaseOrderNumber(replaceFiller(entry.getReferenceFinancialDocumentNumber()));
detail.setTransferPaymentIndicator(false);
detail.refreshNonUpdateableReferences();
appliedPayments.add(detail);
}
}
return appliedPayments;
}
use of org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails in project cu-kfs by CU-CommunityApps.
the class CapitalAssetInformationActionBase method clearCapitalAssetModify.
/**
* clear up the modify capital asset information. The amount field is reset to 0
* Processes any remaining capital assets so that it recalculates the system control
* and system control remaining amounts.
*
* @param mapping
* @param form
* @param request
* @param response
* @return action forward string
* @throws Exception
*/
public ActionForward clearCapitalAssetModify(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
LOG.debug("clearCapitalAssetModify() - start");
KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase = (KualiAccountingDocumentFormBase) form;
List<CapitalAssetInformation> capitalAssetInformation = this.getCurrentCapitalAssetInformationObject(kualiAccountingDocumentFormBase);
if (capitalAssetInformation == null) {
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
int clearIndex = getSelectedLine(request);
capitalAssetInformation.get(clearIndex).setCapitalAssetLineAmount(KualiDecimal.ZERO);
// zero out the amount distribute on the accounting lines...
for (CapitalAssetAccountsGroupDetails groupAccountLine : capitalAssetInformation.get(clearIndex).getCapitalAssetAccountsGroupDetails()) {
groupAccountLine.setAmount(KualiDecimal.ZERO);
}
// now process the remaining capital asset records
processRemainingCapitalAssetInfo(form, capitalAssetInformation);
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
use of org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails in project cu-kfs by CU-CommunityApps.
the class CapitalAssetInformationActionBase method getAccountingLineAmount.
/**
* Returns the amount of the group accounting line from the capital asset information that
* matches the capital accounting lines (only one lines, of course). If none exists, zero is returned.
*
* @param capitalAsset
* @param capitalAccountingLine
* @return accountLineAmount
*/
protected KualiDecimal getAccountingLineAmount(CapitalAssetInformation capitalAsset, CapitalAccountingLines capitalAccountingLine) {
KualiDecimal accountLineAmount = KualiDecimal.ZERO;
List<CapitalAssetAccountsGroupDetails> groupAccountLines = capitalAsset.getCapitalAssetAccountsGroupDetails();
for (CapitalAssetAccountsGroupDetails groupAccountLine : groupAccountLines) {
if (groupAccountLine.getCapitalAssetLineNumber().compareTo(capitalAsset.getCapitalAssetLineNumber()) == 0 && groupAccountLine.getSequenceNumber().compareTo(capitalAccountingLine.getSequenceNumber()) == 0 && groupAccountLine.getFinancialDocumentLineTypeCode().equals(KFSConstants.SOURCE.equals(capitalAccountingLine.getLineType()) ? KFSConstants.SOURCE_ACCT_LINE_TYPE_CODE : KFSConstants.TARGET_ACCT_LINE_TYPE_CODE) && groupAccountLine.getChartOfAccountsCode().equals(capitalAccountingLine.getChartOfAccountsCode()) && groupAccountLine.getAccountNumber().equals(capitalAccountingLine.getAccountNumber()) && groupAccountLine.getFinancialObjectCode().equals(capitalAccountingLine.getFinancialObjectCode())) {
return groupAccountLine.getAmount();
}
}
return accountLineAmount;
}
use of org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails in project cu-kfs by CU-CommunityApps.
the class CapitalAssetInformationActionBase method removeDistributedAccountingLine.
/**
* Removes the matching accounting line that has been distributed to the capital asset
*
* @param capitalAsset
* @param accountingLine
*/
protected void removeDistributedAccountingLine(CapitalAssetInformation capitalAsset, AccountingLine accountingLine) {
List<CapitalAssetAccountsGroupDetails> groupAccountLines = capitalAsset.getCapitalAssetAccountsGroupDetails();
CapitalAssetAccountsGroupDetails accountLineToDelete = null;
for (CapitalAssetAccountsGroupDetails groupAccountLine : groupAccountLines) {
if (groupAccountLine.getSequenceNumber().compareTo(accountingLine.getSequenceNumber()) == 0 && groupAccountLine.getFinancialDocumentLineTypeCode().equals(groupAccountLine.getFinancialDocumentLineTypeCode()) && groupAccountLine.getChartOfAccountsCode().equals(accountingLine.getChartOfAccountsCode()) && groupAccountLine.getAccountNumber().equals(accountingLine.getAccountNumber()) && groupAccountLine.getFinancialObjectCode().equals(accountingLine.getFinancialObjectCode())) {
accountLineToDelete = groupAccountLine;
break;
}
}
if (ObjectUtils.isNotNull(accountLineToDelete)) {
capitalAsset.setCapitalAssetLineAmount(capitalAsset.getCapitalAssetLineAmount().subtract(accountLineToDelete.getAmount()));
groupAccountLines.remove(accountLineToDelete);
}
}
use of org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails in project cu-kfs by CU-CommunityApps.
the class CapitalAssetInformationActionBase method redistributeToGroupAccountingLinesFromAssetsByAmounts.
/**
* when the user user hits refresh button, takes the amount in the amount field and
* distributes to the group capital accounting lines for that asset only.
*
* @param selectedCapitalAccountingLines
* @param capitalAsset
*/
protected void redistributeToGroupAccountingLinesFromAssetsByAmounts(List<CapitalAccountingLines> selectedCapitalAccountingLines, CapitalAssetInformation capitalAsset) {
KualiDecimal amountToDistribute = capitalAsset.getCapitalAssetLineAmount();
KualiDecimal amountDistributed = KualiDecimal.ZERO;
KualiDecimal totalCapitalAccountsAmount = getTotalCapitalAccountsAmounts(selectedCapitalAccountingLines);
// to capture the last group accounting line to update its amount with any variance.
CapitalAssetAccountsGroupDetails lastGroupAccountLine = new CapitalAssetAccountsGroupDetails();
List<CapitalAssetAccountsGroupDetails> groupAccountLines = capitalAsset.getCapitalAssetAccountsGroupDetails();
for (CapitalAssetAccountsGroupDetails groupAccountLine : groupAccountLines) {
BigDecimal linePercent = getCapitalAccountingLinePercent(selectedCapitalAccountingLines, groupAccountLine, totalCapitalAccountsAmount);
// found the accounting line
lastGroupAccountLine = groupAccountLine;
KualiDecimal groupAccountLineAmount = capitalAsset.getCapitalAssetLineAmount().multiply(new KualiDecimal(linePercent));
groupAccountLine.setAmount(groupAccountLineAmount);
// keep track of amount distributed so far.
amountDistributed = amountDistributed.add(groupAccountLineAmount);
}
// add any variance in the amounts to the last group accounting line.
lastGroupAccountLine.setAmount(lastGroupAccountLine.getAmount().add(amountToDistribute.subtract(amountDistributed)));
}
Aggregations