Search in sources :

Example 1 with ParameterEvaluatorService

use of org.kuali.kfs.core.api.parameter.ParameterEvaluatorService in project cu-kfs by CU-CommunityApps.

the class KualiAccountingDocumentActionBase method isSalesTaxRequired.

/**
 * This method checks to see if this doctype needs sales tax If it does then it checks to see if the account and
 * object code require sales tax If it does then it returns true. Note - this is hackish as we shouldn't have to
 * call rules directly from the action class But we need to in this instance because we are copying the lines
 * before calling rules and need a way to modify them before they go on
 *
 * @param accountingLine
 * @return true if sales tax check is needed, false otherwise
 */
protected boolean isSalesTaxRequired(AccountingDocument financialDocument, AccountingLine accountingLine) {
    boolean required = false;
    String docType = SpringContext.getBean(DataDictionaryService.class).getDocumentTypeNameByClass(financialDocument.getClass());
    // first we need to check just the doctype to see if it needs the sales tax check
    // apply the rule, see if it fails
    ParameterEvaluatorService parameterEvaluatorService = SpringContext.getBean(ParameterEvaluatorService.class);
    ParameterEvaluator docTypeSalesTaxCheckEvaluator = parameterEvaluatorService.getParameterEvaluator(KfsParameterConstants.FINANCIAL_PROCESSING_DOCUMENT.class, FPParameterConstants.SALES_TAX_DOCUMENT_TYPES, docType);
    if (docTypeSalesTaxCheckEvaluator.evaluationSucceeds()) {
        required = true;
    }
    // second we need to check the account and object code combination to see if it needs sales tax
    if (required) {
        // get the object code and account
        String objCd = accountingLine.getFinancialObjectCode();
        String account = accountingLine.getAccountNumber();
        if (StringUtils.isNotEmpty(objCd) && StringUtils.isNotEmpty(account)) {
            String compare = account + ":" + objCd;
            ParameterEvaluator salesTaxApplicableAcctAndObjectEvaluator = parameterEvaluatorService.getParameterEvaluator(KfsParameterConstants.FINANCIAL_PROCESSING_DOCUMENT.class, FPParameterConstants.SALES_TAX_APPLICABLE_ACCOUNTS_AND_OBJECT_CODES, compare);
            if (!salesTaxApplicableAcctAndObjectEvaluator.evaluationSucceeds()) {
                required = false;
            }
        } else {
            // the two fields are currently empty and we don't need to check yet
            required = false;
        }
    }
    return required;
}
Also used : KfsParameterConstants(org.kuali.kfs.sys.service.impl.KfsParameterConstants) ParameterEvaluatorService(org.kuali.kfs.core.api.parameter.ParameterEvaluatorService) ParameterEvaluator(org.kuali.kfs.core.api.parameter.ParameterEvaluator) DataDictionaryService(org.kuali.kfs.datadictionary.legacy.DataDictionaryService)

Example 2 with ParameterEvaluatorService

use of org.kuali.kfs.core.api.parameter.ParameterEvaluatorService in project cu-kfs by CU-CommunityApps.

the class CuPurapServiceImplTest method setUp.

@Before
public void setUp() throws Exception {
    ParameterService parameterService = buildMockParameterService();
    ParameterEvaluatorService parameterEvaluatorService = buildParameterEvaluatorService(parameterService);
    purapService = new CuPurapServiceImpl();
    purapService.setParameterService(parameterService);
    purapService.setParameterEvaluatorService(parameterEvaluatorService);
    purapService.setVendorService(buildMockVendorService());
    purapService.setPersistenceService(buildMockPersistenceService());
    purapService.setBusinessObjectService(buildMockBusinessObjectService());
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) ParameterEvaluatorService(org.kuali.kfs.core.api.parameter.ParameterEvaluatorService) Before(org.junit.Before)

Aggregations

ParameterEvaluatorService (org.kuali.kfs.core.api.parameter.ParameterEvaluatorService)2 Before (org.junit.Before)1 ParameterEvaluator (org.kuali.kfs.core.api.parameter.ParameterEvaluator)1 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)1 DataDictionaryService (org.kuali.kfs.datadictionary.legacy.DataDictionaryService)1 KfsParameterConstants (org.kuali.kfs.sys.service.impl.KfsParameterConstants)1