use of org.kuali.kfs.krad.service.KualiRuleService in project cu-kfs by CU-CommunityApps.
the class IWantDocumentAction method addNewItem.
private boolean addNewItem(IWantDocumentForm iWantDocumentForm, IWantDocument iWantDoc, IWantItem item) {
KualiRuleService ruleService = SpringContext.getBean(KualiRuleService.class);
boolean rulePassed = true;
// call business rules
rulePassed &= ruleService.applyRules(new AddIWantItemEvent(StringUtils.EMPTY, iWantDoc, item));
if (rulePassed) {
item = iWantDocumentForm.getAndResetNewIWantItemLine();
iWantDoc.addItem(item);
}
return rulePassed;
}
use of org.kuali.kfs.krad.service.KualiRuleService in project cu-kfs by CU-CommunityApps.
the class CuPurapAccountingServiceImpl method updateAccountAmounts.
/**
* @see org.kuali.kfs.module.purap.service.PurapAccountingService#updateAccountAmounts(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)
*/
@Override
public void updateAccountAmounts(PurchasingAccountsPayableDocument document) {
PurchasingAccountsPayableDocumentBase purApDocument = (PurchasingAccountsPayableDocumentBase) document;
String accountDistributionMethod = purApDocument.getAccountDistributionMethod();
KualiRuleService kualiRuleService = SpringContext.getBean(KualiRuleService.class);
WorkflowDocument workflowDocument = purApDocument.getDocumentHeader().getWorkflowDocument();
Set<String> nodeNames = workflowDocument.getCurrentNodeNames();
// don't update if past the AP review level
if ((document instanceof PaymentRequestDocument) && purapService.isFullDocumentEntryCompleted(document)) {
if (nodeNames.contains(PaymentRequestStatuses.NODE_PAYMENT_METHOD_REVIEW)) {
// CU needs this update because the customization allows Treasury Manager to change unit/extended price and 'calculate'
for (PurApItem item : document.getItems()) {
updatePreqItemAccountAmountsOnly(item);
}
} else {
convertMoneyToPercent((PaymentRequestDocument) document);
}
return;
}
document.fixItemReferences();
// if distribution method is sequential and document is PREQ or VCM then...
if (((document instanceof PaymentRequestDocument) || (document instanceof VendorCreditMemoDocument)) && PurapConstants.AccountDistributionMethodCodes.SEQUENTIAL_CODE.equalsIgnoreCase(accountDistributionMethod)) {
if (document instanceof VendorCreditMemoDocument) {
VendorCreditMemoDocument cmDocument = (VendorCreditMemoDocument) document;
cmDocument.updateExtendedPriceOnItems();
for (PurApItem item : document.getItems()) {
for (PurApAccountingLine account : item.getSourceAccountingLines()) {
account.setAmount(KualiDecimal.ZERO);
}
}
}
// update the accounts amounts for PREQ and distribution method = sequential
for (PurApItem item : document.getItems()) {
updatePreqItemAccountAmounts(item);
}
return;
}
// if distribution method is proportional and document is PREQ or VCM then...
if (((document instanceof PaymentRequestDocument) || (document instanceof VendorCreditMemoDocument)) && PurapConstants.AccountDistributionMethodCodes.PROPORTIONAL_CODE.equalsIgnoreCase(accountDistributionMethod)) {
// update the accounts amounts for PREQ and distribution method = sequential
if (document instanceof VendorCreditMemoDocument) {
VendorCreditMemoDocument cmDocument = (VendorCreditMemoDocument) document;
cmDocument.updateExtendedPriceOnItems();
for (PurApItem item : document.getItems()) {
for (PurApAccountingLine account : item.getSourceAccountingLines()) {
account.setAmount(KualiDecimal.ZERO);
}
}
}
for (PurApItem item : document.getItems()) {
boolean rulePassed = true;
// check any business rules
rulePassed &= kualiRuleService.applyRules(new PurchasingAccountsPayableItemPreCalculateEvent(document, item));
if (rulePassed) {
updatePreqProportionalItemAccountAmounts(item);
}
}
return;
}
// No recalculate if the account distribution method code is equal to "S" sequential ON REQ or POs..
if (PurapConstants.AccountDistributionMethodCodes.SEQUENTIAL_CODE.equalsIgnoreCase(accountDistributionMethod)) {
for (PurApItem item : document.getItems()) {
boolean rulePassed = true;
// check any business rules
rulePassed &= kualiRuleService.applyRules(new PurchasingAccountsPayableItemPreCalculateEvent(document, item));
return;
}
}
// do recalculate only if the account distribution method code is not equal to "S" sequential method.
if (!PurapConstants.AccountDistributionMethodCodes.SEQUENTIAL_CODE.equalsIgnoreCase(accountDistributionMethod)) {
for (PurApItem item : document.getItems()) {
boolean rulePassed = true;
// check any business rules
rulePassed &= kualiRuleService.applyRules(new PurchasingAccountsPayableItemPreCalculateEvent(document, item));
if (rulePassed) {
updateItemAccountAmounts(item);
}
}
}
}
use of org.kuali.kfs.krad.service.KualiRuleService in project cu-kfs by CU-CommunityApps.
the class IWantDocumentAction method continueToRouting.
/**
* Takes the user to next page
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward continueToRouting(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
IWantDocumentForm iWantForm = (IWantDocumentForm) form;
IWantDocument iWantDocument = iWantForm.getIWantDocument();
// call business rules
KualiRuleService ruleService = SpringContext.getBean(KualiRuleService.class);
boolean rulePassed = true;
rulePassed &= ruleService.applyRules(new RouteDocumentEvent("", iWantDocument));
if (rulePassed) {
iWantForm.setStep(CUPurapConstants.IWantDocumentSteps.ROUTING_STEP);
iWantDocument.setStep(CUPurapConstants.IWantDocumentSteps.ROUTING_STEP);
}
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
use of org.kuali.kfs.krad.service.KualiRuleService 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 org.kuali.kfs.krad.service.KualiRuleService 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