Search in sources :

Example 21 with PurApAccountingLine

use of org.kuali.kfs.module.purap.businessobject.PurApAccountingLine in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestServiceImpl method addTaxItem.

@Override
protected PurApItem addTaxItem(PaymentRequestDocument preq, String itemTypeCode, BigDecimal taxableAmount) {
    PurApItem item = super.addTaxItem(preq, itemTypeCode, taxableAmount);
    PurApAccountingLine taxLine = item.getSourceAccountingLines().get(0);
    // KFSPTS-1891.  added to fix validation required field error. especially after calculate tax
    if (taxLine.getAccountLinePercent() == null) {
        taxLine.setAccountLinePercent(BigDecimal.ZERO);
    }
    return item;
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)

Example 22 with PurApAccountingLine

use of org.kuali.kfs.module.purap.businessobject.PurApAccountingLine in project cu-kfs by CU-CommunityApps.

the class CuRequisitionDocument method getAccountsForAwardRouting.

public List<Account> getAccountsForAwardRouting() {
    List<Account> accounts = new ArrayList<Account>();
    ParameterService parameterService = SpringContext.getBean(ParameterService.class);
    for (PurApItem item : (List<PurApItem>) this.getItems()) {
        for (PurApAccountingLine accountingLine : item.getSourceAccountingLines()) {
            if (isObjectCodeAllowedForAwardRouting(accountingLine, parameterService)) {
                if (ObjectUtils.isNull(accountingLine.getAccount())) {
                    accountingLine.refreshReferenceObject("account");
                }
                if (accountingLine.getAccount() != null && !accounts.contains(accountingLine.getAccount())) {
                    accounts.add(accountingLine.getAccount());
                }
            }
        }
    }
    return accounts;
}
Also used : RequisitionAccount(org.kuali.kfs.module.purap.businessobject.RequisitionAccount) Account(org.kuali.kfs.coa.businessobject.Account) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 23 with PurApAccountingLine

use of org.kuali.kfs.module.purap.businessobject.PurApAccountingLine in project cu-kfs by CU-CommunityApps.

the class CuPurchaseOrderAmendmentDocumentPresentationController method getEditModes.

@Override
public Set<String> getEditModes(Document document) {
    Set<String> editModes = super.getEditModes(document);
    PurchaseOrderDocument poDocument = (PurchaseOrderDocument) document;
    if (PurapConstants.PurchaseOrderStatuses.APPDOC_CHANGE_IN_PROCESS.equals(poDocument.getApplicationDocumentStatus())) {
        WorkflowDocument workflowDocument = poDocument.getFinancialSystemDocumentHeader().getWorkflowDocument();
        // amendment doc needs to lock its field for initiator while enroute
        if (workflowDocument.isInitiated() || workflowDocument.isSaved() || workflowDocument.isCompletionRequested()) {
            editModes.add(PurchaseOrderEditMode.AMENDMENT_ENTRY);
        }
    }
    // KFSUPGRADE-339
    if (PurchaseOrderStatuses.APPDOC_AWAITING_FISCAL_REVIEW.equals(((PurchaseOrderDocument) document).getApplicationDocumentStatus())) {
        editModes.add(PurchaseOrderEditMode.AMENDMENT_ENTRY);
    }
    if (SpringContext.getBean(PurapService.class).isDocumentStoppedInRouteNode((PurchasingAccountsPayableDocument) document, "New Unordered Items")) {
        editModes.add(PurchaseOrderEditMode.UNORDERED_ITEM_ACCOUNT_ENTRY);
    }
    boolean showDisableRemoveAccounts = true;
    PurchaseOrderAmendmentDocument purchaseOrderAmendmentDocument = (PurchaseOrderAmendmentDocument) document;
    List<PurApItem> aboveTheLinePOItems = PurApItemUtils.getAboveTheLineOnly(purchaseOrderAmendmentDocument.getItems());
    PurchaseOrderDocument po = (PurchaseOrderDocument) document;
    boolean containsUnpaidPaymentRequestsOrCreditMemos = po.getContainsUnpaidPaymentRequestsOrCreditMemos();
    ItemLoop: for (PurApItem poItem : aboveTheLinePOItems) {
        boolean acctLinesEditable = allowAccountingLinesAreEditable((PurchaseOrderItem) poItem, containsUnpaidPaymentRequestsOrCreditMemos);
        for (PurApAccountingLine poAccoutingLine : poItem.getSourceAccountingLines()) {
            if (!acctLinesEditable) {
                showDisableRemoveAccounts = false;
                break ItemLoop;
            }
        }
    }
    if (!showDisableRemoveAccounts) {
        editModes.add(PurchaseOrderEditMode.DISABLE_REMOVE_ACCTS);
    }
    // KFSPTS-985
    if (document instanceof PurchaseOrderDocument && !editModes.contains(RequisitionEditMode.DISABLE_SETUP_ACCT_DISTRIBUTION) && !hasEmptyAcctline((PurchaseOrderDocument) document)) {
        editModes.add(RequisitionEditMode.DISABLE_SETUP_ACCT_DISTRIBUTION);
    }
    return editModes;
}
Also used : PurchaseOrderAmendmentDocument(org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument) PurchaseOrderItem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem) PurapService(org.kuali.kfs.module.purap.document.service.PurapService) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument)

Example 24 with PurApAccountingLine

use of org.kuali.kfs.module.purap.businessobject.PurApAccountingLine in project cu-kfs by CU-CommunityApps.

