Search in sources :

Example 16 with PurchasingDocument

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

the class PurchasingActionBase method selectSystem.

public ActionForward selectSystem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingAccountsPayableFormBase purchasingForm = (PurchasingAccountsPayableFormBase) form;
    PurchasingDocument document = (PurchasingDocument) purchasingForm.getDocument();
    String errorPath = PurapConstants.CAPITAL_ASSET_TAB_ERRORS;
    // validate entry is selected for each field
    if (StringUtils.isEmpty(document.getCapitalAssetSystemTypeCode())) {
        GlobalVariables.getMessageMap().putError(errorPath, KFSKeyConstants.ERROR_CUSTOM, "Capital Asset System Type and Capital Asset System State are both required to proceed");
    } else if (StringUtils.isEmpty(document.getCapitalAssetSystemStateCode())) {
        GlobalVariables.getMessageMap().putError(errorPath, KFSKeyConstants.ERROR_CUSTOM, "Capital Asset System Type and Capital Asset System State are both required to proceed");
    } else {
        document.refreshReferenceObject(PurapPropertyConstants.CAPITAL_ASSET_SYSTEM_TYPE);
        document.refreshReferenceObject(PurapPropertyConstants.CAPITAL_ASSET_SYSTEM_STATE);
        if (validateCapitalAssetSystemStateAllowed(document.getCapitalAssetSystemType(), document.getCapitalAssetSystemState())) {
            SpringContext.getBean(PurchasingService.class).setupCapitalAssetSystem(document);
            SpringContext.getBean(PurchasingService.class).setupCapitalAssetItems(document);
            if (!document.getPurchasingCapitalAssetItems().isEmpty()) {
                saveDocumentNoValidationUsingClearErrorMap(document);
            } else {
                // TODO: extract this and above strings to app resources
                GlobalVariables.getMessageMap().putError(errorPath, KFSKeyConstants.ERROR_CUSTOM, "No items were found that met the requirements for Capital Asset data collection");
            }
            saveDocumentNoValidationUsingClearErrorMap(document);
        } else {
            // Blank out type selection, otherwise UI marks it read only
            document.setCapitalAssetSystemStateCode(null);
            document.setCapitalAssetSystemState(null);
        }
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument)

Example 17 with PurchasingDocument

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

the class PurchasingFormBase method getPurchasingCapitalAssetSystemCommentsAvailability.

public String getPurchasingCapitalAssetSystemCommentsAvailability() {
    String availability = PurapConstants.CapitalAssetAvailability.NONE;
    PurchasingDocument pd = (PurchasingDocument) this.getDocument();
    if ((PurapConstants.CapitalAssetSystemTypes.ONE_SYSTEM.equals(pd.getCapitalAssetSystemTypeCode()) || PurapConstants.CapitalAssetSystemTypes.MULTIPLE.equals(pd.getCapitalAssetSystemTypeCode()))) {
        availability = PurapConstants.CapitalAssetAvailability.ONCE;
    } else if (PurapConstants.CapitalAssetSystemTypes.INDIVIDUAL.equals(pd.getCapitalAssetSystemTypeCode())) {
        availability = PurapConstants.CapitalAssetAvailability.EACH;
    }
    return availability;
}
Also used : PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument)

Example 18 with PurchasingDocument

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

the class PurchasingFormBase method getPurchasingCapitalAssetCountAssetNumberAvailability.

public String getPurchasingCapitalAssetCountAssetNumberAvailability() {
    String availability = PurapConstants.CapitalAssetAvailability.NONE;
    PurchasingDocument pd = (PurchasingDocument) this.getDocument();
    if ((PurapConstants.CapitalAssetSystemTypes.ONE_SYSTEM.equals(pd.getCapitalAssetSystemTypeCode()) && PurapConstants.CapitalAssetSystemStates.NEW.equals(pd.getCapitalAssetSystemStateCode()))) {
        availability = PurapConstants.CapitalAssetAvailability.ONCE;
    }
    return availability;
}
Also used : PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument)

Example 19 with PurchasingDocument

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

the class PurchasingFormBase method getPurchasingCapitalAssetSystemDescriptionAvailability.

