Flow
The order my report checks for a rate
11 A percent field
A field meant to hold a percent, or one that says percent next to a value
22 Worked out from the sale
This promotion's discount over the line price before discount, saved with the numbers used
33 A real percent sign
A name like 10% off; a bare 10 does not count
4Nothing found
The row claims the register's dollars and is marked as a fallback
The vendor credit report decided that a promotion tag reading "10" meant ten percent off. I shipped that, and pulled it the same day. Every claim the report sends a supplier hangs on its rate.
Register dollars and supplier dollars
The register tells you how many dollars came off for the shopper. The supplier owes a share of what the store paid. Those are different numbers. My report claims rate times wholesale cost times units, and keeps the register's dollars next to it for audit only.
That puts all the weight on the rate. A wrong rate won't break anything. It just gives you a neat, wrong number everywhere.
What a "10" tag can mean
My first change took any tag made only of digits as a percent. The test passed. But a tag is text a person typed. "10" could mean ten percent, ten dollars, or the tenth campaign. The string can't tell you, so the code can't either.
The order the report checks now
The order my report checks now:
- A field in the promotion's data that is meant to hold a percent, or one that says "percent" next to a value.
- A rate worked out from the sale: this promotion's discount divided by the line's price before discount.
- A name with an actual percent sign in it.
A bare "10" with nothing behind it gets no rate, and a test pins that.
For the worked-out rate, use the line total, or unit price times quantity if the total is missing. Skip it when the price is zero or missing, the discount isn't positive, or the discount is bigger than the line. Then save the price and discount you used next to the rate, so a person can redo the math later.
The rate is the discount divided by what the line cost before it. In a made-up example, 4 off a line of 40 is one tenth.
One trap: my sync step used to skip any sale that already had a product name. Once it had to find rates too, that skip was wrong, so I took it out.
What the headline counts now
My top-line total now counts only rows tied to a supplier and a product with a real amount. The rest stay in the drilldown with their own audit total. Before, the big number counted rows nobody could claim.
When no rate turns up, my report still claims the register's dollars for that row and marks it as a fallback. I haven't settled what that row should claim yet.