Search in sources :

Example 1 with PurchasingDocumentBase

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

the class PurchasingActionBase method addItem.

/**
 * Add a new item to the document.
 *
 * @param mapping An ActionMapping
 * @param form An ActionForm
 * @param request The HttpServletRequest
 * @param response The HttpServletResponse
 * @return An ActionForward
 * @throws Exception
 */
@SuppressWarnings("unchecked")
public ActionForward addItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
    PurApItem item = purchasingForm.getNewPurchasingItemLine();
    PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();
    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 : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) AttributedAddPurchasingAccountsPayableItemEvent(org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingAccountsPayableItemEvent) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) PurchasingDocumentBase(org.kuali.kfs.module.purap.document.PurchasingDocumentBase)

Example 2 with PurchasingDocumentBase

use of org.kuali.kfs.module.purap.document.PurchasingDocumentBase 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)

Example 3 with PurchasingDocumentBase

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

the class CuPurchasingProcessVendorValidation method validateDataForMethodOfPOTransmissionExistsOnVendorAddress.

/**
 * This routine verifies that the data necessary for the Method of PO Transmission chosen on the REQ,
 * PO, or POA document exists on the document's VendorAddress record for the chosen Vendor.
 * If the required checks pass, true is returned.
 * If the required checks fail, false is returned.
 *
 * NOTE: This routine could not be used for the VendorAddress validation checks on the Vendor maintenance
 * document because the Method of PO Transmission value selectable on that document pertains to the specific
 * VendorAddress being maintained.  The method of PO transmission being used for this routine's validation
 * checks is the one that is present on the input parameter purchasing document (REQ, PO, or POA) and could
 * be different from the value of the same name that is on the VendorAddress.  It is ok if these two values
 * are different because the user could have changed it after the default was obtained via the lookup and
 * used to populate the REQ, PO, or POA value as long as the data required for the method of PO transmission
 * selected in that document exists on the VendorAddress record chosen on the REQ, PO, or POA.
 *
 * 	For KFSPTS-1458: This method was changed extensively to address new business rules.
 */
public boolean validateDataForMethodOfPOTransmissionExistsOnVendorAddress(Document document) {
    boolean dataExists = true;
    MessageMap errorMap = GlobalVariables.getMessageMap();
    errorMap.clearErrorPath();
    errorMap.addToErrorPath(PurapConstants.VENDOR_ERRORS);
    // for REQ, PO, and POA verify that data exists on form for method of PO transmission value selected
    if ((document instanceof RequisitionDocument) || (document instanceof PurchaseOrderDocument) || (document instanceof PurchaseOrderAmendmentDocument)) {
        PurchaseOrderTransmissionMethodDataRulesServiceImpl purchaseOrderTransmissionMethodDataRulesServiceImpl = SpringContext.getBean(PurchaseOrderTransmissionMethodDataRulesServiceImpl.class);
        PurchasingDocumentBase purapDocument = (PurchasingDocumentBase) document;
        String poTransMethodCode = purapDocument.getPurchaseOrderTransmissionMethodCode();
        if (poTransMethodCode != null && !StringUtils.isBlank(poTransMethodCode)) {
            if (poTransMethodCode.equals(PurapConstants.POTransmissionMethods.FAX)) {
                dataExists = purchaseOrderTransmissionMethodDataRulesServiceImpl.isFaxNumberValid(purapDocument.getVendorFaxNumber());
                if (!dataExists) {
                    errorMap.putError(VendorPropertyConstants.VENDOR_FAX_NUMBER, CUPurapKeyConstants.PURAP_MOPOT_REQUIRED_DATA_MISSING);
                }
            } else if (poTransMethodCode.equals(CUPurapConstants.POTransmissionMethods.EMAIL)) {
                dataExists = purchaseOrderTransmissionMethodDataRulesServiceImpl.isEmailAddressValid(purapDocument.getVendorEmailAddress());
                if (!dataExists) {
                    errorMap.putError("vendorEmailAddress", CUPurapKeyConstants.PURAP_MOPOT_REQUIRED_DATA_MISSING);
                }
            } else if (poTransMethodCode.equals(CUPurapConstants.POTransmissionMethods.MANUAL)) {
                dataExists = purchaseOrderTransmissionMethodDataRulesServiceImpl.isPostalAddressValid(purapDocument.getVendorLine1Address(), purapDocument.getVendorCityName(), purapDocument.getVendorStateCode(), purapDocument.getVendorPostalCode(), purapDocument.getVendorCountryCode());
                if (!dataExists) {
                    errorMap.putError(VendorPropertyConstants.VENDOR_ADDRESS_LINE_1, CUPurapKeyConstants.PURAP_MOPOT_REQUIRED_DATA_MISSING);
                }
            }
        }
    }
    return dataExists;
}
Also used : RequisitionDocument(org.kuali.kfs.module.purap.document.RequisitionDocument) PurchaseOrderAmendmentDocument(org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) PurchaseOrderTransmissionMethodDataRulesServiceImpl(edu.cornell.kfs.module.purap.document.service.impl.PurchaseOrderTransmissionMethodDataRulesServiceImpl) MessageMap(org.kuali.kfs.krad.util.MessageMap) PurchasingDocumentBase(org.kuali.kfs.module.purap.document.PurchasingDocumentBase)

