use of org.kuali.kfs.fp.businessobject.CapitalAssetInformation in project cu-kfs by CU-CommunityApps.
the class GlLineServiceImpl method createNewCapitalAsset.
/**
* helper method to add accounting details for this new capital asset record
*
* @param capitalAccountingLines
* @param currentCapitalAssetInformation
* @param documentNumber
* @param actionType
* @param nextCapitalAssetLineNumnber
*/
protected void createNewCapitalAsset(List<CapitalAccountingLines> capitalAccountingLines, String documentNumber, String actionType, Integer nextCapitalAssetLineNumber) {
CapitalAssetInformation capitalAsset = new CapitalAssetInformation();
capitalAsset.setCapitalAssetLineAmount(KualiDecimal.ZERO);
capitalAsset.setDocumentNumber(documentNumber);
capitalAsset.setCapitalAssetLineNumber(nextCapitalAssetLineNumber);
capitalAsset.setCapitalAssetActionIndicator(actionType);
capitalAsset.setCapitalAssetProcessedIndicator(false);
KualiDecimal capitalAssetLineAmount = KualiDecimal.ZERO;
// now setup the account line information associated with this capital asset
for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
capitalAsset.setDistributionAmountCode(capitalAccountingLine.getDistributionAmountCode());
createCapitalAssetAccountingLinesDetails(capitalAccountingLine, capitalAsset);
capitalAssetLineAmount = capitalAssetLineAmount.add(capitalAccountingLine.getAmount());
}
capitalAsset.setCapitalAssetLineAmount(capitalAssetLineAmount);
businessObjectService.save(capitalAsset);
}
use of org.kuali.kfs.fp.businessobject.CapitalAssetInformation 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.CapitalAssetInformation in project cu-kfs by CU-CommunityApps.
the class GlLineServiceImpl method findCapitalAssetInformation.
/**
* @see GlLineService#findCapitalAssetInformation(GeneralLedgerEntry)
*/
@Override
@NonTransactional
public CapitalAssetInformation findCapitalAssetInformation(String documentNumber, Integer capitalAssetLineNumber) {
Map<String, String> primaryKeys = new HashMap<String, String>(2);
primaryKeys.put(CamsPropertyConstants.CapitalAssetInformation.DOCUMENT_NUMBER, documentNumber);
primaryKeys.put(CamsPropertyConstants.CapitalAssetInformation.ASSET_LINE_NUMBER, capitalAssetLineNumber.toString());
CapitalAssetInformation assetInformation = businessObjectService.findByPrimaryKey(CapitalAssetInformation.class, primaryKeys);
return assetInformation;
}
use of org.kuali.kfs.fp.businessobject.CapitalAssetInformation in project cu-kfs by CU-CommunityApps.
the class GlLineServiceImpl method createAssetPaymentDocument.
/**
* @see GlLineService#createAssetPaymentDocument(GeneralLedgerEntry, Integer)
*/
@Override
@NonTransactional
public Document createAssetPaymentDocument(GeneralLedgerEntry primaryGlEntry, Integer capitalAssetLineNumber) throws WorkflowException {
// Find out the GL Entry
// initiate a new document
AssetPaymentDocument document = (AssetPaymentDocument) documentService.getNewDocument(DocumentTypeName.ASSET_PAYMENT);
document.setCapitalAssetBuilderOriginIndicator(true);
// populate the capital asset line distribution amount code to the payment document.
CapitalAssetInformation capitalAssetInformation = findCapitalAssetInformation(primaryGlEntry.getDocumentNumber(), capitalAssetLineNumber);
if (ObjectUtils.isNotNull(capitalAssetInformation)) {
// setup asset allocation info accordingly so it can be changed on Asset Payment Document
if (ObjectUtils.isNull(capitalAssetInformation.getDistributionAmountCode())) {
document.setAssetPaymentAllocationTypeCode(KFSConstants.CapitalAssets.DISTRIBUTE_COST_EQUALLY_CODE);
document.setAllocationFromFPDocuments(false);
} else {
document.setAssetPaymentAllocationTypeCode(capitalAssetInformation.getDistributionAmountCode());
document.setAllocationFromFPDocuments(true);
}
}
document.getDocumentHeader().setDocumentDescription(CAB_DESC_PREFIX + primaryGlEntry.getDocumentNumber());
updatePreTagInformation(primaryGlEntry, document, capitalAssetLineNumber);
// Asset Payment Detail - sourceAccountingLines on the document....
document.getSourceAccountingLines().addAll(createAssetPaymentDetails(primaryGlEntry, document, 0, capitalAssetLineNumber));
KualiDecimal assetAmount = KualiDecimal.ZERO;
List<SourceAccountingLine> sourceAccountingLines = document.getSourceAccountingLines();
for (SourceAccountingLine sourceAccountingLine : sourceAccountingLines) {
assetAmount = assetAmount.add(sourceAccountingLine.getAmount());
}
List<AssetPaymentAssetDetail> assetPaymentDetails = document.getAssetPaymentAssetDetail();
for (AssetPaymentAssetDetail assetPaymentDetail : assetPaymentDetails) {
assetPaymentDetail.setAllocatedAmount(assetAmount);
}
// Asset payment asset detail
// save the document
documentService.saveDocument(document);
markCapitalAssetProcessed(primaryGlEntry, capitalAssetLineNumber);
deactivateGLEntries(primaryGlEntry, document, capitalAssetLineNumber);
return document;
}
use of org.kuali.kfs.fp.businessobject.CapitalAssetInformation in project cu-kfs by CU-CommunityApps.
the class GlLineServiceImpl method findCapitalAssetInformationForGLLine.
/**
* @see GlLineService#findCapitalAssetInformationForGLLine(GeneralLedgerEntry)
*/
@Override
@NonTransactional
public List<CapitalAssetInformation> findCapitalAssetInformationForGLLine(GeneralLedgerEntry entry) {
Map<String, String> fields = new HashMap<String, String>();
fields.put(CamsPropertyConstants.CapitalAssetInformation.DOCUMENT_NUMBER, entry.getDocumentNumber());
fields.put(CamsPropertyConstants.CapitalAssetInformation.ASSET_PROCESSED_IND, "N");
List<CapitalAssetInformation> assetInformation = (List<CapitalAssetInformation>) businessObjectService.findMatchingOrderBy(CapitalAssetInformation.class, fields, CamsPropertyConstants.CapitalAssetInformation.ACTION_INDICATOR, true);
List<CapitalAssetInformation> matchingAssets = new ArrayList<CapitalAssetInformation>();
for (CapitalAssetInformation capitalAsset : assetInformation) {
addToCapitalAssets(matchingAssets, capitalAsset, entry);
}
return matchingAssets;
}
Aggregations