diff --git a/apps/ops/src/pages/ReportInternetCherPage.vue b/apps/ops/src/pages/ReportInternetCherPage.vue index 6a8459e..b04c181 100644 --- a/apps/ops/src/pages/ReportInternetCherPage.vue +++ b/apps/ops/src/pages/ReportInternetCherPage.vue @@ -7,11 +7,13 @@ -
+
Total mensuel net du service Internet (forfait + rabais récurrents, forfaits annuels - ramenés au mois) par adresse de service, depuis la base legacy. Exclut TV, téléphonie - et les frais ponctuels (équipement, installation). Sert à repérer les clients qui - gagneraient à être déplacés vers un forfait mieux adapté. + ramenés au mois) par adresse de service, depuis la base legacy. + Comptes clients actifs uniquement — exclut les comptes résiliés, + prospects, relais/infrastructure et propriétaires-hébergeurs. Exclut aussi TV, + téléphonie, frais ponctuels (équipement, installation) et crédits promo expirés. + Sert à repérer les clients qui gagneraient à être déplacés vers un forfait mieux adapté.
diff --git a/services/targo-hub/lib/legacy-reports.js b/services/targo-hub/lib/legacy-reports.js index 590d944..3fc1648 100644 --- a/services/targo-hub/lib/legacy-reports.js +++ b/services/targo-hub/lib/legacy-reports.js @@ -20,6 +20,24 @@ * → service (delivery_id, status=1) active service line * → product (category, price) the plan; price<0 = recurring discount * + * Account-level filters (mirror the legacy recurring-billing logic in + * LEGACY-ACCOUNTING-ANALYSIS.md §6.1, which bills only when BOTH + * service.status=1 AND account.status=1): + * account.status = 1 → active account. status=4 is terminated + * (8602 accounts, most with a terminate_date, + * e.g. Or Viande Inc closed in 2014 but still + * carrying an orphan service.status=1 line). + * account.group_id = 5 → "Client" per the account_group table. Excludes + * 6 Prospect, 7 Fournisseur, 8 Relais (network + * infrastructure accounts like a tower-host), + * 10 Équipement motorisé — none are billable + * residential/commercial customers. + * customer_id NOT LIKE → 59 "PROPRIO*" accounts sit inside group 5 but + * 'PROPRIO%' are landowners hosting our relay/antenna gear + * under a special arrangement (e.g. Denis + * Henderson "PROPRIOH_STCHARLES"), not regular + * paying customers. Excluded by their id prefix. + * * Effective monthly price of a service line: * base = service.hijack=1 ? service.hijack_price : product.price * // product.price is ALREADY the monthly unit price regardless of the @@ -116,6 +134,9 @@ function buildQuery (url) { JOIN service s ON s.delivery_id = d.id AND s.status = 1 JOIN product p ON p.id = s.product_id WHERE p.category IN (${catPlaceholders}) + AND a.status = 1 + AND a.group_id = 5 + AND a.customer_id NOT LIKE 'PROPRIO%' AND p.price_recurr_type = 1 AND NOT (p.price < 0 AND s.actif_until IS NOT NULL AND s.actif_until > 0 AND s.actif_until < UNIX_TIMESTAMP()) ${commercialClause}