Example:
Product has a Purchase UOM: Box of 25 Units and a Cost: $450 (implied cost of $18 per unit).
10 units of the product are sold for $20 per unit.
The margin is calculated as -$4100 (10x$20- 10x$450). It should be $20 (10x$20-.10x$18).
In other words, the total cost is based on the purchase UOM (Box of 25 units) and not the selling UOM (unit).