Search in sources :

Example 1 with AssetPaymentAssetDetail

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;
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) AssetPaymentDocument(org.kuali.kfs.module.cam.document.AssetPaymentDocument) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) AssetPaymentAssetDetail(org.kuali.kfs.module.cam.businessobject.AssetPaymentAssetDetail) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) NonTransactional(org.kuali.kfs.sys.service.NonTransactional)

Example 2 with AssetPaymentAssetDetail

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);
            }
        }
    }
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) AssetPaymentAssetDetail(org.kuali.kfs.module.cam.businessobject.AssetPaymentAssetDetail) GeneralLedgerEntryAsset(org.kuali.kfs.module.cam.businessobject.GeneralLedgerEntryAsset) Asset(org.kuali.kfs.module.cam.businessobject.Asset)

Aggregations

CapitalAssetInformation (org.kuali.kfs.fp.businessobject.CapitalAssetInformation)2 AssetPaymentAssetDetail (org.kuali.kfs.module.cam.businessobject.AssetPaymentAssetDetail)2 Asset (org.kuali.kfs.module.cam.businessobject.Asset)1 GeneralLedgerEntryAsset (org.kuali.kfs.module.cam.businessobject.GeneralLedgerEntryAsset)1 AssetPaymentDocument (org.kuali.kfs.module.cam.document.AssetPaymentDocument)1 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)1 NonTransactional (org.kuali.kfs.sys.service.NonTransactional)1 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)1