diff --git a/services/nginx/app/classes/invoice_period_flag_service.php b/services/nginx/app/classes/invoice_period_flag_service.php index f0bbdc5a..117088f7 100644 --- a/services/nginx/app/classes/invoice_period_flag_service.php +++ b/services/nginx/app/classes/invoice_period_flag_service.php @@ -758,6 +758,7 @@ class invoice_period_flag_service o.department_id, d.custom_pricing_only AS department_custom_pricing_only, o.reg_1, + o.reg_2, o.invoice_collection_id, o.wash_id, o.safety_seal, @@ -1303,6 +1304,16 @@ class invoice_period_flag_service if ($reg === '' || !isset($history[$reg])) { continue; } + // When the current order only has one registration number (reg_2 is empty), + // the historical "usual product" may include a trailer component (e.g. + // "Tractor-trailer wash") because the reg previously only appeared in + // tractor-trailer bookings. Billing just the tractor in that case is correct + // and matches the operator's expectation (bug #10, Sarah #10714). The mismatch + // is therefore uninformative when reg_2 is empty, so suppress the flag. + $reg2 = trim((string)($row['reg_2'] ?? '')); + if ($reg2 === '') { + continue; + } $expectedProductId = (int)$history[$reg]['product_id']; if ($this->primaryVehicleProductsMatch( (int)$row['product_id'], diff --git a/services/nginx/app/tests/Unit/Invoicing/InvoicePeriodFlagServiceTest.php b/services/nginx/app/tests/Unit/Invoicing/InvoicePeriodFlagServiceTest.php index 5ec08ea0..200d968e 100644 --- a/services/nginx/app/tests/Unit/Invoicing/InvoicePeriodFlagServiceTest.php +++ b/services/nginx/app/tests/Unit/Invoicing/InvoicePeriodFlagServiceTest.php @@ -464,6 +464,7 @@ it('does not flag interior wash variants as historical primary product mismatche 'invoice_collection_id' => 16912, 'department_id' => 7, 'reg_1' => 'CN96636', + 'reg_2' => 'AB12345', 'is_wash' => 1, 'related_item_id' => 0, 'order_created_at' => '2026-05-11 08:05:21',