Three lines of fix, the rest is leftovers
builds on: Scope creep and unasked-for changes in a diff, What 'done' means for a change
The fix is the import change plus the `q` and `quantize` lines. Everything else is a tell. The `print` runs on every invoice in production and fills the logs. The commented-out line leaves readers wondering whether to restore it. `_round_v1` is called nowhere. It also rounds half to even and returns a float, the very behaviour being fixed, so whoever reuses it brings the bug back. The scratch file ships in the repo, and the next reader has to work out whether it matters. All of it goes before merge, not in a later cleanup.
// Python
--- a/billing/invoice.py
+++ b/billing/invoice.py
@@ -1 +1 @@
-from decimal import Decimal
+from decimal import Decimal, ROUND_HALF_UP
@@ -12 +12,7 @@
- return round(total, 2)
+ print("DBG total", total)
+ # return round(total, 2)
+ q = Decimal("0.01")
+ return total.quantize(q, ROUND_HALF_UP)
+
+def _round_v1(x):
+ return float(f"{x:.2f}")
--- /dev/null
+++ b/scratch_test_round.py