The following is an example of a rate card with a base_price of 49, and a total of two rate_card_plans, three rate_card_groups, and five rate_card_items.
{ "name": "e2e Test RateCard Example", "client_id": "test-client", "description": "A test RateCard created for e2e tests", "status": "valid", "currency_code": "USD", "applicable_for": [ { "is_metadata": false, "id": "test-value-id", "label": "test-value-label", "values": [ { "id": "test-value-1", "label": "value 1" }, { "id": "test-value-1", "label": "value 1" } ], "sequence": 0 } ], "variables": [ { "id": "base_price", "value": 49, "data_type": "number" } ], "rate_card_plans": [ { "id": "a821e0d8-3572-404f-9026-0321ffae938d", "name": "e2e Test RateCard Plan #0", "sequence": 0, "description": "A test RateCard Plan created for e2e tests", "variables": [ { "id": "disk_size", "value": 0, "data_type": "number" } ], "rate_card_groups": [ { "id": "8c174830-8e54-4d7d-95c5-e2b4bdcafc94", "name": "e2e Test RateCard Group #0", "sequence": 0, "description": "A test RateCard Group created for e2e tests", "variables": [ { "id": "increment", "value": 2, "data_type": "number" } ], "rate_card_items": [ { "id": "9603e3c3-6f61-4f6c-923f-0912cce39c0c", "name": "40<disk_size<=100", "sequence": 0, "description": "A test RateCard Item created for e2e tests", "frequency": { "code": "MONTH", "value": 1 }, "expression": { "when": { "and": [ { ">": [ { "var": "disk_size" }, 40 ] }, { "<=": [ { "var": "disk_size" }, 100 ] } ] }, "then": [ { "uom": { "code": "GB", "value": 1 }, "name": "basePrice", "json_formula": { "var": "base_price" } }, { "uom": { "code": "", "value": 1 }, "name": "increment", "raw_formula": "max(min(60, disk_size - 40), 0) * increment" } ] } }, { "id": "32182194-1ae9-4999-bfa1-0344d1d5ba76", "name": "0<disk_size<=40", "sequence": 1, "description": "A test RateCard Item created for e2e tests", "frequency": { "code": "MONTH", "value": 1 }, "expression": { "when": { "and": [ { ">": [ { "var": "disk_size" }, 0 ] }, { "<=": [ { "var": "disk_size" }, 40 ] } ] }, "then": [ { "uom": { "code": "GB", "value": 1 }, "name": "basePrice", "json_formula": { "var": "base_price" } } ] } } ] } ] }, { "id": "e0013dd0-c907-4242-bb86-9978b3f2195c", "name": "e2e Test RateCard Plan #1", "sequence": 1, "description": "A test RateCard Plan created for e2e tests", "variables": [ { "id": "ram_size", "value": 0, "data_type": "number" } ], "rate_card_groups": [ { "id": "0134d951-a407-4b15-acbc-3b422def54bd", "name": "Silver", "sequence": 0, "description": "A test RateCard Group created for e2e tests", "variables": [], "rate_card_items": [ { "id": "b35c9a53-b0c5-424b-969d-000a31756948", "name": "0<ram_size<=4", "sequence": 0, "description": "A test RateCard Item created for e2e tests", "frequency": { "code": "MONTH", "value": 1 }, "expression": { "when": { "and": [ { ">": [ { "var": "ram_size" }, 0 ] }, { "<=": [ { "var": "ram_size" }, 4 ] } ] }, "then": [ { "uom": { "code": "GB", "value": 1 }, "name": "basePrice", "json_formula": { "var": "base_price" } } ] } } ] }, { "id": "affb89f9-06a0-4e31-9faa-86d07b23c890", "name": "Gold", "sequence": 1, "description": "A test RateCard Group created for e2e tests", "variables": [ { "id": "base_price", "value": 79, "data_type": "number" }, { "id": "increment", "value": 2, "data_type": "number" } ], "rate_card_items": [ { "id": "77b42897-e4f5-4bab-a0ca-64b71bbca966", "name": "0<ram_size<=4", "sequence": 0, "description": "A test RateCard Item created for e2e tests", "frequency": { "code": "MONTH", "value": 1 }, "expression": { "when": { "and": [ { ">": [ { "var": "ram_size" }, 0 ] }, { "<=": [ { "var": "ram_size" }, 8 ] } ] }, "then": [ { "uom": { "code": "GB", "value": 1 }, "name": "basePrice", "json_formula": { "var": "base_price" } } ] } }, { "id": "d8495961-d472-4a93-be25-94583157ea0a", "name": "4<ram_size<=32", "sequence": 1, "description": "A test RateCard Item created for e2e tests", "frequency": { "code": "MONTH", "value": 1 }, "expression": { "when": { "and": [ { ">": [ { "var": "ram_size" }, 8 ] }, { "<=": [ { "var": "ram_size" }, 32 ] } ] }, "then": [ { "uom": { "code": "GB", "value": 1 }, "name": "basePrice", "json_formula": { "var": "base_price" } }, { "uom": { "code": "", "value": 1 }, "name": "increment", "raw_formula": "(ram_size - 4) * increment" } ] } } ] } ] } ]}
This rate card contains a variable defined as follows:
"variables": [ { "id": "base_price", "value": 49, "data_type": "number" }
Take the rate_card_items with id : 9603e3c3-6f61-4f6c-923f-0912cce39c0c as the first example. The when block is as follows:
"when": { "and": [ { ">": [ { "var": "disk_size" }, 40 ] }, { "<=": [ { "var": "disk_size" }, 100 ] } ] }
In this example, when the disk_size is greater than 40 and less than or equal to 100, the rule is applied. In that case, the following then block is executed:
"then": [ { "uom": { "code": "GB", "value": 1 }, "name": "basePrice", "json_formula": { "var": "base_price" } }, { "uom": { "code": "", "value": 1 }, "name": "increment", "raw_formula": "max(min(60, disk_size - 40), 0) * increment" } ]
As established, the base_price is set to 49 in the variables block. Assuming disk_size is set to 70, increment will be set to 60 based on the raw_formula and the value of increment set in rate_card_groups with id: 8c174830-8e54-4d7d-95c5-e2b4bdcafc94 is as follows:
{ "id": "increment", "value": 2, "data_type": "number"}