use of edu.cornell.kfs.module.purap.businessobject.IWantAccount 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.IWantAccount 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;
}
use of edu.cornell.kfs.module.purap.businessobject.IWantAccount in project cu-kfs by CU-CommunityApps.
the class IWantDocumentForm method getAndResetNewIWantAccountLine.
/**
* This method ...
*
* @return
*/
public IWantAccount getAndResetNewIWantAccountLine() {
IWantAccount aIWantAccount = (IWantAccount) getNewSourceLine();
newSourceLine = new IWantAccount();
return aIWantAccount;
}
use of edu.cornell.kfs.module.purap.businessobject.IWantAccount in project cu-kfs by CU-CommunityApps.
the class CuUserFavoriteAccountServiceImplTest method validateAccount.
private void validateAccount(String accountType, Class accountClass) {
final FavoriteAccount favoriteAccount = FavoriteAccountFixture.FAVORITE_ACCOUNT_1.createFavoriteAccount();
final GeneralLedgerPendingEntrySourceDetail acct = userFavoriteAccountService.getPopulatedNewAccount(favoriteAccount, accountClass);
Assert.assertNotNull("Account should be populated", acct);
Assert.assertTrue("Account should be " + accountType + " Account", accountClass.isInstance(acct));
Assert.assertEquals("Account Number should be populated", favoriteAccount.getAccountNumber(), acct.getAccountNumber());
Assert.assertEquals("Object Code should be populated", favoriteAccount.getFinancialObjectCode(), acct.getFinancialObjectCode());
if (acct instanceof IWantAccount) {
final KualiDecimal accountLinePercent = ((IWantAccount) acct).getAmountOrPercent();
Assert.assertEquals("Incorrect percentage (comparison against 100% should have been zero)", 0, accountLinePercent.compareTo(new KualiDecimal(100)));
Assert.assertEquals("Amount-or-Percent indicator should be Percent", CUPurapConstants.PERCENT, ((IWantAccount) acct).getUseAmountOrPercent());
} else {
final BigDecimal accountLinePercent = ((PurApAccountingLineBase) acct).getAccountLinePercent();
Assert.assertEquals("Incorrect percentage (comparison against 100% should have been zero)", 0, accountLinePercent.compareTo(new BigDecimal(100)));
}
}
use of edu.cornell.kfs.module.purap.businessobject.IWantAccount in project cu-kfs by CU-CommunityApps.
the class IWantDocumentFeedServiceImpl method populateIWantDocAccounts.
/**
* Populates the I Want document accounts
*
* @param batchIWantDocument
* @param iWantDocument
* @return true if no errors encountered, false otherwise
*/
protected boolean populateIWantDocAccounts(BatchIWantDocument batchIWantDocument, IWantDocument iWantDocument) {
LOG.info("Populate I Want doc accounts");
boolean noErrors = true;
// accounts
List<IWantAccount> iWantAccounts = batchIWantDocument.getAccounts();
if (CollectionUtils.isNotEmpty(iWantAccounts)) {
for (IWantAccount account : iWantAccounts) {
IWantAccount addAccount = new IWantAccount();
addAccount.setAccountNumber(account.getAccountNumber());
addAccount.setSubAccountNumber(account.getSubAccountNumber());
addAccount.setChartOfAccountsCode(account.getChartOfAccountsCode());
addAccount.setFinancialObjectCode(account.getFinancialObjectCode());
addAccount.setFinancialSubObjectCode(account.getFinancialSubObjectCode());
addAccount.setOrganizationReferenceId(account.getOrganizationReferenceId());
addAccount.setProjectCode(account.getProjectCode());
addAccount.setAmountOrPercent(account.getAmountOrPercent());
if ("P".equalsIgnoreCase(account.getUseAmountOrPercent())) {
addAccount.setUseAmountOrPercent(CUPurapConstants.PERCENT);
}
if ("A".equalsIgnoreCase(account.getUseAmountOrPercent())) {
addAccount.setUseAmountOrPercent(CUPurapConstants.AMOUNT);
}
boolean rulePassed = ruleService.applyRules(new KualiAddLineEvent(iWantDocument, "accounts", addAccount));
if (rulePassed) {
iWantDocument.addAccount(addAccount);
} else {
logErrorMessages();
}
noErrors &= rulePassed;
}
}
return noErrors;
}
Aggregations