Basket.serialize puts every basket-level amount through roundAmount; BasketItem.serialize puts none of the item amounts through it. Measured:
basket amountTotalGross: 0.3
item amountGross : 0.30000000000000004
item amountDiscount : 8.881784197001252e-16
roundAmount's own docstring names both hazards: the API truncates past four decimals, and json.dumps writes a near-zero residue in scientific notation, "not a number the API accepts".
This matters more since #13 documented that v3 reconciles totalValueGross == sum((amountPerUnitGross - amountDiscountPerUnitGross) * quantity) exact to the cent (API.600.410.062) — that guidance asks the caller to do exactly the arithmetic whose residue nothing scrubs. Spreading a 90.78 discount over 7 units gives 12.968571428571428 on the wire against a rounded total; the API truncates to 12.9685 and its own sum no longer matches.
Rounding was added deliberately at the basket level and looks simply forgotten at the item level. Suggested: route amountPerUnitGross, amountDiscountPerUnitGross, amountGross, amountVat, amountPerUnit, amountNet and amountDiscount through roundAmount the same way.
Basket.serializeputs every basket-level amount throughroundAmount;BasketItem.serializeputs none of the item amounts through it. Measured:roundAmount's own docstring names both hazards: the API truncates past four decimals, andjson.dumpswrites a near-zero residue in scientific notation, "not a number the API accepts".This matters more since #13 documented that v3 reconciles
totalValueGross == sum((amountPerUnitGross - amountDiscountPerUnitGross) * quantity)exact to the cent (API.600.410.062) — that guidance asks the caller to do exactly the arithmetic whose residue nothing scrubs. Spreading a 90.78 discount over 7 units gives12.968571428571428on the wire against a rounded total; the API truncates to12.9685and its own sum no longer matches.Rounding was added deliberately at the basket level and looks simply forgotten at the item level. Suggested: route
amountPerUnitGross,amountDiscountPerUnitGross,amountGross,amountVat,amountPerUnit,amountNetandamountDiscountthroughroundAmountthe same way.