Search in sources :

Example 21 with IWantDocument

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

the class IWantDocumentAction method save.

@Override
public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
    // Only recreate document description if in INITIATED or SAVED status.
    WorkflowDocument workflowDocument = ((KualiDocumentFormBase) form).getDocument().getDocumentHeader().getWorkflowDocument();
    if (workflowDocument.isInitiated() || workflowDocument.isSaved()) {
        iWantDocumentService.setIWantDocumentDescription((IWantDocument) ((KualiDocumentFormBase) form).getDocument());
    }
    ActionForward actionForward = super.save(mapping, form, request, response);
    IWantDocumentForm iWantDocForm = (IWantDocumentForm) form;
    IWantDocument iWantDocument = iWantDocForm.getIWantDocument();
    boolean added = true;
    // add new item and new accounting line if not empty
    IWantItem item = iWantDocForm.getNewIWantItemLine();
    if (StringUtils.isNotBlank(item.getItemDescription()) || item.getItemUnitPrice() != null || item.getItemQuantity() != null) {
        added &= addNewItem(iWantDocForm, iWantDocument, item);
    }
    added &= addNewFavoriteAccountIfNecessary(added, iWantDocument);
    if (added) {
        IWantAccount account = iWantDocForm.getNewSourceLine();
        if (StringUtils.isNotBlank(account.getAccountNumber()) || StringUtils.isNotBlank(account.getSubAccountNumber()) || StringUtils.isNotBlank(account.getFinancialObjectCode()) || StringUtils.isNotBlank(account.getFinancialSubObjectCode()) || StringUtils.isNotBlank(account.getProjectCode()) || StringUtils.isNotBlank(account.getOrganizationReferenceId())) {
            added &= addNewAccount(iWantDocForm, iWantDocument, account);
        }
    }
    // Do not save if item or account additions failed.
    if (!added) {
        return mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
    iWantDocument.setExplanation(iWantDocument.getDocumentHeader().getExplanation());
    if (StringUtils.isNotBlank(iWantDocForm.getNewAdHocRoutePerson().getId())) {
        iWantDocument.setCurrentRouteToNetId(iWantDocForm.getNewAdHocRoutePerson().getId());
    }
    return actionForward;
}
Also used : IWantAccount(edu.cornell.kfs.module.purap.businessobject.IWantAccount) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem) ActionForward(org.apache.struts.action.ActionForward) IWantDocumentService(edu.cornell.kfs.module.purap.document.service.IWantDocumentService) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Example 22 with IWantDocument

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

the class IWantDocumentAction method refresh.

