Search in sources :

Example 16 with IWantDocument

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

the class IWantDocumentAction method continueToVendor.

/**
 * Takes the user to next page
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward continueToVendor(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    IWantDocumentForm iWantForm = (IWantDocumentForm) form;
    IWantDocument iWantDocument = iWantForm.getIWantDocument();
    boolean added = true;
    // add new item and new accounting line if not empty
    IWantItem item = iWantForm.getNewIWantItemLine();
    if (StringUtils.isNotBlank(item.getItemDescription()) || item.getItemUnitPrice() != null || item.getItemQuantity() != null) {
        added &= addNewItem(iWantForm, iWantDocument, item);
    }
    added &= addNewFavoriteAccountIfNecessary(added, iWantDocument);
    if (added) {
        IWantAccount account = iWantForm.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(iWantForm, iWantDocument, account);
        }
    }
    // If addition of IWNT item or account failed, then skip the rest of the validation.
    if (!added) {
        return mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
    KualiRuleService ruleService = SpringContext.getBean(KualiRuleService.class);
    boolean rulePassed = true;
    // call business rules
    rulePassed &= ruleService.applyRules(new RouteDocumentEvent("", iWantDocument));
    if (rulePassed) {
        iWantForm.setStep(CUPurapConstants.IWantDocumentSteps.VENDOR_STEP);
        iWantDocument.setStep(CUPurapConstants.IWantDocumentSteps.VENDOR_STEP);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) IWantAccount(edu.cornell.kfs.module.purap.businessobject.IWantAccount) RouteDocumentEvent(org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent) IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Example 17 with IWantDocument

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

the class IWantDocumentAction method deleteItem.

/**
 * Deletes the selected item
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward deleteItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    IWantDocumentForm iWantForm = (IWantDocumentForm) form;
    IWantDocument iWantDocument = (IWantDocument) iWantForm.getDocument();
    iWantDocument.deleteItem(getSelectedLine(request));
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Example 18 with IWantDocument

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

the class IWantDocumentAction method loadDocument.

/**
 * @see org.kuali.kfs.kns.web.struts.action.KualiDocumentActionBase#loadDocument(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)
 */
@Override
protected void loadDocument(KualiDocumentFormBase kualiDocumentFormBase) throws WorkflowException {
    super.loadDocument(kualiDocumentFormBase);
    IWantDocumentForm iWantForm = (IWantDocumentForm) kualiDocumentFormBase;
    IWantDocument iWantDocument = iWantForm.getIWantDocument();
    if (iWantDocument.getDocumentHeader().getWorkflowDocument().isSaved()) {
        iWantForm.setStep(CUPurapConstants.IWantDocumentSteps.CUSTOMER_DATA_STEP);
        iWantDocument.setStep(CUPurapConstants.IWantDocumentSteps.CUSTOMER_DATA_STEP);
        if (StringUtils.isNotBlank(iWantDocument.getCurrentRouteToNetId())) {
            iWantForm.getNewAdHocRoutePerson().setId(iWantDocument.getCurrentRouteToNetId());
        }
    } else if (!iWantDocument.getDocumentHeader().getWorkflowDocument().isInitiated()) {
        iWantForm.setStep(CUPurapConstants.IWantDocumentSteps.REGULAR);
        iWantDocument.setStep(CUPurapConstants.IWantDocumentSteps.REGULAR);
    }
}
Also used : IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Example 19 with IWantDocument

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

the class IWantDocumentAction method execute.

/**
 * @see org.kuali.kfs.kns.web.struts.action.KualiAction#execute(org.apache.struts.action.ActionMapping,
 * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
 * javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    ActionForward actionForward = super.execute(mapping, form, request, response);
    IWantDocumentForm documentForm = (IWantDocumentForm) form;
    IWantDocument iWantDoc = documentForm.getIWantDocument();
    if (documentForm != null && documentForm.getDocument() != null) {
        iWantDoc.setExplanation(iWantDoc.getDocumentHeader().getExplanation());
        // populate department drop down
        if (!documentForm.getPreviousSelectedOrg().equalsIgnoreCase(((IWantDocument) documentForm.getDocument()).getCollegeLevelOrganization())) {
            String cLevelOrg = ((IWantDocument) documentForm.getDocument()).getCollegeLevelOrganization();
            documentForm.getDeptOrgKeyLabels().clear();
            documentForm.getDeptOrgKeyLabels().add(new ConcreteKeyValue("", "Please Select"));
            if (StringUtils.isNotEmpty(cLevelOrg)) {
                IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
                List<LevelOrganization> dLevelOrgs = iWantDocumentService.getDLevelOrganizations(cLevelOrg);
                // Get the list of chart+org combos to forcibly exclude from the drop-down, if any.
                String routingChart = ((IWantDocument) documentForm.getDocument()).getRoutingChart();
                Collection<String> dLevelExcludesList = getParameterService().getParameterValuesAsString(PurapConstants.PURAP_NAMESPACE, KRADConstants.DetailTypes.DOCUMENT_DETAIL_TYPE, IWANT_DEPT_ORGS_TO_EXCLUDE_PARM);
                Set<String> dLevelExcludes = new HashSet<String>((dLevelExcludesList != null) ? dLevelExcludesList : Collections.<String>emptyList());
                for (LevelOrganization levelOrganization : dLevelOrgs) {
                    // Add each department-level org to the drop-down as long as it is not marked for exclusion.
                    if (!dLevelExcludes.contains(routingChart + "=" + levelOrganization.getCode())) {
                        documentForm.getDeptOrgKeyLabels().add(new ConcreteKeyValue(levelOrganization.getCode(), levelOrganization.getCodeAndDescription()));
                    }
                }
            }
        }
        setupDocumentMessages(documentForm.getStep());
    }
    return actionForward;
}
Also used : ConcreteKeyValue(org.kuali.rice.core.api.util.ConcreteKeyValue) LevelOrganization(edu.cornell.kfs.module.purap.businessobject.LevelOrganization) ActionForward(org.apache.struts.action.ActionForward) 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) HashSet(java.util.HashSet)

Example 20 with IWantDocument

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

the class IWantDocumentAction method addAccountingLine.

/**
 * Adds an accounting line
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward addAccountingLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    IWantDocumentForm iWantDocumentForm = (IWantDocumentForm) form;
    IWantDocument iWantDoc = (IWantDocument) iWantDocumentForm.getDocument();
    IWantAccount account = iWantDocumentForm.getNewSourceLine();
    addNewAccount(iWantDocumentForm, iWantDoc, account);
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : IWantAccount(edu.cornell.kfs.module.purap.businessobject.IWantAccount) 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