diff --git a/hypha/apply/dashboard/templates/dashboard/finance_dashboard.html b/hypha/apply/dashboard/templates/dashboard/finance_dashboard.html index d3985ae2ccb0563c7ff19cd5cda7bf03e4d5f71f..1e8a957474d517d131ebb1a3fcfb79d000df1bff 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 9ac43c32d82e9ec7b365309490083d2fc595bf93..168c761ab9878fed9faf14051c4d09a975475dfb 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 b9d4ffe614b2c477bfa351f8e3ab8b504e508530..8403ffd232156ec54b068d29ba7f8e60d59daa48 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])