/**
 * @see org.kuali.kfs.kns.web.struts.action.KualiDocumentActionBase#refresh(org.apache.struts.action.ActionMapping,
 * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
 * javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    IWantDocumentForm iWantDocForm = (IWantDocumentForm) form;
    IWantDocument iWantDocument = iWantDocForm.getIWantDocument();
    ActionForward actionForward = super.refresh(mapping, form, request, response);
    String refreshCaller = request.getParameter(KFSConstants.REFRESH_CALLER);
    if (refreshCaller != null && refreshCaller.endsWith(KFSConstants.LOOKUPABLE_SUFFIX)) {
        String deliverToNetID = iWantDocument.getDeliverToNetID();
        if (StringUtils.isNotEmpty(deliverToNetID)) {
            IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
            String address = iWantDocumentService.getPersonCampusAddress(deliverToNetID);
            iWantDocument.setDeliverToAddress(address);
        }
        if ("iWantDocVendorLookupable".equalsIgnoreCase(refreshCaller)) {
            Integer vendorHeaderId = iWantDocument.getVendorHeaderGeneratedIdentifier();
            Integer vendorId = iWantDocument.getVendorDetailAssignedIdentifier();
            String phoneNumber = "Phone: ";
            Map<String, Object> fieldValues = new HashMap<String, Object>();
            fieldValues.put("vendorHeaderGeneratedIdentifier", vendorHeaderId);
            fieldValues.put("vendorDetailAssignedIdentifier", vendorId);
            fieldValues.put("vendorPhoneTypeCode", "PH");
            Collection<VendorPhoneNumber> vendorPhoneNumbers = getBusinessObjectService().findMatching(VendorPhoneNumber.class, fieldValues);
            if (ObjectUtils.isNotNull(vendorPhoneNumbers) && vendorPhoneNumbers.size() > 0) {
                VendorPhoneNumber retrievedVendorPhoneNumber = vendorPhoneNumbers.toArray(new VendorPhoneNumber[1])[0];
                phoneNumber += retrievedVendorPhoneNumber.getVendorPhoneNumber();
            }
            // populate vendor info
            String addressLine1 = iWantDocument.getVendorLine1Address() != null ? iWantDocument.getVendorLine1Address() : StringUtils.EMPTY;
            String addressLine2 = iWantDocument.getVendorLine2Address() != null ? iWantDocument.getVendorLine2Address() : StringUtils.EMPTY;
            String cityName = iWantDocument.getVendorCityName() != null ? iWantDocument.getVendorCityName() : StringUtils.EMPTY;
            String stateCode = iWantDocument.getVendorStateCode() != null ? iWantDocument.getVendorStateCode() : StringUtils.EMPTY;
            String countryCode = iWantDocument.getVendorCountryCode() != null ? iWantDocument.getVendorCountryCode() : StringUtils.EMPTY;
            String postalCode = iWantDocument.getVendorPostalCode() != null ? iWantDocument.getVendorPostalCode() : StringUtils.EMPTY;
            String faxNumber = "Fax: " + (iWantDocument.getVendorFaxNumber() != null ? iWantDocument.getVendorFaxNumber() : StringUtils.EMPTY);
            String url = "URL: " + (iWantDocument.getVendorWebURL() != null ? iWantDocument.getVendorWebURL() : StringUtils.EMPTY);
            String vendorInfo = new StringBuilder(100).append(addressLine1).append('\n').append(addressLine2).append('\n').append(cityName).append(", ").append(postalCode).append(", ").append(stateCode).append(", ").append(countryCode).append('\n').append(faxNumber).append('\n').append(phoneNumber).append(" \n").append(url).toString();
            iWantDocument.setVendorDescription(vendorInfo);
        }
    }
    return actionForward;
}
Also used : HashMap(java.util.HashMap) ActionForward(org.apache.struts.action.ActionForward) VendorPhoneNumber(org.kuali.kfs.vnd.businessobject.VendorPhoneNumber) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument) IWantDocumentService(edu.cornell.kfs.module.purap.document.service.IWantDocumentService)

Example 23 with IWantDocument

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

the class IWantDocumentAction method continueToItems.

/**
 * Takes the user to next page
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward continueToItems(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    IWantDocumentForm iWantForm = (IWantDocumentForm) form;
    IWantDocument iWantDocument = iWantForm.getIWantDocument();
    iWantDocument.setExplanation(iWantDocument.getDocumentHeader().getExplanation());
    KualiRuleService ruleService = SpringContext.getBean(KualiRuleService.class);
    boolean rulePassed = true;
    // call business rules
    rulePassed &= ruleService.applyRules(new RouteDocumentEvent(KFSConstants.DOCUMENT_HEADER_ERRORS, iWantDocument));
    if (rulePassed) {
        iWantForm.setStep(CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP);
        iWantDocument.setStep(CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) RouteDocumentEvent(org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Example 24 with IWantDocument

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

the class IWantDocumentAction method addFavoriteAccount.

/**
 * Adds a new IWNT account to the document using the selected Favorite Account from the drop-down.
 * This is similar to a method on PurchasingActionBase, but has been modified for IWNT use instead.
 */
public ActionForward addFavoriteAccount(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    IWantDocumentForm iwntForm = (IWantDocumentForm) form;
    IWantDocument document = iwntForm.getIWantDocument();
    if (addNewFavoriteAccount(document)) {
        document.setFavoriteAccountLineIdentifier(null);
    }
    return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
Also used : IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Example 25 with IWantDocument

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

the class IWantDocumentAction 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;
    if (request.getParameter(KRADConstants.PARAMETER_DOC_ID) == null) {
        forward = super.copy(mapping, form, request, response);
    } else {
        // this is copy document from Procurement Gateway:
        // use this link to call: http://localhost:8080/kfs-dev/purapIWant.do?methodToCall=copy&docId=xxxx
        String docId = request.getParameter(KRADConstants.PARAMETER_DOC_ID);
        KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
        IWantDocument document = null;
        document = (IWantDocument) getDocumentService().getByDocumentHeaderId(docId);
        document.toCopyFromGateway();
        kualiDocumentFormBase.setDocument(document);
        WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
        kualiDocumentFormBase.setDocTypeName(workflowDocument.getDocumentTypeName());
        UserSessionUtils.addWorkflowDocument(GlobalVariables.getUserSession(), workflowDocument);
        forward = mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
    return forward;
}
Also used : WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) ActionForward(org.apache.struts.action.ActionForward) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Aggregations

IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)27 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)18 IWantDocumentService (edu.cornell.kfs.module.purap.document.service.IWantDocumentService)8 ActionForward (org.apache.struts.action.ActionForward)7 IWantAccount (edu.cornell.kfs.module.purap.businessobject.IWantAccount)4 IWantItem (edu.cornell.kfs.module.purap.businessobject.IWantItem)4 HashMap (java.util.HashMap)3 RouteDocumentEvent (org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent)3 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)3 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)3 Person (org.kuali.rice.kim.api.identity.Person)3 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)2 LevelOrganization (edu.cornell.kfs.module.purap.businessobject.LevelOrganization)2 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)2 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)2 PurapService (org.kuali.kfs.module.purap.document.service.PurapService)2 RequisitionForm (org.kuali.kfs.module.purap.document.web.struts.RequisitionForm)2 FinancialSystemWorkflowHelperService (org.kuali.kfs.sys.service.FinancialSystemWorkflowHelperService)2 VendorPhoneNumber (org.kuali.kfs.vnd.businessobject.VendorPhoneNumber)2 ConcreteKeyValue (org.kuali.rice.core.api.util.ConcreteKeyValue)2