Search in sources :

Example 6 with IWantItem

use of edu.cornell.kfs.module.purap.businessobject.IWantItem in project cu-kfs by CU-CommunityApps.

the class IWantDocumentServiceImpl method setUpItemsTabForReqDoc.

/**
 * Set up items on the Requisition document based on the information on the I Want
 * document.
 *
 * @param requisitionDocument
 * @param iWantDocument
 */
private void setUpItemsTabForReqDoc(RequisitionDocument requisitionDocument, IWantDocument iWantDocument) {
    @SuppressWarnings("unchecked") List<IWantItem> iWantItems = iWantDocument.getItems();
    if (iWantDocument.getItems() != null && iWantItems.size() > 0) {
        for (IWantItem iWantItem : iWantItems) {
            RequisitionItem requisitionItem = new RequisitionItem();
            requisitionItem.setItemQuantity(iWantItem.getItemQuantity());
            requisitionItem.setItemDescription(iWantItem.getItemDescription());
            requisitionItem.setItemUnitOfMeasureCode(iWantItem.getItemUnitOfMeasureCode());
            requisitionItem.setItemCatalogNumber(iWantItem.getItemCatalogNumber());
            requisitionItem.setItemUnitPrice(iWantItem.getItemUnitPrice());
            requisitionDocument.addItem(requisitionItem);
        }
    }
}
Also used : RequisitionItem(org.kuali.kfs.module.purap.businessobject.RequisitionItem) IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem)

Example 7 with IWantItem

use of edu.cornell.kfs.module.purap.businessobject.IWantItem in project cu-kfs by CU-CommunityApps.

the class IWantDocumentFeedServiceImpl method populateIWantDocItems.

/**
 * Populates I Want doc items.
 *
 * @param batchIWantDocument
 * @param iWantDocument
 * @return true if no errors encountered, false otherwise
 */
protected boolean populateIWantDocItems(BatchIWantDocument batchIWantDocument, IWantDocument iWantDocument) {
    LOG.info("Populate I Want doc items");
    boolean noErrors = true;
    // items
    List<IWantItem> iWantItems = batchIWantDocument.getItems();
    if (CollectionUtils.isNotEmpty(iWantItems)) {
        for (IWantItem item : iWantItems) {
            IWantItem addItem = new IWantItem();
            addItem.setItemDescription(item.getItemDescription());
            addItem.setItemTypeCode(item.getItemUnitOfMeasureCode());
            addItem.setItemCatalogNumber(item.getItemCatalogNumber());
            addItem.setItemUnitPrice(item.getItemUnitPrice());
            addItem.setPurchasingCommodityCode(item.getPurchasingCommodityCode());
            addItem.setItemQuantity(item.getItemQuantity());
            boolean rulePassed = ruleService.applyRules(new AddIWantItemEvent(StringUtils.EMPTY, iWantDocument, addItem));
            if (rulePassed) {
                iWantDocument.addItem(addItem);
            } else {
                logErrorMessages();
            }
            noErrors &= rulePassed;
        }
    }
    return noErrors;
}
Also used : AddIWantItemEvent(edu.cornell.kfs.module.purap.document.validation.event.AddIWantItemEvent) IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem)

Example 8 with IWantItem

use of edu.cornell.kfs.module.purap.businessobject.IWantItem 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 9 with IWantItem

use of edu.cornell.kfs.module.purap.businessobject.IWantItem 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 10 with IWantItem

use of edu.cornell.kfs.module.purap.businessobject.IWantItem in project cu-kfs by CU-CommunityApps.

the class IWantDocumentAction method addItem.

/**
 * Adds an item to the document
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward addItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    IWantDocumentForm iWantDocumentForm = (IWantDocumentForm) form;
    IWantDocument iWantDocument = (IWantDocument) iWantDocumentForm.getDocument();
    IWantItem item = iWantDocumentForm.getNewIWantItemLine();
    addNewItem(iWantDocumentForm, iWantDocument, item);
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Aggregations

IWantItem (edu.cornell.kfs.module.purap.businessobject.IWantItem)11 IWantAccount (edu.cornell.kfs.module.purap.businessobject.IWantAccount)4 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)4 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)4 IWantDocumentService (edu.cornell.kfs.module.purap.document.service.IWantDocumentService)2 ActionForward (org.apache.struts.action.ActionForward)2 AddIWantItemEvent (edu.cornell.kfs.module.purap.document.validation.event.AddIWantItemEvent)1 ArrayList (java.util.ArrayList)1 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)1 RouteDocumentEvent (org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent)1 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)1 RequisitionItem (org.kuali.kfs.module.purap.businessobject.RequisitionItem)1 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)1 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)1