diff --git a/services/targo-hub/lib/legacy-reports.js b/services/targo-hub/lib/legacy-reports.js index dee653c..46e1ae3 100644 --- a/services/targo-hub/lib/legacy-reports.js +++ b/services/targo-hub/lib/legacy-reports.js @@ -61,8 +61,12 @@ * end date.) * * Internet product categories: - * 32 Mensualités fibre, 4 Mensualités sans-fil, 23 Internet camping - * (add-ons) 16 Téléch. supp, 17 IP fixe, 21 Location point-à-point + * monthly: 32 Mensualités fibre, 4 Mensualités sans-fil, 23 camping + * equipment: 26/29 équipement fibre, 7/8 équipement sans-fil + * (recurring modem/router rentals + Internet discounts that + * live here, e.g. RAB_FTTH_URBA). One-time install charges + * in these cats are dropped by the price_recurr_type=1 filter. + * add-ons: 16 Téléch. supp, 17 IP fixe, 21 Location point-à-point * Excluded entirely: 9 Téléphonie, 33 Télévision, 34 Install télé */ @@ -72,8 +76,18 @@ const { log, json } = require('./helpers') let mysql try { mysql = require('mysql2/promise') } catch { /* optional dep */ } -const CAT_INTERNET_CORE = [32, 4, 23] // fibre, wireless, camping +// Internet category sets. CORE = monthly plans + Internet equipment. +// The equipment categories (26/29 fibre, 7/8 wireless) carry recurring +// modem/router rentals (FTTH_LOCMOD +10, LOC_TPL +5) AND recurring Internet +// discounts (RAB_FTTH_URBA), which are part of the real Internet bill — a +// client's net Internet cost is wrong without them. Example: Claude Bergeron +// shows 94.95 from cat 32 alone, but a -60$ RAB_FTTH_URBA discount lives in +// cat 26, so his true net is 44.95 (and he correctly drops off the report). +// The price_recurr_type=1 filter still excludes one-time install charges +// (INSTFIBRE -199, etc.) that share these equipment categories. +const CAT_INTERNET_CORE = [32, 4, 23, 26, 29, 7, 8] const CAT_INTERNET_ADDONS = [16, 17, 21] // extra download, static IP, point-to-point +// Always excluded: 9 Téléphonie, 33 Télévision, 34 Installation/équip télé. // Monthly-normalized effective price expression (see header comment). const EFF = `((CASE WHEN s.hijack=1 THEN s.hijack_price ELSE p.price END) / (CASE WHEN p.sku LIKE '%ANN' THEN 12 ELSE 1 END))`