diff --git a/apps/ops/src/composables/useSubscriptionGroups.js b/apps/ops/src/composables/useSubscriptionGroups.js index 3ea86a4..c55ac5c 100644 --- a/apps/ops/src/composables/useSubscriptionGroups.js +++ b/apps/ops/src/composables/useSubscriptionGroups.js @@ -73,8 +73,16 @@ export function subSubLabel (sub) { return '' } +// Only Active subs contribute to the displayed monthly total. Cancelled/ +// Suspended/Pending rows are still rendered (with strikethrough) for +// audit visibility but they shouldn't inflate the number the rep +// communicates to the customer. Was a real bug on C-LPB4: 5 internet +// rows summed to 196.05 because the 3 cancelled (Megafibre 80, TEST, +// FTTH100) were included in the math even though shown struck-through. +const isActiveBilling = sub => (sub.status || 'Active') === 'Active' + export function sectionTotal (items) { - return items.reduce((s, sub) => s + parseFloat(sub.actual_price || 0), 0) + return items.reduce((s, sub) => isActiveBilling(sub) ? s + parseFloat(sub.actual_price || 0) : s, 0) } export function annualPrice (sub) { @@ -102,11 +110,12 @@ export function useSubscriptionGroups (subscriptions) { } function locSubsMonthlyTotal (locName) { - return locSubsMonthly(locName).reduce((sum, s) => sum + parseFloat(s.actual_price || 0), 0) + // Same active-only filter as sectionTotal — keep them in sync. + return locSubsMonthly(locName).reduce((sum, s) => isActiveBilling(s) ? sum + parseFloat(s.actual_price || 0) : sum, 0) } function locSubsAnnualTotal (locName) { - return locSubsAnnual(locName).reduce((sum, s) => sum + annualPrice(s), 0) + return locSubsAnnual(locName).reduce((sum, s) => isActiveBilling(s) ? sum + annualPrice(s) : sum, 0) } function locSubsSections (locName, freq) { diff --git a/apps/ops/src/modules/dispatch/components/RightPanel.vue b/apps/ops/src/modules/dispatch/components/RightPanel.vue index 1e26295..c9ffdbd 100644 --- a/apps/ops/src/modules/dispatch/components/RightPanel.vue +++ b/apps/ops/src/modules/dispatch/components/RightPanel.vue @@ -52,11 +52,13 @@ const onDeleteTag = inject('onDeleteTag')
{{ panel.data.job.serviceLocation }}
diff --git a/apps/ops/src/pages/ClientDetailPage.vue b/apps/ops/src/pages/ClientDetailPage.vue
index 2d51b45..7eb627a 100644
--- a/apps/ops/src/pages/ClientDetailPage.vue
+++ b/apps/ops/src/pages/ClientDetailPage.vue
@@ -15,16 +15,25 @@