Search in sources :

Example 1 with PurchasingAccountsPayableDocument

use of org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method deleteSourceLine.

/**
 * @see org.kuali.kfs.sys.web.struts.KualiAccountingDocumentActionBase#deleteSourceLine(org.apache.struts.action.ActionMapping,
 *      org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward deleteSourceLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
    String[] indexes = getSelectedLineForAccounts(request);
    int itemIndex = Integer.parseInt(indexes[0]);
    int accountIndex = Integer.parseInt(indexes[1]);
    if (itemIndex == -2) {
        purchasingForm.getAccountDistributionsourceAccountingLines().remove(accountIndex);
    } else {
        PurApItem item = ((PurchasingAccountsPayableDocument) purchasingForm.getDocument()).getItem((itemIndex));
        item.getSourceAccountingLines().remove(accountIndex);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)

Example 2 with PurchasingAccountsPayableDocument

use of org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument in project cu-kfs by CU-CommunityApps.

the class CuPurchaseOrderAmendmentHasUnitCostAndValidPercentage method validate.

public boolean validate(AttributedDocumentEvent event) {
    boolean valid = true;
    PurchasingAccountsPayableDocument purapDocument = (PurchasingAccountsPayableDocument) event.getDocument();
    List<PurApItem> items = purapDocument.getItems();
    for (PurApItem item : items) {
        if (item.isConsideredEntered()) {
            BigDecimal unitPrice = ((PurchaseOrderItem) item).getItemUnitPrice();
            List<PurApAccountingLine> lines = item.getSourceAccountingLines();
            // check if unit price is zero or null and item has accounts associated with it
            if ((unitPrice == null || (unitPrice.compareTo(BigDecimal.ZERO) == 0)) && lines.size() > 0) {
                GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERRORS, CUKFSKeyConstants.ERROR_NO_UNIT_COST_WITH_ACCOUNTS, item.getItemIdentifierString());
                valid = false;
            }
            if ((unitPrice != null && unitPrice.compareTo(BigDecimal.ZERO) != 0) && lines.size() == 0) {
                GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERRORS, CUKFSKeyConstants.ERROR_UNIT_COST_W_O_ACCOUNT, item.getItemIdentifierString());
                valid = false;
            }
            BigDecimal totalPercent = new BigDecimal(0);
            for (PurApAccountingLine accountingLine : lines) {
                totalPercent = totalPercent.add(accountingLine.getAccountLinePercent());
                // if an account distribution is zero percent, invalid
                if (accountingLine.getAccountLinePercent().compareTo(BigDecimal.ZERO) == 0) {
                    GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, CUKFSKeyConstants.ERROR_NO_ZERO_PERCENT_ACCOUNT_LINES_ALLOWED, item.getItemIdentifierString());
                    valid = false;
                }
            }
            // if total percent is not 100, error
            if (totalPercent.compareTo(new BigDecimal(100)) != 0) {
                // KFSPTS-1769.  if it is spawnpoa for unordered item, then don't check
                if (!((purapDocument instanceof CuPurchaseOrderAmendmentDocument) && ((CuPurchaseOrderAmendmentDocument) purapDocument).isSpawnPoa())) {
                    GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, PurapKeyConstants.ERROR_ITEM_ACCOUNTING_TOTAL, item.getItemIdentifierString());
                    valid = false;
                }
            }
        }
    }
    return valid;
}
Also used : PurchaseOrderItem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem) CuPurchaseOrderAmendmentDocument(edu.cornell.kfs.module.purap.document.CuPurchaseOrderAmendmentDocument) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument) BigDecimal(java.math.BigDecimal)

Example 3 with PurchasingAccountsPayableDocument

use of org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument in project cu-kfs by CU-CommunityApps.

the class PurApItemBase method refreshNonUpdateableReferences.

@Override
public void refreshNonUpdateableReferences() {
    PurchasingAccountsPayableDocument document = null;
    PurchasingAccountsPayableDocument tempDocument = getPurapDocument();
    if (tempDocument != null) {
        Integer tempDocumentIdentifier = tempDocument.getPurapDocumentIdentifier();
        if (tempDocumentIdentifier != null) {
            document = this.getPurapDocument();
        }
    }
    super.refreshNonUpdateableReferences();
    if (ObjectUtils.isNotNull(document)) {
        this.setPurapDocument(document);
    }
}
Also used : PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)

Example 4 with PurchasingAccountsPayableDocument

use of org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument in project cu-kfs by CU-CommunityApps.

the class PurchasingAccountsPayableTransactionalDocumentAuthorizerBase method addRoleQualification.

@Override
protected void addRoleQualification(Object businessObject, Map<String, String> attributes) {
    super.addRoleQualification(businessObject, attributes);
    attributes.put(PurapKimAttributes.DOCUMENT_SENSITIVE, "false");
    PurchasingAccountsPayableDocument purapDoc = (PurchasingAccountsPayableDocument) businessObject;
    if (purapDoc.getAccountsPayablePurchasingDocumentLinkIdentifier() != null) {
        List<SensitiveData> sensitiveDataList = SpringContext.getBean(SensitiveDataService.class).getSensitiveDatasAssignedByRelatedDocId(purapDoc.getAccountsPayablePurchasingDocumentLinkIdentifier());
        if (ObjectUtils.isNotNull(sensitiveDataList) && !sensitiveDataList.isEmpty()) {
            StringBuffer sensitiveDataCodes = new StringBuffer();
            for (SensitiveData sensitiveData : sensitiveDataList) {
                if (ObjectUtils.isNotNull(sensitiveData)) {
                    sensitiveDataCodes.append(sensitiveData.getSensitiveDataCode()).append(";");
                }
            }
            if (sensitiveDataCodes.length() > 0) {
                attributes.put(PurapKimAttributes.DOCUMENT_SENSITIVE, "true");
                attributes.put(PurapKimAttributes.SENSITIVE_DATA_CODE, sensitiveDataCodes.toString().substring(0, sensitiveDataCodes.length() - 1));
                attributes.put(PurapKimAttributes.ACCOUNTS_PAYABLE_PURCHASING_DOCUMENT_LINK_IDENTIFIER, purapDoc.getAccountsPayablePurchasingDocumentLinkIdentifier().toString());
            }
        // KFSUPGRADE-346
        } else if (purapDoc.isSensitive()) {
            attributes.put(PurapKimAttributes.DOCUMENT_SENSITIVE, "true");
        }
    }
}
Also used : SensitiveDataService(org.kuali.kfs.module.purap.service.SensitiveDataService) SensitiveData(org.kuali.kfs.module.purap.businessobject.SensitiveData) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)

Example 5 with PurchasingAccountsPayableDocument

use of org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument in project cu-kfs by CU-CommunityApps.

the class PurchasingAddItemValidation method validate.

public boolean validate(AttributedDocumentEvent event) {
    boolean valid = true;
    GlobalVariables.getMessageMap().addToErrorPath(PurapPropertyConstants.NEW_PURCHASING_ITEM_LINE);
    // refresh itemType
    PurApItem refreshedItem = getItemForValidation();
    refreshedItem.refreshReferenceObject("itemType");
    super.setItemForValidation(refreshedItem);
    valid &= super.validate(event);
    valid &= validateItemUnitPrice(getItemForValidation());
    valid &= validateUnitOfMeasure(getItemForValidation());
    if (getItemForValidation().getItemType().isLineItemIndicator()) {
        valid &= validateItemDescription(getItemForValidation());
        valid &= validateItemQuantity(getItemForValidation());
        commodityCodeValidation.setItemForValidation(getItemForValidation());
        valid &= commodityCodeValidation.validate(event);
        // KFSPTS-2096
        valid &= validateMixItemType(getItemForValidation(), (PurchasingAccountsPayableDocument) event.getDocument());
    }
    GlobalVariables.getMessageMap().removeFromErrorPath(PurapPropertyConstants.NEW_PURCHASING_ITEM_LINE);
    return valid;
}
Also used : PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)

Aggregations

PurchasingAccountsPayableDocument (org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)10 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)5 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)3 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)2 PurchaseOrderAmendmentDocument (org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument)2 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)2 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)2 CuPurchaseOrderAmendmentDocument (edu.cornell.kfs.module.purap.document.CuPurchaseOrderAmendmentDocument)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)1 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)1 Document (org.kuali.kfs.krad.document.Document)1 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)1 MessageMap (org.kuali.kfs.krad.util.MessageMap)1 PurchasingItemBase (org.kuali.kfs.module.purap.businessobject.PurchasingItemBase)1 SensitiveData (org.kuali.kfs.module.purap.businessobject.SensitiveData)1 PurchasingAccountsPayableDocumentBase (org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocumentBase)1