diff --git a/hypha/apply/activity/adapters/utils.py b/hypha/apply/activity/adapters/utils.py
index 67c5388d4f..ea3c01574c 100644
--- a/hypha/apply/activity/adapters/utils.py
+++ b/hypha/apply/activity/adapters/utils.py
@@ -133,4 +133,4 @@ def get_users_for_groups(groups, user_queryset=None, exact_match=False):
user_queryset = user_queryset.filter(groups__name=groups.pop().name)
return get_users_for_groups(groups, user_queryset=user_queryset)
else:
- return user_queryset
+ return user_queryset if user_queryset is not None else set()
diff --git a/hypha/apply/projects/forms/payment.py b/hypha/apply/projects/forms/payment.py
index a48c0d2e63..c830156390 100644
--- a/hypha/apply/projects/forms/payment.py
+++ b/hypha/apply/projects/forms/payment.py
@@ -4,6 +4,7 @@
from django.core.files.base import ContentFile
from django.db import transaction
from django.db.models.fields.files import FieldFile
+from django.forms.widgets import RadioSelect
from django.utils.translation import gettext_lazy as _
from django_file_form.forms import FileFormMixin
@@ -69,16 +70,22 @@ class ChangeInvoiceStatusForm(forms.ModelForm):
class Meta:
fields = ["status", "paid_date", "comment"]
model = Invoice
+ widgets = {"status": RadioSelect}
- def __init__(self, instance, user, *args, **kwargs):
+ def __init__(self, *args, **kwargs):
+ user = kwargs.pop("user")
+ instance = kwargs.pop("instance")
super().__init__(*args, **kwargs, instance=instance)
- self.initial["comment"] = ""
- status_field = self.fields["status"]
-
- status_field.choices = get_invoice_possible_transition_for_user(
+ invoice_choices = get_invoice_possible_transition_for_user(
user, invoice=instance
)
+ self.initial["comment"] = ""
+ if len(invoice_choices) > 4:
+ self.fields["status"] = forms.TypedChoiceField(choices=invoice_choices)
+ else:
+ self.fields["status"].choices = invoice_choices
+
class InvoiceBaseForm(forms.ModelForm):
class Meta:
diff --git a/hypha/apply/projects/templates/application_projects/includes/invoices.html b/hypha/apply/projects/templates/application_projects/includes/invoices.html
index e908dc0cad..7600633b32 100644
--- a/hypha/apply/projects/templates/application_projects/includes/invoices.html
+++ b/hypha/apply/projects/templates/application_projects/includes/invoices.html
@@ -18,95 +18,13 @@
{% trans "Date submitted" %}
{% trans "Invoice date" %}
- {% trans "Invoice No." %}
+ {% trans "Invoice no." %}
{% trans "Status" %}
-
- {% for invoice in object.invoices.not_rejected %}
- {% display_invoice_status_for_user user invoice as invoice_status %}
-
- {% trans "Date submitted" %}: {{ invoice.requested_at.date }}
- {% trans "Invoice date" %}: {% if invoice.invoice_date %}{{ invoice.invoice_date }}{% else %} {{ invoice.requested_at.date }} {% endif %}
- {% trans "Invoice number" %}: {{ invoice.invoice_number }}
- {% trans "Status" %}: {{ invoice_status }}
-
-
- {% heroicon_micro "eye" aria_hidden=true class="me-1" %}
- {% trans "View" %}
-
- {% can_edit invoice user as user_can_edit_request %}
- {% if user_can_edit_request %}
-
- {% heroicon_micro "pencil-square" aria_hidden=true class="me-1" %}
- {% trans "Edit" %}
-
- {% endif %}
-
- {% can_delete invoice user as user_can_delete_request %}
- {% if user.is_applicant and user_can_delete_request %}
-
- {% heroicon_micro "trash" aria_hidden=true class="me-1" %}
- {% trans "Delete" %}
-
- {% endif %}
- {% can_change_status invoice user as can_change_invoice_status %}
- {% if can_change_invoice_status %}
-
- {% trans "Update Status" %}
-
-
- {% get_invoice_form invoice user as invoice_form %}
- {% get_invoice_form_id invoice_form invoice as invoice_form_id %}
-
-
{% trans "Current status" %}: {{ invoice_status }}
- {% trans "Update Status" as update %}
- {% include 'funds/includes/delegated_form_base.html' with form=invoice_form value=update action=invoice.get_absolute_url form_id=invoice_form_id %}
-
-
- {% endif %}
-
-
- {% endfor %}
+
+ {% include "application_projects/partials/invoice_status_table.html" with invoices=object.invoices.not_rejected rejected=False %}
{% else %}
@@ -123,27 +41,13 @@
{% trans "Date submitted" %}
{% trans "Invoice date" %}
- {% trans "Invoice number" %}
+ {% trans "Invoice no." %}
{% trans "Status" %}
-
- {% for invoice in object.invoices.rejected %}
- {% display_invoice_status_for_user user invoice as invoice_status %}
-
- {% trans "Date submitted" %}: {{ invoice.requested_at.date }}
- {% trans "Invoice date" %}: {% if invoice.invoice_date %}{{ invoice.invoice_date }}{% else %} {{ invoice.requested_at.date }} {% endif %}
- {% trans "Invoice number" %}: {{ invoice.invoice_number }}
- {% trans "Status" %}: {{ invoice_status }}
-
-
- {% heroicon_mini "eye" size=16 aria_hidden=true class="me-1" %}
- {% trans "View" %}
-
-
-
- {% endfor %}
+
+ {% include "application_projects/partials/invoice_status_table.html" with invoices=object.invoices.rejected rejected=True %}
{% endif %}
diff --git a/hypha/apply/projects/templates/application_projects/includes/update_invoice_form.html b/hypha/apply/projects/templates/application_projects/includes/update_invoice_form.html
new file mode 100644
index 0000000000..d2ec4b8e55
--- /dev/null
+++ b/hypha/apply/projects/templates/application_projects/includes/update_invoice_form.html
@@ -0,0 +1,13 @@
+{% load i18n %}
+
+{% modal_title %}Update Invoice Status{% endmodal_title %}
+
+
\ No newline at end of file
diff --git a/hypha/apply/projects/templates/application_projects/invoice_admin_detail.html b/hypha/apply/projects/templates/application_projects/invoice_admin_detail.html
index 0bce3742be..a32e945518 100644
--- a/hypha/apply/projects/templates/application_projects/invoice_admin_detail.html
+++ b/hypha/apply/projects/templates/application_projects/invoice_admin_detail.html
@@ -7,38 +7,8 @@
{% endif %}
{% endblock %}
-{% block actions %}
- {{ block.super }}
- {% can_change_status object user as user_can_change_status %}
-
- {% trans "Update Invoice Status" %}
-
- {% if user_can_change_status %}
-
-
-
{% trans "Current status" %}: {{ object.status_display }}
- {% trans "Update Status" as update %}
- {% include 'funds/includes/delegated_form_base.html' with form=change_invoice_status value=update %}
-
- {% endif %}
-{% endblock %}
-
-{% block extra_css %}
-
-{% endblock %}
-
{% block extra_js %}
{{ block.super }}
-
-