Search in sources :

Example 1 with CuRequisitionDocument

use of edu.cornell.kfs.module.purap.document.CuRequisitionDocument in project cu-kfs by CU-CommunityApps.

the class CuRequisitionAction method copy.

/**
 * Overridden to guarantee that form of copied document is set to whatever the entry mode of the document is
 * @see org.kuali.kfs.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 {
    ActionForward forward = null;
    String docID = "docId";
    if (request.getParameter(docID) == null) {
        forward = super.copy(mapping, form, request, response);
    } else {
        // this is copy document from Procurement Gateway:
        // use this url to call: http://localhost:8080/kfs-dev/purapRequisition.do?methodToCall=copy&docId=xxxx
        String docId = request.getParameter(docID);
        KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
        CuRequisitionDocument document = null;
        document = (CuRequisitionDocument) getDocumentService().getByDocumentHeaderId(docId);
        document.toCopyFromGateway();
        kualiDocumentFormBase.setDocument(document);
        WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
        kualiDocumentFormBase.setDocTypeName(workflowDocument.getDocumentTypeName());
        SpringContext.getBean(SessionDocumentService.class).addDocumentToUserSession(GlobalVariables.getUserSession(), workflowDocument);
        forward = mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
    return forward;
}
Also used : CuRequisitionDocument(edu.cornell.kfs.module.purap.document.CuRequisitionDocument) SessionDocumentService(org.kuali.kfs.krad.service.SessionDocumentService) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) ActionForward(org.apache.struts.action.ActionForward)

Example 2 with CuRequisitionDocument

use of edu.cornell.kfs.module.purap.document.CuRequisitionDocument 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 CuRequisitionDocument

use of edu.cornell.kfs.module.purap.document.CuRequisitionDocument in project cu-kfs by CU-CommunityApps.

the class CuRequisitionAction method clearVendor.

public ActionForward clearVendor(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase baseForm = (PurchasingFormBase) form;
    CuRequisitionDocument document = (CuRequisitionDocument) baseForm.getDocument();
    document.setVendorHeaderGeneratedIdentifier(null);
    document.setVendorDetailAssignedIdentifier(null);
    document.setVendorDetail(null);
    document.setVendorName("");
    document.setVendorLine1Address("");
    document.setVendorLine2Address("");
    document.setVendorAddressInternationalProvinceName("");
    document.setVendorCityName("");
    document.setVendorStateCode("");
    document.setVendorPostalCode("");
    document.setVendorCountryCode("");
    document.setVendorContractGeneratedIdentifier(null);
    document.setVendorContract(null);
    document.setVendorFaxNumber("");
    document.setVendorCustomerNumber("");
    document.setVendorAttentionName("");
    document.setVendorAddressGeneratedIdentifier(null);
    // clearing value that was set in PurchasingDocumentBase.templateVendorAction
    document.setVendorAddressGeneratedIdentifier(null);
    // clearing value that was set in PurchasingDocumentBase.templateVendorAction
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : CuRequisitionDocument(edu.cornell.kfs.module.purap.document.CuRequisitionDocument) PurchasingFormBase(org.kuali.kfs.module.purap.document.web.struts.PurchasingFormBase)

Aggregations

CuRequisitionDocument (edu.cornell.kfs.module.purap.document.CuRequisitionDocument)3 PurchasingFormBase (org.kuali.kfs.module.purap.document.web.struts.PurchasingFormBase)2 ActionForward (org.apache.struts.action.ActionForward)1 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)1 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)1 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)1 SessionDocumentService (org.kuali.kfs.krad.service.SessionDocumentService)1 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)1 RequisitionItem (org.kuali.kfs.module.purap.businessobject.RequisitionItem)1 PurchasingDocument (org.kuali.kfs.module.purap.document.PurchasingDocument)1 PurchasingDocumentBase (org.kuali.kfs.module.purap.document.PurchasingDocumentBase)1 AttributedAddPurchasingAccountsPayableItemEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingAccountsPayableItemEvent)1 RequisitionForm (org.kuali.kfs.module.purap.document.web.struts.RequisitionForm)1 VendorCommodityCode (org.kuali.kfs.vnd.businessobject.VendorCommodityCode)1 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)1 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)1