Update Todos

Fix net_bill_value in SessionRepo::completed() to include bowser_amount after allocation

Fix MyCloudLibrary line 258 — assignment bug in meter_rental

Remove double-count workaround in siteServiceTemplate.blade.php line 269

Verify: API transformer — does frontend sum net_bill_value + bowser_amount client-side?

Verify: Vilogi journal entry (JournalEntryService) — confirm montant should include bowser

Verify: CSV export (siteServiceCsv) — confirm 'Bill Value' column should include bowser

Verify: TXT export (toText) — confirm amount field should include bowser

Verify: lotSummaryPdf — confirm totals will be correct with bowser included

Verify: existing archived_sessions data — do historical records need a backfill migration?
Fix Plan: net_bill_value must include bowser_amount
Root cause
net_bill_value is computed in MyCloudLibrary::calculation() as:


CWA + WMA + service_charge + meter_rental      (water)
bill_rate + load_rate + service_charge + meter_rental   (electricity/gas)
Bowser allocation happens after calculation() returns, in SessionRepo::completed() line 785. net_bill_value is never recalculated to include it.

Code changes
1. SessionRepo::completed() — after the bowser allocation loop (line 791), add a second pass to update net_bill_value:


foreach ($billRate as $key => $value) {
    if (!empty($value['bowser_amount'])) {
        $billRate[$key]['net_bill_value'] += (float) $value['bowser_amount'];
    }
}
This is the single source fix. All downstream consumers read net_bill_value from the archived row.

2. MyCloudLibrary.php line 258 — fix the accidental assignment bug:


// Before (assignment = instead of addition +)
$key['net_bill_value'] = ... + $key['meter_rental'] = $service->meter_rental;
// After
$key['net_bill_value'] = ... + $key['meter_rental'];
This is a syntax bug unrelated to bowser but should be fixed in the same pass.

3. siteServiceTemplate.blade.php line 269 — remove the workaround:


// Before (double-counts bowser once net_bill_value includes it)
$totalDue = (float) $value['net_bill_value'] + (float) ($value['bowser_amount'] ?? 0);
// After
$totalDue = (float) $value['net_bill_value'];
Things to verify before shipping
#	Verify	Risk if wrong	How to check
1	Frontend API consumer — does it sum net_bill_value + bowser_amount client-side like the PDF template did?	Double-count on the frontend UI	Search frontend codebase for bowser_amount and net_bill_value usage
2	Vilogi journal entry — montant uses net_bill_value. Confirm Vilogi expects the total inclusive of bowser, not just the consumption charges	Incorrect accounting entry sent to Vilogi	Check Vilogi API docs or confirm with the integration spec
3	CSV export (siteServiceCsv) — "Bill Value" column outputs net_bill_value. Confirm admins expect this to include bowser	Exported values change for bowser sessions	Confirm with business whether "Bill Value" = total due
4	TXT export (toText()) — outputs net_bill_value as the pipe-delimited amount field	Accounting import file values change	Same as above — confirm the TXT consumer expects total inclusive of bowser
5	Lot summary PDF (lotSummaryPdf.blade.php) — displays and sums net_bill_value. Does it also have a separate bowser line or workaround like the bill PDF?	Double-count or missing bowser on summary	Read the full template for bowser references
6	Historical archived_sessions — all existing rows in the DB have net_bill_value that excludes bowser. Any reporting query (dashboards, summaries, SUM(net_bill_value)) will show a discontinuity between old and new records	Revenue reports show a jump at the cutover point	Decide: run a one-time backfill migration (UPDATE archived_sessions SET net_bill_value = net_bill_value + bowser_amount WHERE bowser_amount IS NOT NULL AND bowser_amount > 0) or accept the break
7	Non-billable zeroing in SessionRepo::completed() — currently zeros bowser_amount for non-billable lots. Confirm the += bowser_amount line runs after the zeroing block so non-billable lots don't accidentally get bowser added	Main meter gets a non-zero net_bill_value	Check code ordering: zeroing block must come before the bowser += line
Recommended execution order
Get answers on verify items 1–6 (frontend + business confirmation)
Apply code changes 1–3 in a single commit
Decide on historical backfill (verify item 6) — can be a separate migration
Test with a water session that includes a bowser cost and confirm the PDF total matches