Search in sources :

Example 1 with CapitalAccountingLines

use of org.kuali.kfs.fp.businessobject.CapitalAccountingLines 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 CapitalAccountingLines

use of org.kuali.kfs.fp.businessobject.CapitalAccountingLines in project cu-kfs by CU-CommunityApps.

the class GlLineServiceImpl method addCapitalAccountingLine.

/**
 * convenience method to add a new capital accounting line to the collection of capital
 * accounting lines.
 *
 * @param capitalAccountingLines
 * @param entry
 * @return
 */
protected CapitalAccountingLines addCapitalAccountingLine(List<CapitalAccountingLines> capitalAccountingLines, GeneralLedgerEntry entry) {
    CapitalAccountingLines cal = new CapitalAccountingLines();
    String capitalAssetLineType = KFSConstants.GL_CREDIT_CODE.equals(entry.getTransactionDebitCreditCode()) ? KFSConstants.SOURCE : KFSConstants.TARGET;
    cal.setLineType(capitalAssetLineType);
    cal.setSequenceNumber(entry.getTransactionLedgerEntrySequenceNumber());
    cal.setChartOfAccountsCode(entry.getChartOfAccountsCode());
    cal.setAccountNumber(entry.getAccountNumber());
    cal.setSubAccountNumber(entry.getSubAccountNumber());
    cal.setFinancialObjectCode(entry.getFinancialObjectCode());
    cal.setFinancialSubObjectCode(entry.getFinancialSubObjectCode());
    cal.setProjectCode(entry.getProjectCode());
    cal.setOrganizationReferenceId(entry.getOrganizationReferenceId());
    cal.setFinancialDocumentLineDescription(entry.getTransactionLedgerEntryDescription());
    cal.setAmount(entry.getAmount());
    cal.setAccountLinePercent(null);
    cal.setSelectLine(false);
    return cal;
}
Also used : CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines)

Example 3 with CapitalAccountingLines

use of org.kuali.kfs.fp.businessobject.CapitalAccountingLines in project cu-kfs by CU-CommunityApps.

the class CapitalAssetInformationActionBase method accountingLinesAmountDistributed.

/**
 * @param capitalAccountingLines
 * @param existingCapitalAsset
 * @return true if accounting line amount equals to capital asset amount, else false.
 */
protected boolean accountingLinesAmountDistributed(List<CapitalAccountingLines> capitalAccountingLines, CapitalAssetInformation existingCapitalAsset) {
    KualiDecimal accountingLineAmount = KualiDecimal.ZERO;
    for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
        accountingLineAmount = accountingLineAmount.add(capitalAccountingLine.getAmount().abs());
    }
    KualiDecimal capitalAssetsAmount = existingCapitalAsset.getCapitalAssetLineAmount();
    return accountingLineAmount.equals(capitalAssetsAmount);
}
Also used : CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 4 with CapitalAccountingLines

use of org.kuali.kfs.fp.businessobject.CapitalAccountingLines in project cu-kfs by CU-CommunityApps.

the class CapitalAssetInformationActionBase method DistributeCapitalAssetAmountToGroupAccountingLines.

/**
 * This method redistributes the capital asset amount to its group accounting lines
 * based on the accounting line's percent.  Takes each capital assets amount and
 * distributes to the capital asset group accounting lines.
 *
 * @param kualiAccountingDocumentFormBase
 */
protected void DistributeCapitalAssetAmountToGroupAccountingLines(KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase) {
    CapitalAccountingLinesFormBase capitalAccountingLinesFormBase = (CapitalAccountingLinesFormBase) kualiAccountingDocumentFormBase;
    checkSelectForCapitalAccountingLines(capitalAccountingLinesFormBase);
    checkCapitalAccountingLinesSelected(capitalAccountingLinesFormBase);
    calculatePercentsForSelectedCapitalAccountingLines(capitalAccountingLinesFormBase);
    CapitalAccountingLinesDocumentBase caldb = (CapitalAccountingLinesDocumentBase) capitalAccountingLinesFormBase.getFinancialDocument();
    String distributionAmountCode = capitalAccountingLinesFormBase.getCapitalAccountingLine().getDistributionCode();
    List<CapitalAccountingLines> capitalAccountingLines = caldb.getCapitalAccountingLines();
    List<CapitalAccountingLines> selectedCapitalAccountingLines = new ArrayList<CapitalAccountingLines>();
    for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
        if (capitalAccountingLine.isSelectLine() && !capitalAccountingLine.isAmountDistributed()) {
            capitalAccountingLine.setDistributionAmountCode(distributionAmountCode);
            selectedCapitalAccountingLines.add(capitalAccountingLine);
        }
    }
    List<CapitalAssetInformation> capitalAssetInformation = this.getCurrentCapitalAssetInformationObject(kualiAccountingDocumentFormBase);
    for (CapitalAssetInformation capitalAsset : capitalAssetInformation) {
        // redistribute the capital asset modify amount to the group accounting lines based on amount.
        if (!capitalAssetAmountAlreadyDistributedToGroupAccountingLines(capitalAsset)) {
            redistributeToGroupAccountingLinesFromAssetsByAmounts(selectedCapitalAccountingLines, capitalAsset);
        }
    }
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines) ArrayList(java.util.ArrayList) CapitalAccountingLinesDocumentBase(org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase)

