use of edu.cornell.kfs.module.purap.businessobject.IWantAccount 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);
}
use of edu.cornell.kfs.module.purap.businessobject.IWantAccount 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);
}
use of edu.cornell.kfs.module.purap.businessobject.IWantAccount 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;
}
Aggregations