I use order tags for lots of things to customise the type of dive my customers have purchased and to record who needs to earn commission for the sale, but I have recently noticed something strange…
Consider just the following three order tags:
- Commission - Just a name which can be click and doesn’t actually affect the price of the order
- Discount - Either a -10% or -20% rate tag to give discounts for certain people.
- Equipment rental - An optional +15 price tag to charge the customer for renting dive equipment.
When applying the Discount tag I have noticed inconsistency in the JSON data that is stored in the DB.
When I have 3 tags (Commission, Discount and Equipment) added to the order, the JSON looks like this…
[
{
"OI":11,
"OK":"070020",
"Q":1,
"TN":"Commission",
"TV":"matt@tankha",
"UI":4
},
{
"OI":12,
"OK":"110010",
"PR":-8.000000,
"Q":1,
"RT":-10.00,
"TN":"Discounts",
"TV":"Multi-day discount",
"UI":4
},
{
"DS":"Dive equipment rental",
"OI":13,
"OK":"150010",
"PR":15.0000,
"Q":1,
"TN":"Equipment",
"TV":"Full",
"UI":4
}
]
When I have just 2 tags (Commission and DIscount) added, the JSON looks like this…
[
{
"OI":11,
"OK":"070040",
"Q":1,
"TN":"Commission",
"TV":"kim@tankha",
"UI":4
},
{
"OI":12,
"OK":"110010",
"Q":1,
"RT":-10.00,
"TN":"Discounts",
"TV":"Local discount",
"UI":4
}
]
The important difference here is the when I have Equipment added, the Discount tag is different…
If the discount tag is the final tag in the list then it does not include a PR value
Conversely, if the discount tag is followed by other tags then it does include a PR value.
Why does this matter???
I am trying to use a REPORT ORDER TAG DETAILS
tag to show all tags which affect the price (T.PRice
) of an order. However, if the discount is the last item in the list then it won’t have a PR value and therefore shows a T.Price=0.00
in the report (even though the RT rate value did affect the order price).
For now, I have moved the commission to be the final tag in the list and this is always required so a discount tag will never be the last tag applied - But I am guessing this inconsistency I have found probably does need a proper fix at some point.
I understand that in many ways good practice would be to just base the PR on the RT and therefore to never include a PR value, but if that’s the case the REPORT ORDER TAG DETAILS:T.Price
logic needs to be updated to calculate the price from the rate when the report is produced.