Search in sources :

Example 1 with CapitalAssetInformation

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);
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 2 with CapitalAssetInformation

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;
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) AssetPaymentDetail(org.kuali.kfs.module.cam.businessobject.AssetPaymentDetail) GeneralLedgerEntry(org.kuali.kfs.module.cam.businessobject.GeneralLedgerEntry) ArrayList(java.util.ArrayList) CapitalAssetAccountsGroupDetails(org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails)

Example 3 with CapitalAssetInformation

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;
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) HashMap(java.util.HashMap) NonTransactional(org.kuali.kfs.sys.service.NonTransactional)

Example 4 with CapitalAssetInformation

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;
}
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 5 with CapitalAssetInformation

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;
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) NonTransactional(org.kuali.kfs.sys.service.NonTransactional)

Aggregations

CapitalAssetInformation (org.kuali.kfs.fp.businessobject.CapitalAssetInformation)46 KualiAccountingDocumentFormBase (org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)18 CapitalAccountingLines (org.kuali.kfs.fp.businessobject.CapitalAccountingLines)15 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)14 ArrayList (java.util.ArrayList)12 CapitalAccountingLinesDocumentBase (org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase)11 CapitalAssetInformationDocumentBase (org.kuali.kfs.fp.document.CapitalAssetInformationDocumentBase)6 HashMap (java.util.HashMap)4 CapitalAssetAccountsGroupDetails (org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails)4 GeneralLedgerEntry (org.kuali.kfs.module.cam.businessobject.GeneralLedgerEntry)4 CapitalAssetEditable (org.kuali.kfs.fp.document.CapitalAssetEditable)3 NonTransactional (org.kuali.kfs.sys.service.NonTransactional)3 CapitalAssetInformationDetailExtendedAttribute (edu.cornell.kfs.fp.businessobject.CapitalAssetInformationDetailExtendedAttribute)2 List (java.util.List)2 CapitalAssetInformationDetail (org.kuali.kfs.fp.businessobject.CapitalAssetInformationDetail)2 AssetPaymentAssetDetail (org.kuali.kfs.module.cam.businessobject.AssetPaymentAssetDetail)2 AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)2 ProcurementCardTransactionExtendedAttribute (edu.cornell.kfs.fp.businessobject.ProcurementCardTransactionExtendedAttribute)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1