use of org.kuali.kfs.module.cam.businessobject.AssetPaymentAssetDetail 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.module.cam.businessobject.AssetPaymentAssetDetail in project cu-kfs by CU-CommunityApps.
the class GlLineServiceImpl method updatePreTagInformation.
/**
* Updates pre tag information received from FP document
*
* @param entry GeneralLedgerEntry
* @param document AssetPaymentDocument
*/
protected void updatePreTagInformation(GeneralLedgerEntry entry, AssetPaymentDocument document, Integer capitalAssetLineNumber) {
CapitalAssetInformation capitalAssetInformation = findCapitalAssetInformation(entry.getDocumentNumber(), capitalAssetLineNumber);
if (ObjectUtils.isNotNull(capitalAssetInformation)) {
// if it is modify asset...
if (KFSConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR.equals(capitalAssetInformation.getCapitalAssetActionIndicator())) {
AssetPaymentAssetDetail assetPaymentAssetDetail = new AssetPaymentAssetDetail();
assetPaymentAssetDetail.setDocumentNumber(document.getDocumentNumber());
// get the allocated amount for the capital asset....
assetPaymentAssetDetail.setCapitalAssetNumber(capitalAssetInformation.getCapitalAssetNumber());
assetPaymentAssetDetail.setAllocatedAmount(KualiDecimal.ZERO);
assetPaymentAssetDetail.setAllocatedUserValue(assetPaymentAssetDetail.getAllocatedAmount());
assetPaymentAssetDetail.refreshReferenceObject(CamsPropertyConstants.AssetPaymentAssetDetail.ASSET);
Asset asset = assetPaymentAssetDetail.getAsset();
if (ObjectUtils.isNotNull(asset)) {
assetPaymentAssetDetail.setPreviousTotalCostAmount(asset.getTotalCostAmount() != null ? asset.getTotalCostAmount() : KualiDecimal.ZERO);
document.getAssetPaymentAssetDetail().add(assetPaymentAssetDetail);
}
}
}
}
Aggregations