CC Pricing Macro
The post talks about how to design a pricing macro which looks into the mapping table to derive the correct output column. Here we are going to use the price table which is a special kind of mapping table class.
Price Table is the mapping table class which has two input columns price key and currency and output is the amount.
Now let’s create a mapping table instance of the mapping table class[price table].
Provide mapping table name and the mapping table class as Price Table and create some mapping table records.
When the pricing macro will look into the table with a specific price key, currency and date it derives a particular amount.
A pricing macro is a reusable entity which can be used in different charges.
Now let’s create a Pricing Macro.
Below Screen appears.
Provide the name and description. As previously we set the context that the price macro will look into the price table to derive an amount – we need to pass three fields: what is the price table, what is the price key and date. Also need to pass the currency but for the currency we dont need any field in the price macro. When the price macro become the part of the charge the currency automatically flows with the standard parameter called CURRENCY_CODE.
Now create 3 input parameters with appropriate types and 1 output parameter as amount.
Now add a mapping table introducer to the price macro.
Below screen appears.
Provide name and description. Map the price macro input parameters to the mapping table parameter.
The mapping table introducer has two parts – row found and row not found.
Add Out Property Update to the row found section which updates the price found from the mapping table introducer to the price macro.
Below screen appears.
Now map the mapping table introducer property : amount to the price macro parameter: pm_amount.
To the Row Not Found- Add no access function.
Below screen appears.
Provide a message and select some properties that will be displayed as popup message when price macro don’t find a price.
Add a Flat/linear function to the row found section.
Once the mapping table introducer find an amount from the price table, we can take this value and then we can make some more calculation like we can add some value to it or multiply. But here in this case we have added a flat function.
Up to this the price macro design is over.
Now lets create a charge and use the price macro inside this and then will test the charge.
Provide charge name and description.
Add twp parameters in the charge one is mapping table id and the mapping table key.
Provide name and description to the price plan.
Add Recurring Rate to the Price plan.
Provide name & description and mention what is the cycle of the recurring rate. IT can be day/week/month/year. Here lets set as every day.
Add Macro operator to the recurring rate.
Provide name and description. Provide – Pricing Macro as designed above.
Now map the charge parameter to the price macro parameter.
Add a flat function to the recurring rate.
Set the price macro generated property in the function.
Save the charge.
Trial the charge.
Provide date, currency.
Also fill the mapping table id and the price key. Execute and it displays the price.
Again run with a different price key.
The price macro error appears: no row found.
Provide date in feb.
It finds the correct price from the mapping table and as the charge has recurring fee which is every day, the recurring fee calculated accordingly.
Try with different price key and we receive an error.