diff --git a/hypha/apply/projects/forms/payment.py b/hypha/apply/projects/forms/payment.py index 7f18d93c20d75ceb1918a26e4c7c7a6bff730318..0d16ff7c40a25539caebd85c74dd60b5348009e8 100644 --- a/hypha/apply/projects/forms/payment.py +++ b/hypha/apply/projects/forms/payment.py @@ -78,37 +78,25 @@ class ChangeInvoiceStatusForm(forms.ModelForm): class InvoiceBaseForm(forms.ModelForm): class Meta: - fields = ['date_from', 'date_to', 'amount', 'document', 'message_for_pm'] + fields = ['document', 'message_for_pm'] model = Invoice - widgets = { - 'date_from': forms.DateInput, - 'date_to': forms.DateInput, - } def __init__(self, user=None, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields['amount'].widget.attrs['min'] = 0 self.initial['message_for_pm'] = '' - def clean(self): - cleaned_data = super().clean() - date_from = cleaned_data['date_from'] - date_to = cleaned_data['date_to'] - - if date_from > date_to: - self.add_error('date_from', _('Date From must be before Date To')) - - return cleaned_data - class CreateInvoiceForm(FileFormMixin, InvoiceBaseForm): - document = SingleFileField(label='Invoice File', required=True) + document = SingleFileField( + label='Invoice File', required=True, + help_text=_('The invoice must be a PDF.') + ) supporting_documents = MultiFileField( required=False, help_text=_('Files that are related to the invoice. They could be xls, microsoft office documents, open office documents, pdfs, txt files.') ) - field_order = ['date_from', 'date_to', 'amount', 'document', 'supporting_documents', 'message_for_pm'] + field_order = ['document', 'supporting_documents', 'message_for_pm'] def save(self, commit=True): invoice = super().save(commit=commit) @@ -127,7 +115,7 @@ class EditInvoiceForm(FileFormMixin, InvoiceBaseForm): document = SingleFileField(label=_('Invoice File'), required=True) supporting_documents = MultiFileField(required=False) - field_order = ['date_from', 'date_to', 'amount', 'document', 'supporting_documents', 'message_for_pm'] + field_order = ['document', 'supporting_documents', 'message_for_pm'] @transaction.atomic def save(self, commit=True): diff --git a/hypha/apply/projects/tables.py b/hypha/apply/projects/tables.py index e137fd68154967fa20959bbdfdb3ba450f6ad836..2060685c90be84cb57ca169be4bce31341441da8 100644 --- a/hypha/apply/projects/tables.py +++ b/hypha/apply/projects/tables.py @@ -21,10 +21,6 @@ class BaseInvoiceTable(tables.Table): ) status = tables.Column() requested_at = tables.DateColumn(verbose_name=_('Submitted')) - amount = tables.Column(verbose_name=_('Value ({currency})').format(currency=settings.CURRENCY_SYMBOL)) - - def render_amount(self, value): - return intcomma(value) def render_project(self, value): text = textwrap.shorten(value.title, width=30, placeholder="..."), @@ -32,17 +28,12 @@ class BaseInvoiceTable(tables.Table): class InvoiceDashboardTable(BaseInvoiceTable): - date_from = tables.DateColumn(verbose_name=_('Period Start')) - date_to = tables.DateColumn(verbose_name=_('Period End')) - class Meta: fields = [ 'requested_at', 'vendor_document_number', 'status', 'project', - 'date_from', - 'date_to', ] model = Invoice order_by = ['-requested_at'] @@ -59,7 +50,6 @@ class InvoiceListTable(BaseInvoiceTable): 'vendor_document_number', 'status', 'project', - 'amount', 'lead', 'fund', ] @@ -68,13 +58,6 @@ class InvoiceListTable(BaseInvoiceTable): order_by = ['-requested_at'] attrs = {'class': 'invoices-table'} - def order_value(self, qs, is_descending): - direction = '-' if is_descending else '' - - qs = qs.order_by(f'{direction}paid_value', f'{direction}amount') - - return qs, True - class BaseProjectsTable(tables.Table): title = tables.LinkColumn( diff --git a/hypha/apply/projects/templates/application_projects/includes/invoices.html b/hypha/apply/projects/templates/application_projects/includes/invoices.html index d8834fc3295d8c7a44cdd28e3bec65ad57516e25..6b868ddb7f6e646f54bff7989014874a5254aa14 100644 --- a/hypha/apply/projects/templates/application_projects/includes/invoices.html +++ b/hypha/apply/projects/templates/application_projects/includes/invoices.html @@ -12,20 +12,14 @@ <table class="data-block__table"> <thead> <tr> - <th class="data-block__table-amount">{% trans "Amount" %} ({{ CURRENCY_SYMBOL }})</th> <th class="data-block__table-status">{% trans "Status" %}</th> - <th class="data-block__table-date">{% trans "From" %}</th> - <th class="data-block__table-date">{% trans "To" %}</th> <th class="data-block__table-update"></th> </tr> </thead> <tbody> {% for invoice in object.invoices.not_rejected %} <tr> - <td><span class="data-block__mobile-label">{% trans "Amount" %}: </span>{{ invoice.amount|intcomma }}</td> <td><span class="data-block__mobile-label">{% trans "Status" %}: </span>{{ invoice.get_status_display }}</td> - <td><span class="data-block__mobile-label">{% trans "From" %}: </span>{{ invoice.date_from.date }}</td> - <td><span class="data-block__mobile-label">{% trans "To" %}: </span>{{ invoice.date_to.date }}</td> <td> <a class="data-block__action-link" href="{{ invoice.get_absolute_url }}">View</a> {% can_edit invoice user as user_can_edit_request %} @@ -59,7 +53,6 @@ <table class="data-block__table is-hidden js-payment-block-rejected-table"> <thead> <tr> - <th class="data-block__table-amount">{% trans "Amount" %}</th> <th class="data-block__table-status">{% trans "Status" %}</th> <th class="data-block__table-view"></th> </tr> @@ -67,7 +60,6 @@ <tbody> {% for invoice in object.invoices.rejected %} <tr> - <td><span class="data-block__mobile-label">{% trans "Amount" %}: </span>{{ CURRENCY_SYMBOL }}{{ invoice.value }}</td> <td><span class="data-block__mobile-label">{% trans "Status" %}: </span>{{ invoice.get_status_display }}</td> <td><a href="{{ invoice.get_absolute_url }}">{% trans "View" %}</a></td> </tr> diff --git a/hypha/apply/projects/templates/application_projects/invoice_confirm_delete.html b/hypha/apply/projects/templates/application_projects/invoice_confirm_delete.html index 6d056588b2147a88d5a65ddb3a73c43e5fc72b60..2ad489d5eef377017ddbc0280f85a65fbd54c77e 100644 --- a/hypha/apply/projects/templates/application_projects/invoice_confirm_delete.html +++ b/hypha/apply/projects/templates/application_projects/invoice_confirm_delete.html @@ -20,8 +20,6 @@ <p class="card__text"><b>{% trans "Status" %}:</b> {{ object.get_status_display }}</p> <p class="card__text"><b>{% trans "Vendor" %}:</b> {{ object.project.vendor.name }}</p> <p class="card__text"><b>{% trans "Invoice Number" %}:</b> {{ object.pk }}</p> - <p class="card__text"><b>{% trans "Period of Performance" %}:</b> {{ object.date_from.date }} | {{ object.date_to.date }}</p> - <p class="card__text"><b>{% trans "Total" %}:</b> {{ CURRENCY_SYMBOL }}{{ object.amount|intcomma }}</p> </div> <div class="card card--solid"> diff --git a/hypha/apply/projects/templates/application_projects/invoice_detail.html b/hypha/apply/projects/templates/application_projects/invoice_detail.html index 60616e6d14b85d08ed4846a735721f547058249f..bef8d68bfbf2d256eb57ea83028e15928cf491d4 100644 --- a/hypha/apply/projects/templates/application_projects/invoice_detail.html +++ b/hypha/apply/projects/templates/application_projects/invoice_detail.html @@ -19,8 +19,6 @@ <p class="card__text"><b>{% trans "Status" %}:</b> {{ object.get_status_display }}</p> <p class="card__text"><b>{% trans "Vendor" %}:</b> {{ object.project.vendor.name }}</p> <p class="card__text"><b>{% trans "Invoice Number" %}:</b> {{ object.vendor_document_number }}</p> - <p class="card__text"><b>{% trans "Period of Performance" %}:</b> {{ object.date_from.date }} | {{ object.date_to.date }}</p> - <p class="card__text"><b>{% trans "Total" %}:</b> {{ CURRENCY_SYMBOL }}{{ object.amount|intcomma }}</p> </div> <div class="card card--solid"> diff --git a/hypha/apply/projects/tests/factories.py b/hypha/apply/projects/tests/factories.py index a5e386f967a213a7e6c217ee4ec9ac4635f57aa4..1982a721f78ef1ece90aeb341cb26ba9b2eb7daf 100644 --- a/hypha/apply/projects/tests/factories.py +++ b/hypha/apply/projects/tests/factories.py @@ -107,11 +107,6 @@ class PacketFileFactory(factory.django.DjangoModelFactory): class InvoiceFactory(factory.django.DjangoModelFactory): project = factory.SubFactory(ProjectFactory) by = factory.SubFactory(UserFactory) - amount = factory.Faker('pydecimal', min_value=1, max_value=10000000, right_digits=2) - - date_from = factory.Faker('date_time').evaluate(None, None, {'tzinfo': pytz.utc, 'locale': None}) - date_to = factory.Faker('date_time').evaluate(None, None, {'tzinfo': pytz.utc, 'locale': None}) - document = factory.django.FileField() class Meta: diff --git a/hypha/apply/projects/tests/test_forms.py b/hypha/apply/projects/tests/test_forms.py index d4d5bb883afd7ecf0d4bcf15ec14bfcb08b0a386..57c9c14ade594241369434b29708d4c9845ee0da 100644 --- a/hypha/apply/projects/tests/test_forms.py +++ b/hypha/apply/projects/tests/test_forms.py @@ -287,10 +287,7 @@ class TestCreateInvoiceForm(TestCase): def test_adding_invoice(self): data = { 'paid_value': '10', - 'date_from': '2018-08-15', - 'date_to': '2019-08-15', 'comment': 'test comment', - 'amount': 100.0 } document = SimpleUploadedFile('invoice.pdf', BytesIO(b'somebinarydata').read()) @@ -314,10 +311,7 @@ class TestCreateInvoiceForm(TestCase): def test_supporting_documents_not_required(self): data = { 'paid_value': '10', - 'date_from': '2018-08-15', - 'date_to': '2019-08-15', 'comment': 'test comment', - 'amount': 100 } @@ -345,10 +339,7 @@ class TestCreateInvoiceForm(TestCase): files=files, data={ 'paid_value': '10', - 'date_from': '2018-08-15', - 'date_to': '2019-08-15', 'comment': 'test comment', - 'amount': 100 } ) @@ -358,10 +349,7 @@ class TestCreateInvoiceForm(TestCase): files=files, data={ 'paid_value': '10', - 'date_from': '2019-08-15', - 'date_to': '2018-08-15', 'comment': 'test comment', - 'amount': 100 } ) @@ -379,9 +367,6 @@ class TestEditInvoiceForm(TestCase): data={ 'document': invoice.document, 'supporting_documents-uploads': '[]', - 'date_from': '2018-08-15', - 'date_to': '2019-08-15', - 'amount': invoice.amount, }, files={ 'supporting_documents': [], @@ -405,9 +390,6 @@ class TestEditInvoiceForm(TestCase): "size": supporting_document.document.size, "type": "existing"}] ), - 'date_from': '2018-08-15', - 'date_to': '2019-08-15', - 'amount': invoice.amount, }, instance=invoice) self.assertTrue(form.is_valid()) @@ -424,9 +406,6 @@ class TestEditInvoiceForm(TestCase): data={ 'document': invoice.document, 'supporting_documents-uploads': '[]', - 'date_from': '2018-08-15', - 'date_to': '2019-08-15', - 'amount': invoice.amount, }, files={ 'supporting_documents': supporting_document, diff --git a/hypha/apply/projects/tests/test_views.py b/hypha/apply/projects/tests/test_views.py index 0575d7d673db6d5328fb9ee08445b9e67dbad2fe..9775b3b14a6bfe407871fd39b59157e7267b130d 100644 --- a/hypha/apply/projects/tests/test_views.py +++ b/hypha/apply/projects/tests/test_views.py @@ -814,9 +814,6 @@ class TestApplicantEditInvoiceView(BaseViewTestCase): self.assertTrue(invoice.supporting_documents.exists()) response = self.post_page(invoice, { - 'amount': invoice.amount, - 'date_from': '2018-08-15', - 'date_to': '2019-08-15', 'comment': 'test comment', 'invoice': '', 'supporting_documents-uploads': '[]', @@ -830,12 +827,7 @@ class TestApplicantEditInvoiceView(BaseViewTestCase): invoice = InvoiceFactory(project=project) supporting_document = SupportingDocumentFactory(invoice=invoice) - amount = invoice.amount - response = self.post_page(invoice, { - 'amount': amount + 1, - 'date_from': '2018-08-15', - 'date_to': '2019-08-15', 'comment': 'test comment', 'invoice': '', 'supporting_documents-uploads': json.dumps([{"name": supporting_document.document.name, "size": supporting_document.document.size, "type": "existing"}]), @@ -847,8 +839,6 @@ class TestApplicantEditInvoiceView(BaseViewTestCase): invoice.refresh_from_db() self.assertEqual(project.invoices.first().pk, invoice.pk) - - self.assertEqual(amount + Decimal("1"), invoice.amount) self.assertEqual(invoice.supporting_documents.first().document, supporting_document.document) @@ -868,9 +858,6 @@ class TestStaffEditInvoiceView(BaseViewTestCase): SupportingDocumentFactory(invoice=invoice) response = self.post_page(invoice, { - 'amount': invoice.amount, - 'date_from': '2018-08-15', - 'date_to': '2019-08-15', 'comment': 'test comment', 'invoice': '', 'supporting_documents-uploads': '[]', @@ -885,15 +872,10 @@ class TestStaffEditInvoiceView(BaseViewTestCase): invoice = InvoiceFactory(project=project) supporting_document = SupportingDocumentFactory(invoice=invoice) - amount = invoice.amount - document = BytesIO(b'somebinarydata') document.name = 'invoice.pdf' response = self.post_page(invoice, { - 'amount': amount + 1, - 'date_from': '2018-08-15', - 'date_to': '2019-08-15', 'comment': 'test comment', 'document': document, 'supporting_documents-uploads': json.dumps([{"name": supporting_document.document.name, "size": supporting_document.document.size, "type": "existing"}]), @@ -906,7 +888,6 @@ class TestStaffEditInvoiceView(BaseViewTestCase): self.assertEqual(project.invoices.first().pk, invoice.pk) - self.assertEqual(amount + Decimal("1"), invoice.amount) self.assertEqual(invoice.supporting_documents.first().document, supporting_document.document) diff --git a/hypha/apply/projects/views/payment.py b/hypha/apply/projects/views/payment.py index 74c464d5b6fd91ef94a404c68d014471984dce5f..c7f20fd13a9d706281d62cfe5640ba2164e316c5 100644 --- a/hypha/apply/projects/views/payment.py +++ b/hypha/apply/projects/views/payment.py @@ -273,6 +273,3 @@ class InvoiceListView(SingleTableMixin, FilterView): model = Invoice table_class = InvoiceListTable template_name = 'application_projects/invoice_list.html' - - def get_queryset(self): - return Invoice.objects.order_by('date_to') diff --git a/hypha/apply/projects/views/project.py b/hypha/apply/projects/views/project.py index 0bc20a25b5412743d83651d0da37320183d4bf33..66f2b283f5a1065fae3e26fcbf7b8858f73f1335 100644 --- a/hypha/apply/projects/views/project.py +++ b/hypha/apply/projects/views/project.py @@ -642,7 +642,7 @@ class ProjectOverviewView(TemplateView): } def get_invoices(self, request): - invoices = Invoice.objects.order_by('date_to')[:10] + invoices = Invoice.objects.order_by('-requested_at')[:10] return { 'filterset': InvoiceListFilter(request.GET or None, request=request, queryset=invoices),