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);
}
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;
}
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;
}
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));
}
}
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;
}
Aggregations