Example 5 with CapitalAccountingLines

use of org.kuali.kfs.fp.businessobject.CapitalAccountingLines in project cu-kfs by CU-CommunityApps.

the class CapitalAssetInformationActionBase method copy.

/**
 * Overridden to guarantee that form of copied document is set to whatever the entry mode of the document is
 *
 * @see org.kuali.rice.kns.web.struts.action.KualiTransactionalDocumentActionBase#copy(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    CapitalAccountingLinesFormBase capitalAccountingLinesFormBase = (CapitalAccountingLinesFormBase) form;
    ;
    CapitalAccountingLinesDocumentBase caldb = (CapitalAccountingLinesDocumentBase) capitalAccountingLinesFormBase.getFinancialDocument();
    List<CapitalAccountingLines> capitalAccountingLines = caldb.getCapitalAccountingLines();
    List<CapitalAccountingLines> copiedCapitalAccountingLines = new ArrayList<>();
    for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
        copiedCapitalAccountingLines.add(capitalAccountingLine);
    }
    capitalAccountingLines.clear();
    ActionForward forward = super.copy(mapping, form, request, response);
    caldb.setCapitalAccountingLines(copiedCapitalAccountingLines);
    // if the copied document has capital asset collection, remove the collection
    KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase = (KualiAccountingDocumentFormBase) form;
    AccountingDocument document = kualiAccountingDocumentFormBase.getFinancialDocument();
    if (document instanceof CapitalAssetEditable) {
        CapitalAssetEditable capitalAssetEditable = (CapitalAssetEditable) document;
        List<CapitalAssetInformation> capitalAssets = capitalAssetEditable.getCapitalAssetInformation();
        for (CapitalAssetInformation capitalAsset : capitalAssets) {
            Long capitalAssetNumber = capitalAsset.getCapitalAssetNumber();
            resetCapitalAssetInfo(capitalAsset);
            // because resetCapitalAssetInfo cleared the value.
            if (KFSConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR.equalsIgnoreCase(capitalAsset.getCapitalAssetActionIndicator())) {
                capitalAsset.setCapitalAssetNumber(capitalAssetNumber);
            }
            capitalAsset.setCapitalAssetProcessedIndicator(false);
        }
    }
    // setup the initial next sequence number column..
    KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
    setupIntialNextCapitalAssetLineNumber(kualiDocumentFormBase);
    checkCapitalAccountingLinesSelected(capitalAccountingLinesFormBase);
    return forward;
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) ArrayList(java.util.ArrayList) CapitalAccountingLinesDocumentBase(org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase) ActionForward(org.apache.struts.action.ActionForward) CapitalAssetEditable(org.kuali.kfs.fp.document.CapitalAssetEditable) CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) KualiAccountingDocumentFormBase(org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)

Aggregations

CapitalAccountingLines (org.kuali.kfs.fp.businessobject.CapitalAccountingLines)21 CapitalAssetInformation (org.kuali.kfs.fp.businessobject.CapitalAssetInformation)15 CapitalAccountingLinesDocumentBase (org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase)12 KualiAccountingDocumentFormBase (org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)9 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 ActionForward (org.apache.struts.action.ActionForward)1 CapitalAssetAccountsGroupDetails (org.kuali.kfs.fp.businessobject.CapitalAssetAccountsGroupDetails)1 CapitalAssetEditable (org.kuali.kfs.fp.document.CapitalAssetEditable)1 CapitalAssetInformationDocumentBase (org.kuali.kfs.fp.document.CapitalAssetInformationDocumentBase)1 CapitalAssetManagementModuleService (org.kuali.kfs.integration.cam.CapitalAssetManagementModuleService)1 Asset (org.kuali.kfs.integration.cam.businessobject.Asset)1 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)1 PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)1 GeneralLedgerEntry (org.kuali.kfs.module.cam.businessobject.GeneralLedgerEntry)1 AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)1 SegmentedLookupResultsService (org.kuali.kfs.sys.service.SegmentedLookupResultsService)1