Search in sources :

Example 1 with IWantItem

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

the class IWantDocument method addItem.

@Override
public void addItem(PurApItem purapItem) {
    IWantItem item = (IWantItem) purapItem;
    item.refreshReferenceObject(PurapPropertyConstants.COMMODITY_CODE);
    int itemLinePosition = getItemLinePosition();
    if (ObjectUtils.isNotNull(item.getItemLineNumber()) && (item.getItemLineNumber() > 0) && (item.getItemLineNumber() <= itemLinePosition)) {
        itemLinePosition = item.getItemLineNumber().intValue() - 1;
    }
    item.setiWantDocumentNumber(this.getDocumentNumber());
    item.setiWantDocument(this);
    items.add(itemLinePosition, item);
    renumberItems(itemLinePosition);
}
Also used : IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem)

Example 2 with IWantItem

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

the class IWantDocument method getTotalDollarAmount.

/**
 * Calculates the total dollar amount
 *
 * @return
 */
@Override
public KualiDecimal getTotalDollarAmount() {
    KualiDecimal totalDollarAmount = KualiDecimal.ZERO;
    KualiDecimal itemTotal = KualiDecimal.ZERO;
    for (IWantItem item : items) {
        if (ObjectUtils.isNull(item.getItemQuantity())) {
            item.setItemQuantity(new KualiDecimal(1));
        }
        if (ObjectUtils.isNull(item.getItemUnitPrice())) {
            item.setItemUnitPrice(BigDecimal.ZERO);
        }
        itemTotal = new KualiDecimal(item.getItemQuantity().bigDecimalValue().multiply(item.getItemUnitPrice()));
        totalDollarAmount = totalDollarAmount.add(itemTotal);
    }
    return totalDollarAmount;
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem)

Example 3 with IWantItem

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

the class IWantDocument method copyItemsAndAccounts.

/**
 * Create copies of the items and accounts lists upon document copy.
 */
private void copyItemsAndAccounts() {
    List<IWantItem> newItems = new ArrayList<IWantItem>();
    List<IWantAccount> newAccounts = new ArrayList<IWantAccount>();
    if (items != null && !items.isEmpty()) {
        for (IWantItem item : items) {
            newItems.add(IWantItem.createCopy(item));
        }
    }
    if (accounts != null && !accounts.isEmpty()) {
        for (IWantAccount account : accounts) {
            newAccounts.add(IWantAccount.createCopy(account));
        }
    }
    this.items = newItems;
    this.accounts = newAccounts;
}
Also used : IWantAccount(edu.cornell.kfs.module.purap.businessobject.IWantAccount) ArrayList(java.util.ArrayList) IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem)

Example 4 with IWantItem

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

the class IWantDocument method renumberItems.

@Override
public void renumberItems(int start) {
    for (int i = start; i < items.size(); i++) {
        IWantItem item = (IWantItem) items.get(i);
        item.setItemLineNumber(new Integer(i + 1));
    }
}
Also used : IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem)

Example 5 with IWantItem

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

the class IWantDocumentAction method route.

/**
 * @see org.kuali.kfs.kns.web.struts.action.KualiDocumentActionBase#route(org.apache.struts.action.ActionMapping,
 * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
 * javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward route(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    IWantDocumentForm iWantDocForm = (IWantDocumentForm) form;
    IWantDocument iWantDocument = iWantDocForm.getIWantDocument();
    IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
    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 route if there were failures adding new items or accounts.
    if (!added) {
        return mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
    iWantDocument.setExplanation(iWantDocument.getDocumentHeader().getExplanation());
    String step = iWantDocForm.getStep();
    String principalId = iWantDocument.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId();
    boolean setDefaultCollegeDept = iWantDocument.isUseCollegeAndDepartmentAsDefault();
    if (setDefaultCollegeDept) {
        // set these values in user Options table
        String college = iWantDocument.getCollegeLevelOrganization();
        String department = iWantDocument.getDepartmentLevelOrganization();
        saveUserOption(principalId, CUPurapConstants.USER_OPTIONS_DEFAULT_COLLEGE, college);
        saveUserOption(principalId, CUPurapConstants.USER_OPTIONS_DEFAULT_DEPARTMENT, department);
    }
    if (iWantDocument.isSetDeliverToInfoAsDefault()) {
        if (StringUtils.isNotBlank(iWantDocument.getDeliverToNetID())) {
            saveUserOption(principalId, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_NET_ID, iWantDocument.getDeliverToNetID());
        }
        if (StringUtils.isNotBlank(iWantDocument.getDeliverToName())) {
            saveUserOption(principalId, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_NAME, iWantDocument.getDeliverToName());
        }
        if (StringUtils.isNotBlank(iWantDocument.getDeliverToEmailAddress())) {
            saveUserOption(principalId, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_EMAIL_ADDRESS, iWantDocument.getDeliverToEmailAddress());
        }
        if (StringUtils.isNotBlank(iWantDocument.getDeliverToPhoneNumber())) {
            saveUserOption(principalId, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_PHONE_NUMBER, iWantDocument.getDeliverToPhoneNumber());
        }
        if (StringUtils.isNotBlank(iWantDocument.getDeliverToAddress())) {
            saveUserOption(principalId, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_ADDRESS, iWantDocument.getDeliverToAddress());
        }
    }
    iWantDocumentService.setIWantDocumentDescription(iWantDocument);
    // insert adhoc route person first and the route
    if (StringUtils.isNotBlank(iWantDocForm.getNewAdHocRoutePerson().getId())) {
        iWantDocument.setCurrentRouteToNetId(iWantDocForm.getNewAdHocRoutePerson().getId());
        insertAdHocRoutePerson(mapping, iWantDocForm, request, response);
    }
    ActionForward actionForward = super.route(mapping, form, request, response);
    if (CUPurapConstants.IWantDocumentSteps.ROUTING_STEP.equalsIgnoreCase(step)) {
        iWantDocForm.setStep(CUPurapConstants.IWantDocumentSteps.REGULAR);
        iWantDocument.setStep(CUPurapConstants.IWantDocumentSteps.REGULAR);
        return mapping.findForward("finish");
    }
    return actionForward;
}
Also used : IWantAccount(edu.cornell.kfs.module.purap.businessobject.IWantAccount) IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem) 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)

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