use of org.kuali.kfs.kns.rule.event.KualiAddLineEvent 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;
}
use of org.kuali.kfs.kns.rule.event.KualiAddLineEvent in project cu-kfs by CU-CommunityApps.
the class IWantDocumentAction method addNewAccount.
private boolean addNewAccount(IWantDocumentForm iWantDocumentForm, IWantDocument iWantDoc, IWantAccount account) {
KualiRuleService ruleService = SpringContext.getBean(KualiRuleService.class);
boolean acctRulesPassed = true;
acctRulesPassed &= ruleService.applyRules(new KualiAddLineEvent(iWantDoc, "accounts", account));
if (acctRulesPassed) {
account = iWantDocumentForm.getAndResetNewIWantAccountLine();
iWantDoc.addAccount(account);
}
return acctRulesPassed;
}
Aggregations