public String getPurchasingCapitalAssetSystemDescriptionAvailability() {
    String availability = PurapConstants.CapitalAssetAvailability.NONE;
    PurchasingDocument pd = (PurchasingDocument) this.getDocument();
    if ((PurapConstants.CapitalAssetSystemTypes.ONE_SYSTEM.equals(pd.getCapitalAssetSystemTypeCode()) && PurapConstants.CapitalAssetSystemStates.NEW.equals(pd.getCapitalAssetSystemStateCode())) || (PurapConstants.CapitalAssetSystemTypes.MULTIPLE.equals(pd.getCapitalAssetSystemTypeCode()) && PurapConstants.CapitalAssetSystemStates.NEW.equals(pd.getCapitalAssetSystemStateCode()))) {
        availability = PurapConstants.CapitalAssetAvailability.ONCE;
    }
    return availability;
}
Also used : PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument)

Example 20 with PurchasingDocument

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

the class CuRequisitionAction method addItem.

@SuppressWarnings("unchecked")
@Override
public ActionForward addItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
    PurApItem item = purchasingForm.getNewPurchasingItemLine();
    RequisitionItem requisitionItem = (RequisitionItem) item;
    PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();
    if (StringUtils.isBlank(requisitionItem.getPurchasingCommodityCode())) {
        boolean commCodeParam = SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(CuRequisitionDocument.class, PurapParameterConstants.ENABLE_DEFAULT_VENDOR_COMMODITY_CODE_IND);
        if (commCodeParam) {
            if (purchasingForm instanceof RequisitionForm) {
                CuRequisitionDocument reqs = (CuRequisitionDocument) purchasingForm.getDocument();
                VendorDetail dtl = reqs.getVendorDetail();
                if (ObjectUtils.isNotNull(dtl)) {
                    List<VendorCommodityCode> vcc = dtl.getVendorCommodities();
                    String defaultCommodityCode = "";
                    Iterator<VendorCommodityCode> it = vcc.iterator();
                    while (it.hasNext()) {
                        VendorCommodityCode commodity = it.next();
                        if (commodity.isCommodityDefaultIndicator()) {
                            defaultCommodityCode = commodity.getPurchasingCommodityCode();
                            requisitionItem.setPurchasingCommodityCode(defaultCommodityCode);
                        }
                    }
                }
            }
        }
    }
    boolean rulePassed = SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedAddPurchasingAccountsPayableItemEvent("", purDocument, item));
    if (rulePassed) {
        item = purchasingForm.getAndResetNewPurchasingItemLine();
        purDocument.addItem(item);
        // KFSPTS-985
        if (((PurchasingDocumentBase) (purDocument)).isIntegratedWithFavoriteAccount()) {
            populatePrimaryFavoriteAccount(item.getSourceAccountingLines(), getAccountClassFromNewPurApAccountingLine(purchasingForm));
        }
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : CuRequisitionDocument(edu.cornell.kfs.module.purap.document.CuRequisitionDocument) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) PurchasingDocumentBase(org.kuali.kfs.module.purap.document.PurchasingDocumentBase) VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) RequisitionItem(org.kuali.kfs.module.purap.businessobject.RequisitionItem) PurchasingFormBase(org.kuali.kfs.module.purap.document.web.struts.PurchasingFormBase) AttributedAddPurchasingAccountsPayableItemEvent(org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingAccountsPayableItemEvent) RequisitionForm(org.kuali.kfs.module.purap.document.web.struts.RequisitionForm) VendorCommodityCode(org.kuali.kfs.vnd.businessobject.VendorCommodityCode)

Aggregations

PurchasingDocument (org.kuali.kfs.module.purap.document.PurchasingDocument)42 CapitalAssetSystem (org.kuali.kfs.integration.purap.CapitalAssetSystem)14 PurchasingCapitalAssetItem (org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem)10 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)7 PurapService (org.kuali.kfs.module.purap.document.service.PurapService)6 PurchasingService (org.kuali.kfs.module.purap.document.service.PurchasingService)5 ItemCapitalAsset (org.kuali.kfs.integration.purap.ItemCapitalAsset)4 MessageMap (org.kuali.kfs.krad.util.MessageMap)4 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)4 ActionForward (org.apache.struts.action.ActionForward)3 Map (java.util.Map)2 CapitalAssetLocation (org.kuali.kfs.integration.purap.CapitalAssetLocation)2 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)2 PurchasingCapitalAssetSystemBase (org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetSystemBase)2 PurchaseOrderAmendmentDocument (org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument)2 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)2 PurchasingDocumentBase (org.kuali.kfs.module.purap.document.PurchasingDocumentBase)2 AttributedAddPurchasingAccountsPayableItemEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingAccountsPayableItemEvent)2 AttributedAddPurchasingCapitalAssetLocationEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingCapitalAssetLocationEvent)2 AttributedAddPurchasingItemCapitalAssetEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingItemCapitalAssetEvent)2