From cdc9f864b28528ea6f33fe3a765fbfc1d65d8d6a Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Thu, 21 May 2026 03:49:10 -0400 Subject: [PATCH] feat(fusion_claims): add dashboard other-funder counts Co-Authored-By: Claude Opus 4.7 (1M context) --- fusion_claims/models/dashboard.py | 19 ++++++++++++++- fusion_claims/tests/test_dashboard.py | 34 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/fusion_claims/models/dashboard.py b/fusion_claims/models/dashboard.py index 84f41c2c..24d237a1 100644 --- a/fusion_claims/models/dashboard.py +++ b/fusion_claims/models/dashboard.py @@ -187,17 +187,25 @@ class FusionClaimsDashboard(models.TransientModel): rec.my_activities_html = '\n'.join(rows) # ========================================================================= - # Bottlenecks (left column) + # Bottlenecks (left column) + Other funder counts # ========================================================================= bottleneck_no_pod_count = fields.Integer(compute='_compute_secondary_counts') bottleneck_no_response_count = fields.Integer(compute='_compute_secondary_counts') + count_odsp = fields.Integer(compute='_compute_secondary_counts') + count_wsib = fields.Integer(compute='_compute_secondary_counts') + count_insurance = fields.Integer(compute='_compute_secondary_counts') + count_mdc = fields.Integer(compute='_compute_secondary_counts') + count_hardship = fields.Integer(compute='_compute_secondary_counts') + count_acsd = fields.Integer(compute='_compute_secondary_counts') + def _compute_secondary_counts(self): from datetime import date, timedelta SO = self.env['sale.order'].sudo() cutoff_14d_ago = date.today() - timedelta(days=14) for rec in self: base = rec._role_filter_domain() + active = base + [('state', '!=', 'cancel')] rec.bottleneck_no_pod_count = SO.search_count(base + [ ('x_fc_adp_application_status', 'in', ['approved', 'approved_deduction']), @@ -207,3 +215,12 @@ class FusionClaimsDashboard(models.TransientModel): ('x_fc_adp_application_status', 'in', ['submitted', 'resubmitted']), ('x_fc_claim_submission_date', '<', cutoff_14d_ago), ]) + + rec.count_odsp = SO.search_count(active + [ + ('x_fc_sale_type', 'in', ['odsp', 'adp_odsp']), + ]) + rec.count_wsib = SO.search_count(active + [('x_fc_sale_type', '=', 'wsib')]) + rec.count_insurance = SO.search_count(active + [('x_fc_sale_type', '=', 'insurance')]) + rec.count_mdc = SO.search_count(active + [('x_fc_sale_type', '=', 'muscular_dystrophy')]) + rec.count_hardship = SO.search_count(active + [('x_fc_sale_type', '=', 'hardship')]) + rec.count_acsd = SO.search_count(active + [('x_fc_client_type', '=', 'ACS')]) diff --git a/fusion_claims/tests/test_dashboard.py b/fusion_claims/tests/test_dashboard.py index 589687e9..cf8534b4 100644 --- a/fusion_claims/tests/test_dashboard.py +++ b/fusion_claims/tests/test_dashboard.py @@ -208,3 +208,37 @@ class TestFusionClaimsDashboard(TransactionCase): }) dashboard = self.Dashboard.with_user(self.manager).create({}) self.assertEqual(dashboard.bottleneck_no_response_count, 1) + + # ------------------------------------------------------------------------- + # Task 5 — Other funder counts + # ------------------------------------------------------------------------- + def test_other_funder_counts_segregate_by_sale_type(self): + SO = self.env['sale.order'].with_context(skip_status_validation=True) + SO.create({'partner_id': self.partner.id, 'user_id': self.manager.id, + 'x_fc_sale_type': 'odsp'}) + SO.create({'partner_id': self.partner.id, 'user_id': self.manager.id, + 'x_fc_sale_type': 'wsib'}) + SO.create({'partner_id': self.partner.id, 'user_id': self.manager.id, + 'x_fc_sale_type': 'insurance'}) + SO.create({'partner_id': self.partner.id, 'user_id': self.manager.id, + 'x_fc_sale_type': 'muscular_dystrophy'}) + SO.create({'partner_id': self.partner.id, 'user_id': self.manager.id, + 'x_fc_sale_type': 'hardship'}) + SO.create({'partner_id': self.partner.id, 'user_id': self.manager.id, + 'x_fc_sale_type': 'adp', 'x_fc_client_type': 'ACS'}) + dashboard = self.Dashboard.with_user(self.manager).create({}) + self.assertEqual(dashboard.count_odsp, 1) + self.assertEqual(dashboard.count_wsib, 1) + self.assertEqual(dashboard.count_insurance, 1) + self.assertEqual(dashboard.count_mdc, 1) + self.assertEqual(dashboard.count_hardship, 1) + self.assertEqual(dashboard.count_acsd, 1) + + def test_other_funder_counts_exclude_cancelled(self): + so = self.env['sale.order'].with_context(skip_status_validation=True).create({ + 'partner_id': self.partner.id, 'user_id': self.manager.id, + 'x_fc_sale_type': 'wsib', + }) + so.with_context(skip_status_validation=True).write({'state': 'cancel'}) + dashboard = self.Dashboard.with_user(self.manager).create({}) + self.assertEqual(dashboard.count_wsib, 0)