From ffd4ac28b7745e1b81902f47a845ac26974691d3 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 <sandeepsajan0@gmail.com> Date: Sat, 15 Oct 2022 18:14:44 +0530 Subject: [PATCH] Show invoices in seperate table to finance for their review and sage intacct --- .../dashboard/finance_dashboard.html | 15 ++++++++++++++ hypha/apply/dashboard/views.py | 20 +++++++++++++++++++ hypha/apply/projects/models/payment.py | 8 ++++++++ 3 files changed, 43 insertions(+) diff --git a/hypha/apply/dashboard/templates/dashboard/finance_dashboard.html b/hypha/apply/dashboard/templates/dashboard/finance_dashboard.html index d3985ae2c..1e8a95747 100644 --- a/hypha/apply/dashboard/templates/dashboard/finance_dashboard.html +++ b/hypha/apply/dashboard/templates/dashboard/finance_dashboard.html @@ -26,6 +26,21 @@ {% endif %} </div> + {% if invoices_for_approval.count %} + <div id="invoices-awaiting-approval" class="wrapper wrapper--bottom-space"> + <h4 class="heading heading--normal">{% trans "Invoices for my review" %}</h4> + {% render_table invoices_for_approval.table %} + </div> + {% endif %} + + {% if invoices_to_convert.count %} + <div id="invoices-to-convert" class="wrapper wrapper--bottom-space"> + <h4 class="heading heading--normal">{% trans "Invoices for entry to Sage IntAcct" %}</h4> + {% render_table invoices_to_convert.table %} + </div> + {% endif %} + + {% if waiting_for_approval.count %} <div id="paf-awaiting-approval" class="wrapper wrapper--bottom-space"> <h4 class="heading heading--normal">{% trans "PAF awaiting approval" %}</h4> diff --git a/hypha/apply/dashboard/views.py b/hypha/apply/dashboard/views.py index 9ac43c32d..168c761ab 100644 --- a/hypha/apply/dashboard/views.py +++ b/hypha/apply/dashboard/views.py @@ -160,6 +160,8 @@ class FinanceDashboardView(MyFlaggedMixin, TemplateView): context.update({ 'active_invoices': self.active_invoices(), + 'invoices_for_approval': self.invoices_for_approval(), + 'invoices_to_convert': self.invoices_to_convert(), 'waiting_for_approval': self.waiting_for_approval(), }) @@ -176,6 +178,24 @@ class FinanceDashboardView(MyFlaggedMixin, TemplateView): 'table': InvoiceDashboardTable(invoices), } + def invoices_for_approval(self): + if self.request.user.is_finance_level_2: + invoices = Invoice.objects.approved_by_finance_1() + else: + invoices = Invoice.objects.approved_by_staff() + + return { + 'count': invoices.count(), + 'table': InvoiceDashboardTable(invoices) + } + + def invoices_to_convert(self): + invoices = Invoice.objects.waiting_to_convert() + return { + 'count': invoices.count(), + 'table': InvoiceDashboardTable(invoices), + } + def waiting_for_approval(self): if not self.request.user.is_finance: return { diff --git a/hypha/apply/projects/models/payment.py b/hypha/apply/projects/models/payment.py index b9d4ffe61..8403ffd23 100644 --- a/hypha/apply/projects/models/payment.py +++ b/hypha/apply/projects/models/payment.py @@ -79,6 +79,14 @@ class InvoiceQueryset(models.QuerySet): def approved_by_finance_1(self): return self.filter(status=APPROVED_BY_FINANCE_1) + def approved_by_finance_2(self): + return self.filter(status=APPROVED_BY_FINANCE_2) + + def waiting_to_convert(self): + if settings.INVOICE_EXTENDED_WORKFLOW: + return self.filter(status=APPROVED_BY_FINANCE_2) + return self.filter(status=APPROVED_BY_FINANCE_1) + def for_finance_1(self): if settings.INVOICE_EXTENDED_WORKFLOW: return self.filter(status__in=[APPROVED_BY_STAFF, CHANGES_REQUESTED_BY_FINANCE_2]) -- GitLab