the class IWantDocumentServiceImpl method copyIWantDocAccountingLinesToReqDoc.

/**
 * Copies the accounting lines from the I Want document to the Requisition document
 *
 * @param requisitionDocument
 * @param iWantDocument
 * @param requisitionForm
 */
private void copyIWantDocAccountingLinesToReqDoc(RequisitionDocument requisitionDocument, IWantDocument iWantDocument, RequisitionForm requisitionForm) {
    int itemsSize = iWantDocument.getItems() != null ? iWantDocument.getItems().size() : 0;
    int accountsSize = iWantDocument.getAccounts() != null ? iWantDocument.getAccounts().size() : 0;
    // we only add accounts information if there or only one item or there is only one account, otherwise ignore
    if (itemsSize == 1 || accountsSize == 1) {
        for (IWantAccount iWantAccount : iWantDocument.getAccounts()) {
            PurApAccountingLine requisitionAccount = requisitionForm.getAccountDistributionnewSourceLine();
            requisitionAccount.setChartOfAccountsCode(iWantAccount.getChartOfAccountsCode());
            requisitionAccount.setAccountNumber(iWantAccount.getAccountNumber());
            requisitionAccount.setSubAccountNumber(iWantAccount.getSubAccountNumber());
            requisitionAccount.setFinancialObjectCode(iWantAccount.getFinancialObjectCode());
            requisitionAccount.setFinancialSubObjectCode(iWantAccount.getFinancialSubObjectCode());
            requisitionAccount.setProjectCode(iWantAccount.getProjectCode());
            requisitionAccount.setOrganizationReferenceId(iWantAccount.getOrganizationReferenceId());
            if (CUPurapConstants.PERCENT.equalsIgnoreCase(iWantAccount.getUseAmountOrPercent())) {
                requisitionAccount.setAccountLinePercent(iWantAccount.getAmountOrPercent().bigDecimalValue().setScale(0, RoundingMode.HALF_UP));
            } else {
                // compute amount based on percent
                BigDecimal requisitionAccountPercent = BigDecimal.ZERO;
                KualiDecimal iWantDocTotalDollarAmount = iWantDocument.getTotalDollarAmount();
                if (iWantDocTotalDollarAmount != null && iWantAccount.getAmountOrPercent() != null && iWantDocTotalDollarAmount.isNonZero() && iWantAccount.getAmountOrPercent().isNonZero()) {
                    requisitionAccountPercent = (iWantAccount.getAmountOrPercent().divide(iWantDocTotalDollarAmount).bigDecimalValue()).multiply(new BigDecimal("100"));
                    requisitionAccountPercent = requisitionAccountPercent.setScale(0, RoundingMode.HALF_UP);
                }
                requisitionAccount.setAccountLinePercent(requisitionAccountPercent);
            }
            requisitionForm.addAccountDistributionsourceAccountingLine(requisitionAccount);
        }
    }
}
Also used : IWantAccount(edu.cornell.kfs.module.purap.businessobject.IWantAccount) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) BigDecimal(java.math.BigDecimal)

Example 25 with PurApAccountingLine

use of org.kuali.kfs.module.purap.businessobject.PurApAccountingLine in project cu-kfs by CU-CommunityApps.

the class CuPurchaseOrderForm method populateItemAccountingLines.

// end KFSUPGRADE-411
/**
 * Overridden to properly increment the local "itemCount" loop counter when processing POA documents,
 * but otherwise has the same code as in the superclass.
 *
 * @see org.kuali.kfs.module.purap.document.web.struts.PurchasingAccountsPayableFormBase#populateItemAccountingLines(java.util.Map)
 */
@SuppressWarnings("rawtypes")
@Override
protected void populateItemAccountingLines(Map parameterMap) {
    if (!(getDocument() instanceof PurchaseOrderAmendmentDocument)) {
        super.populateItemAccountingLines(parameterMap);
        return;
    }
    int itemCount = 0;
    for (PurApItem item : ((PurchasingAccountsPayableDocument) getDocument()).getItems()) {
        populateAccountingLine(item.getNewSourceLine(), KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.ITEM + "[" + itemCount + "]." + KFSPropertyConstants.NEW_SOURCE_LINE, parameterMap);
        int sourceLineCount = 0;
        for (PurApAccountingLine purApLine : item.getSourceAccountingLines()) {
            populateAccountingLine(purApLine, KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.ITEM + "[" + itemCount + "]." + KFSPropertyConstants.SOURCE_ACCOUNTING_LINE + "[" + sourceLineCount + "]", parameterMap);
            sourceLineCount += 1;
        }
        itemCount += 1;
    }
}
Also used : PurchaseOrderAmendmentDocument(org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)

Aggregations

PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)27 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)17 ArrayList (java.util.ArrayList)9 List (java.util.List)7 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)7 BigDecimal (java.math.BigDecimal)6 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)5 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)5 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)4 IWantAccount (edu.cornell.kfs.module.purap.businessobject.IWantAccount)3 PurchaseOrderAmendmentDocument (org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument)3 PurchasingAccountsPayableDocument (org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)3 KfsParameterConstants (org.kuali.kfs.sys.service.impl.KfsParameterConstants)3 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)3 Account (org.kuali.kfs.coa.businessobject.Account)2 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)2 PurchasingItemBase (org.kuali.kfs.module.purap.businessobject.PurchasingItemBase)2 RequisitionAccount (org.kuali.kfs.module.purap.businessobject.RequisitionAccount)2 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)2 PurchasingAccountsPayableDocumentBase (org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocumentBase)2