Search in sources :

Example 1 with RouteDocumentEvent

use of org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent in project cu-kfs by CU-CommunityApps.

the class PurchasingDocumentBase method prepareForSave.

/**
 * Overrides the method in PurchasingAccountsPayableDocumentBase to remove the
 * purchasingCapitalAssetSystem when the system type is either ONE or MULT.
 */
@Override
public void prepareForSave(KualiDocumentEvent event) {
    super.prepareForSave(event);
    if (StringUtils.isNotBlank(this.getCapitalAssetSystemTypeCode())) {
        if (this.getCapitalAssetSystemTypeCode().equals(PurapConstants.CapitalAssetSystemTypes.ONE_SYSTEM) || this.getCapitalAssetSystemTypeCode().equals(PurapConstants.CapitalAssetSystemTypes.MULTIPLE)) {
            // If the system state is ONE or MULT, we have to remove all the systems on the items because it's not applicable.
            for (PurchasingCapitalAssetItem camsItem : this.getPurchasingCapitalAssetItems()) {
                camsItem.setPurchasingCapitalAssetSystem(null);
            }
        }
    }
    if (event instanceof RouteDocumentEvent || event instanceof ApproveDocumentEvent) {
        boolean defaultUseTaxIndicatorValue = SpringContext.getBean(PurchasingService.class).getDefaultUseTaxIndicatorValue(this);
        SpringContext.getBean(PurapService.class).updateUseTaxIndicator(this, defaultUseTaxIndicatorValue);
    }
    // KFSUPGRADE-583
    checkForFederalAccount();
}
Also used : ApproveDocumentEvent(org.kuali.kfs.krad.rules.rule.event.ApproveDocumentEvent) PurapService(org.kuali.kfs.module.purap.document.service.PurapService) PurchasingCapitalAssetItem(org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem) RouteDocumentEvent(org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent) PurchasingService(org.kuali.kfs.module.purap.document.service.PurchasingService)

Example 2 with RouteDocumentEvent

use of org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent in project cu-kfs by CU-CommunityApps.

the class PaymentWorksDataProcessingIntoKfsServiceImpl method kfsVendorMaintenanceDocumentValidated.

private boolean kfsVendorMaintenanceDocumentValidated(MaintenanceDocument vendorMaintenceDoc, PaymentWorksNewVendorRequestsBatchReportData reportData, PaymentWorksVendor pmwVendor) {
    boolean documentValidated = false;
    try {
        vendorMaintenceDoc.validateBusinessRules(new RouteDocumentEvent(vendorMaintenceDoc));
        LOG.info("kfsVendorMaintenanceDocumentValidated: vendorMaintenceDoc validate.");
        documentValidated = true;
    } catch (ValidationException ve) {
        List<String> validationErrors = convertReportDataValidationErrors(GlobalVariables.getMessageMap().getErrorMessages());
        captureKfsProcessingErrorsForVendor(pmwVendor, reportData, validationErrors);
        LOG.error("kfsVendorMaintenanceDocumentValidated: eDoc validation error(s): " + validationErrors.toString());
        LOG.error("kfsVendorMaintenanceDocumentValidated: eDoc validation exception caught: " + ve.getMessage());
    } finally {
        GlobalVariables.getMessageMap().clearErrorMessages();
    }
    return documentValidated;
}
Also used : ValidationException(org.kuali.kfs.krad.exception.ValidationException) RouteDocumentEvent(org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent) ArrayList(java.util.ArrayList) AutoPopulatingList(org.springframework.util.AutoPopulatingList) List(java.util.List)

Example 3 with RouteDocumentEvent

use of org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent 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);
}
Also used : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) RouteDocumentEvent(org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Example 4 with RouteDocumentEvent

use of org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent 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);
}
Also used : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) IWantAccount(edu.cornell.kfs.module.purap.businessobject.IWantAccount) RouteDocumentEvent(org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent) IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Example 5 with RouteDocumentEvent

use of org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent in project cu-kfs by CU-CommunityApps.

the class IWantDocumentAction method continueToItems.

/**
 * Takes the user to next page
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward continueToItems(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    IWantDocumentForm iWantForm = (IWantDocumentForm) form;
    IWantDocument iWantDocument = iWantForm.getIWantDocument();
    iWantDocument.setExplanation(iWantDocument.getDocumentHeader().getExplanation());
    KualiRuleService ruleService = SpringContext.getBean(KualiRuleService.class);
    boolean rulePassed = true;
    // call business rules
    rulePassed &= ruleService.applyRules(new RouteDocumentEvent(KFSConstants.DOCUMENT_HEADER_ERRORS, iWantDocument));
    if (rulePassed) {
        iWantForm.setStep(CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP);
        iWantDocument.setStep(CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) RouteDocumentEvent(org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Aggregations

RouteDocumentEvent (org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent)5 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)3 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)3 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)3 IWantAccount (edu.cornell.kfs.module.purap.businessobject.IWantAccount)1 IWantItem (edu.cornell.kfs.module.purap.businessobject.IWantItem)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ValidationException (org.kuali.kfs.krad.exception.ValidationException)1 ApproveDocumentEvent (org.kuali.kfs.krad.rules.rule.event.ApproveDocumentEvent)1 PurchasingCapitalAssetItem (org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem)1 PurapService (org.kuali.kfs.module.purap.document.service.PurapService)1 PurchasingService (org.kuali.kfs.module.purap.document.service.PurchasingService)1 AutoPopulatingList (org.springframework.util.AutoPopulatingList)1