From 30cf3bb382e81dfb43b63b5a09f2ac480a4386fb Mon Sep 17 00:00:00 2001 From: sandeepsajan0 <sandeepsajan0@gmail.com> Date: Fri, 18 Feb 2022 10:31:04 +0530 Subject: [PATCH] Remove reciept_path, add test for invoice deliverable total amount --- .../migrations/0014_add_payment_related_models.py | 2 +- hypha/apply/projects/models/payment.py | 4 ---- hypha/apply/projects/tests/test_models.py | 11 +++++++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/hypha/apply/projects/migrations/0014_add_payment_related_models.py b/hypha/apply/projects/migrations/0014_add_payment_related_models.py index b8bfe32af..6d250951a 100644 --- a/hypha/apply/projects/migrations/0014_add_payment_related_models.py +++ b/hypha/apply/projects/migrations/0014_add_payment_related_models.py @@ -28,7 +28,7 @@ class Migration(migrations.Migration): name='PaymentReceipt', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('file', models.FileField(storage=django.core.files.storage.FileSystemStorage(), upload_to=hypha.apply.projects.models.payment.receipt_path)), + ('file', models.FileField(storage=django.core.files.storage.FileSystemStorage())), ], ), migrations.CreateModel( diff --git a/hypha/apply/projects/models/payment.py b/hypha/apply/projects/models/payment.py index 21bd6d7aa..9315e0e32 100644 --- a/hypha/apply/projects/models/payment.py +++ b/hypha/apply/projects/models/payment.py @@ -59,10 +59,6 @@ def invoice_status_user_choices(user): return [] -def receipt_path(instance, filename): - return f'projects/{instance.project_id}/payment_invoices/{filename}' - - def invoice_path(instance, filename): return f'projects/{instance.project_id}/payment_invoices/{filename}' diff --git a/hypha/apply/projects/tests/test_models.py b/hypha/apply/projects/tests/test_models.py index 99a6b73c7..4ee923a46 100644 --- a/hypha/apply/projects/tests/test_models.py +++ b/hypha/apply/projects/tests/test_models.py @@ -32,7 +32,9 @@ from ..models.payment import ( from ..models.project import Project from ..models.report import Report, ReportConfig from .factories import ( + DeliverableFactory, DocumentCategoryFactory, + InvoiceDeliverableFactory, InvoiceFactory, PacketFileFactory, ProjectFactory, @@ -190,6 +192,15 @@ class TestInvoiceModel(TestCase): ) self.assertEqual(invoice.value, Decimal('2')) + def test_deliverables_total_amount(self): + deliverable = DeliverableFactory(unit_price=100) + invoice_deliverable = InvoiceDeliverableFactory(deliverable=deliverable, quantity=2) + self.assertEqual(invoice_deliverable.deliverable.unit_price, 100.00) + + invoice = InvoiceFactory(status=APPROVED_BY_STAFF) + invoice.deliverables.add(invoice_deliverable) + self.assertEqual(invoice.deliverables_total_amount['total'], 200.00) + def test_staff_can_change_status(self): statuses = [SUBMITTED, RESUBMITTED, CHANGES_REQUESTED_BY_STAFF, CHANGES_REQUESTED_BY_FINANCE_1] user = StaffFactory() -- GitLab