Create Basic Rule

A campaign applies discounts on certain product categories with specific rates:

  • A fixed 15% discount on Electronics products.

  • A fixed 30% discount on products in the Toys category.

  • For Fashion products, discount rates vary based on price:

    • 15% discount for items priced between 0 and 500 TL

    • 20% discount for items priced between 501 and 1000 TL

    • 25% discount for items priced 1001 TL and above

  • For Outdoor products, discounts are as follows based on price ranges:

    • 10% discount for items priced between 1000 and 5000 TL

    • 20% discount for items priced between 5001 and 10000 TL

    • (Missing info) discount for items priced 10001 TL and above

Product Category
Price Range (TL)
Discount Rate (%)

Electronics

15% fixed

Toys

30% fixed

Fashion

0 – 500

15%

Fashion

501 – 1000

20%

Fashion

1001 and above

25%

Outdoor

1000 – 5000

10%

Outdoor

5001 – 10000

20%

Outdoor

10001 and above

25%

The inputs consist of product_type and total_amount,and the output is the rate variable.

If product_type and total_amount do not exist in the parameter pool, we define them.

You can find more detailed information about the Parameter Pool here.

Parameter Definition for "PRODUCT_TYPE"

Parameter Definition for "TOTAL_AMOUNT "

Rule Definition

Category, rule name, rule validity dates, rule parameters, and variables for rule output are defined.

Kural Tanımı

After saving, we proceed by clicking the "Decision Table" button that appears at the bottom.

Decision Table

On the decision table screen, we first set the system’s default value that will be used before any rules are defined. This value applies to cases that do not match any rule set.

Then, using the "Add Decision Table" button located at the bottom of the page, we begin defining our rule sets.

We create our first rule set to check based solely on the product type. For this:

  1. Select the parameter to be checked (e.g., Product Type)

  2. Specify the control type (e.g., Equals)

  3. Finally, click the Add button to include the rule in the table.

After the first rule set, we now define a second rule set that will check both the product type and the amount.

After defining your rule sets, click the "Save" button located at the bottom of the page.

After clicking the Save button:

  • Two new buttons appear to help you manage your rule sets:

  1. Sort Button

    • Used to determine the order in which your defined rule sets will be evaluated.

    • Priority order is important: the rule at the top runs first, and if its condition is met, subsequent rules are not processed.

  2. Data Entry Button

    • The Data button allows you to enter data for each rule set.

The Data button allows data entry for each rule set.

Decision Table Data

On the page opened via the Data button in the decision table list, you can create the desired number of rows using the "+" or "Copy" buttons. After filling in the rule data, click the Save button to save the entries.

We perform data entry for our second rule set as well.

Bulk upload can be done via Excel. You can find more details here.

Test the Rule

We can test the rule we created. The test screen opens by clicking the Test button located either in the header section or at the bottom of the rule page.

You can find more detailed information about the test screen here.

When we test with a product code not defined in our rule, we expect the default rate value of 0 to be returned.

When we test the rule sequentially for the products "toy" and "fashion," we see that the defined rates are returned, confirming that our rule works successfully.

Publishing the Rule

We can now publish our rule and execute it via the API.

You can find more detailed information about rule publishing here.

By clicking the "Submit for Approval" button on the rule main page, you can initiate the approval process for the rule you have created or updated.

This action ensures that the rule is forwarded to the relevant departments for review and approval.

  • Users with approval authority can publish the rule by clicking the "Publish" button.

  • A published rule becomes executable through the system’s API and starts being used in real operational processes.

Kural Başlık Bilgileri

Executing the Rule via API

  • To execute the rule, the API receives the rule’s unique code, "K1", and a date parameter to specify the version to be run.

  • The date must be in the dd.mm.yyyy format.

  • If the date parameter is not provided, the system automatically uses the current date.

// api url
/public/ruleExecuterApi/executeWithPath?path=K1&baseDate=21.03.2023
//Request
{
    "context":[
        {"code":"PRODUCT_TYPE",
         "value":"toys"   
        },
         {"code":"TOTAL_AMOUNT",
         "value":"100"   
        }
    ]
}
// Responce
{
    "localProcessCode": "20230321130825560-766176@ubuntu-31",
    "results": [
        {
            "code": "RATE",
            "name": "RATE",
            "multiple": false,
            "value": "0.3",
            "values": null
        }
    ]
}
```
  • Using the localProcessCode value returned from the API call,

  • In the log search screen, you can access the related transaction records by entering this code into the Transaction Code field.

Last updated