Files
api/services/nginx/app/tests/Unit/Invoicing
MiniMax M3 Subagent 89aa895192 fix(api): suppress historical_primary_product_mismatch when reg_2 is empty
Bug #10: When an order has only one registration number (reg_2 is empty)
but the reg historically appeared in tractor-trailer bookings, the
'historical_primary_product_mismatch' flag falsely suggests that the
current tractor-only billing is incorrect. The operator (Sarah #10714)
correctly expects that billing only a tractor is the right action when
there's no trailer to bill.

This change suppresses the historical_primary_product_mismatch flag for
rows where reg_2 is empty, matching the operator expectation. The
underlying historical SQL already filters by reg_1 only; a follow-up
could narrow the history to orders with matching reg_2 patterns, but for
the reported false-positive this fix is sufficient.

- invoice_period_flag_service.php: add o.reg_2 to the row projection
  and skip the historical mismatch loop when the current order's reg_2
  is empty.
- InvoicePeriodFlagServiceTest.php: include reg_2 in the existing
  historical mismatch test fixture so it still exercises the flag path.
2026-08-10 20:10:49 +02:00
..