Example 4 with PurchasingDocumentBase

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

the class PurchasingActionBase method populateDeliveryBuilding.

public ActionForward populateDeliveryBuilding(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase purForm = (PurchasingFormBase) form;
    PurchasingDocumentBase document = (PurchasingDocumentBase) purForm.getDocument();
    updateDeliveryBuilding(request, document);
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PurchasingDocumentBase(org.kuali.kfs.module.purap.document.PurchasingDocumentBase)

Example 5 with PurchasingDocumentBase

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

the class PurchasingActionBase method selectSystemType.

/**
 * This method...
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward selectSystemType(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingAccountsPayableFormBase purchasingForm = (PurchasingAccountsPayableFormBase) form;
    PurchasingDocumentBase document = (PurchasingDocumentBase) purchasingForm.getDocument();
    Object question = request.getParameter(PurapConstants.QUESTION_INDEX);
    Object buttonClicked = request.getParameter(KFSConstants.QUESTION_CLICKED_BUTTON);
    String systemTypeCode = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    systemTypeCode = StringUtils.substringBetween(systemTypeCode, "selectSystemType.", ".");
    if (question == null) {
        String questionText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(PurapConstants.CapitalAssetTabStrings.QUESTION_SYSTEM_SWITCHING);
        return this.performQuestionWithoutInput(mapping, form, request, response, PurapConstants.CapitalAssetTabStrings.SYSTEM_SWITCHING_QUESTION, questionText, KFSConstants.CONFIRMATION_QUESTION, KFSConstants.ROUTE_METHOD, "0");
    } else if (ConfirmationQuestion.YES.equals(buttonClicked)) {
        // document.setCapitalAssetSystemTypeCode(systemTypeCode);
        document.refreshReferenceObject(PurapPropertyConstants.CAPITAL_ASSET_SYSTEM_TYPE);
        KNSGlobalVariables.getMessageList().add(PurapKeyConstants.PUR_CAPITAL_ASSET_SYSTEM_TYPE_SWITCHED);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) ConfigurationService(org.kuali.rice.core.api.config.property.ConfigurationService) PurchasingDocumentBase(org.kuali.kfs.module.purap.document.PurchasingDocumentBase)

Aggregations

PurchasingDocumentBase (org.kuali.kfs.module.purap.document.PurchasingDocumentBase)9 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)2 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)2 PurchasingDocument (org.kuali.kfs.module.purap.document.PurchasingDocument)2 AttributedAddPurchasingAccountsPayableItemEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingAccountsPayableItemEvent)2 CuRequisitionDocument (edu.cornell.kfs.module.purap.document.CuRequisitionDocument)1 PurchaseOrderTransmissionMethodDataRulesServiceImpl (edu.cornell.kfs.module.purap.document.service.impl.PurchaseOrderTransmissionMethodDataRulesServiceImpl)1 PurchasingFavoriteAccountLineBuilderForDistribution (edu.cornell.kfs.module.purap.util.PurchasingFavoriteAccountLineBuilderForDistribution)1 FavoriteAccountValuesFinder (edu.cornell.kfs.sys.businessobject.options.FavoriteAccountValuesFinder)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)1 PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)1 MessageMap (org.kuali.kfs.krad.util.MessageMap)1 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)1 PurchasingItemBase (org.kuali.kfs.module.purap.businessobject.PurchasingItemBase)1 RequisitionItem (org.kuali.kfs.module.purap.businessobject.RequisitionItem)1 PurchaseOrderAmendmentDocument (org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument)1 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)1 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)1