From e5f99efbf6924968996ff9b3b46cda1f777fe55d Mon Sep 17 00:00:00 2001 From: Ivo Branco Date: Fri, 26 Jul 2024 13:45:17 +0100 Subject: [PATCH] feat(financial manager): no longer send excl vat tax fields On financial manager integration, no longer send the exclude vat tax fields. related to: fccn/nau-technical#215 --- README.rst | 3 -- nau_extensions/financial_manager.py | 6 ---- nau_extensions/strategy.py | 22 -------------- .../tests/test_financial_manager.py | 29 ++---------------- nau_extensions/tests/test_vat.py | 30 ------------------- 5 files changed, 2 insertions(+), 88 deletions(-) delete mode 100644 nau_extensions/strategy.py delete mode 100644 nau_extensions/tests/test_vat.py diff --git a/README.rst b/README.rst index 63c3a48..7a585ec 100644 --- a/README.rst +++ b/README.rst @@ -22,9 +22,6 @@ edit the `ecommerce/settings/private.py` file add change to:: ) LOGO_URL = "https://lms.nau.edu.pt/static/nau-basic/images/nau_azul.svg" - # Configure tax as 23% used in Portugal - NAU_EXTENSION_TAX_RATE = "0.298701299" # = 0.23/0.77 - NAU_FINANCIAL_MANAGER = { "edx": { "url": "http://financial-manager.local.nau.fccn.pt:8000/api/billing/transaction-complete/", diff --git a/nau_extensions/financial_manager.py b/nau_extensions/financial_manager.py index cf2f930..daf0aeb 100644 --- a/nau_extensions/financial_manager.py +++ b/nau_extensions/financial_manager.py @@ -83,10 +83,8 @@ def sync_request_data(bti: BasketTransactionIntegration) -> dict: "country_code": country_code, "vat_identification_number": vat_identification_number, "vat_identification_country": vat_identification_country, - "total_amount_exclude_vat": order.total_excl_tax, "total_amount_include_vat": order.total_incl_tax, "total_discount_incl_tax": order.total_discount_incl_tax, - "total_discount_excl_tax": order.total_discount_excl_tax, "currency": order.currency, "payment_type": _get_payment_type(order), "items": _convert_order_lines(order), @@ -119,15 +117,11 @@ def _convert_order_lines(order): course_key = CourseKey.from_string(course.id) if course else None organization_code = course_key.org if course else None product_code = course_key.course if course else None - unit_price_excl_tax = line.unit_price_excl_tax unit_price_incl_tax = line.unit_price_incl_tax - vat_tax = unit_price_incl_tax - unit_price_excl_tax result.append( { "description": line.title, "quantity": line.quantity, - "vat_tax": vat_tax, - "unit_price_excl_vat": unit_price_excl_tax, "unit_price_incl_vat": unit_price_incl_tax, "organization_code": organization_code, "product_code": product_code, diff --git a/nau_extensions/strategy.py b/nau_extensions/strategy.py deleted file mode 100644 index 98f6d80..0000000 --- a/nau_extensions/strategy.py +++ /dev/null @@ -1,22 +0,0 @@ -""" -Django Oscar strategy for fixed rate tax. -Use a fixed rate tax read from a setting. -""" - -from decimal import Decimal as D - -from django.conf import settings -from oscar.apps.partner import strategy - - -class SettingFixedRateTax(strategy.FixedRateTax): - """ - A custom rate tax that loads a fixed value from a setting. - This means that everything we sell has a fixed VAT value. - """ - - def get_rate(self, product, stockrecord): - """ - The rate VAT that all products have. - """ - return D(getattr(settings, "NAU_EXTENSION_TAX_RATE", 0)) diff --git a/nau_extensions/tests/test_financial_manager.py b/nau_extensions/tests/test_financial_manager.py index 1713673..53184dc 100644 --- a/nau_extensions/tests/test_financial_manager.py +++ b/nau_extensions/tests/test_financial_manager.py @@ -91,16 +91,13 @@ def test_financial_manager_sync_data_basic(self): "country_code": "PT", "vat_identification_number": "123456789", "vat_identification_country": "PT", - "total_amount_exclude_vat": Decimal("30.00"), "total_amount_include_vat": Decimal("30.00"), - "total_discount_excl_tax": Decimal('0.00'), "total_discount_incl_tax": Decimal('0.00'), "currency": "EUR", "payment_type": None, "items": [ # verified { - "unit_price_excl_vat": Decimal("10.00"), "unit_price_incl_vat": Decimal("10.00"), "description": "Seat in edX Demonstration Course with verified certificate", 'discount_excl_tax': Decimal('0.00'), @@ -109,11 +106,9 @@ def test_financial_manager_sync_data_basic(self): "product_code": "DemoX", "product_id": "course-v1:edX+DemoX+Demo_Course", "quantity": 3, - "vat_tax": Decimal("0.00"), }, # honor { - "unit_price_excl_vat": Decimal("0.00"), "unit_price_incl_vat": Decimal("0.00"), "description": "Seat in edX Demonstration Course with honor certificate", 'discount_excl_tax': Decimal('0.00'), @@ -122,7 +117,6 @@ def test_financial_manager_sync_data_basic(self): "product_code": "DemoX", "product_id": "course-v1:edX+DemoX+Demo_Course", "quantity": 2, - "vat_tax": Decimal("0.00"), }, ], }, @@ -192,16 +186,13 @@ def test_financial_manager_sync_data_with_quantity(self): "country_code": "PT", "vat_identification_number": "123456789", "vat_identification_country": "PT", - "total_amount_exclude_vat": Decimal("10.00"), "total_amount_include_vat": Decimal("10.00"), - "total_discount_excl_tax": Decimal('0.00'), "total_discount_incl_tax": Decimal('0.00'), "currency": "EUR", "payment_type": None, "items": [ # verified { - "unit_price_excl_vat": Decimal("10.00"), "unit_price_incl_vat": Decimal("10.00"), "description": "Seat in edX Demonstration Course with verified certificate", 'discount_excl_tax': Decimal('0.00'), @@ -210,11 +201,9 @@ def test_financial_manager_sync_data_with_quantity(self): "product_code": "DemoX", "product_id": "course-v1:edX+DemoX+Demo_Course", "quantity": 1, - "vat_tax": Decimal("0.00"), }, # honor { - "unit_price_excl_vat": Decimal("0.00"), "unit_price_incl_vat": Decimal("0.00"), "description": "Seat in edX Demonstration Course with honor certificate", 'discount_excl_tax': Decimal('0.00'), @@ -223,14 +212,12 @@ def test_financial_manager_sync_data_with_quantity(self): "product_code": "DemoX", "product_id": "course-v1:edX+DemoX+Demo_Course", "quantity": 1, - "vat_tax": Decimal("0.00"), }, ], }, ) @override_settings( - NAU_EXTENSION_TAX_RATE="0.298701299", # = 0.23/0.77, OSCAR_DEFAULT_CURRENCY="EUR" ) def test_financial_manager_sync_data_with_tax_rate(self): @@ -294,17 +281,14 @@ def test_financial_manager_sync_data_with_tax_rate(self): "country_code": "PT", "vat_identification_number": "123456789", "vat_identification_country": "PT", - "total_amount_exclude_vat": Decimal("10.00"), - "total_amount_include_vat": Decimal("12.99"), - "total_discount_excl_tax": Decimal('0.00'), + "total_amount_include_vat": Decimal("10.00"), "total_discount_incl_tax": Decimal('0.00'), "currency": "EUR", "payment_type": None, "items": [ # verified { - "unit_price_excl_vat": Decimal("10.00"), - "unit_price_incl_vat": Decimal("12.99"), + "unit_price_incl_vat": Decimal("10.00"), "description": "Seat in edX Demonstration Course with verified certificate", 'discount_excl_tax': Decimal('0.00'), 'discount_incl_tax': Decimal('0.00'), @@ -312,11 +296,9 @@ def test_financial_manager_sync_data_with_tax_rate(self): "product_code": "DemoX", "product_id": "course-v1:edX+DemoX+Demo_Course", "quantity": 1, - "vat_tax": Decimal("2.99"), }, # honor { - "unit_price_excl_vat": Decimal("0.00"), "unit_price_incl_vat": Decimal("0.00"), "description": "Seat in edX Demonstration Course with honor certificate", 'discount_excl_tax': Decimal('0.00'), @@ -325,7 +307,6 @@ def test_financial_manager_sync_data_with_tax_rate(self): "product_code": "DemoX", "product_id": "course-v1:edX+DemoX+Demo_Course", "quantity": 1, - "vat_tax": Decimal("0.00"), }, ], }, @@ -381,16 +362,13 @@ def test_financial_manager_sync_data_without_bbi(self): "country_code": None, "vat_identification_number": None, "vat_identification_country": None, - "total_amount_exclude_vat": Decimal("10.00"), "total_amount_include_vat": Decimal("10.00"), - "total_discount_excl_tax": Decimal("0.00"), "total_discount_incl_tax": Decimal("0.00"), "currency": "EUR", "payment_type": None, "items": [ # verified { - "unit_price_excl_vat": Decimal("10.00"), "unit_price_incl_vat": Decimal("10.00"), "description": "Seat in edX Demonstration Course with verified certificate", "discount_excl_tax": Decimal("0.00"), @@ -399,11 +377,9 @@ def test_financial_manager_sync_data_without_bbi(self): "product_code": "DemoX", "product_id": "course-v1:edX+DemoX+Demo_Course", "quantity": 1, - "vat_tax": Decimal("0.00"), }, # honor { - "unit_price_excl_vat": Decimal("0.00"), "unit_price_incl_vat": Decimal("0.00"), "description": "Seat in edX Demonstration Course with honor certificate", "discount_excl_tax": Decimal("0.00"), @@ -412,7 +388,6 @@ def test_financial_manager_sync_data_without_bbi(self): "product_code": "DemoX", "product_id": "course-v1:edX+DemoX+Demo_Course", "quantity": 1, - "vat_tax": Decimal("0.00"), }, ], }, diff --git a/nau_extensions/tests/test_vat.py b/nau_extensions/tests/test_vat.py deleted file mode 100644 index a5e006d..0000000 --- a/nau_extensions/tests/test_vat.py +++ /dev/null @@ -1,30 +0,0 @@ -from decimal import Decimal - -from django.test import override_settings -from nau_extensions.tests.factories import create_basket - -from ecommerce.extensions.partner.strategy import DefaultStrategy -from ecommerce.tests.testcases import TestCase - - -@override_settings( - NAU_EXTENSION_TAX_RATE="0.298701299", # = 0.23/0.77 -) -class VATNAUExtensionsTests(TestCase): - """ - This class aims to test the VAT customization required by NAU. - """ - - def test_vat_tax(self): - """ - Test that the VAT tax extension is applied on Django Oscar strategy. - """ - self.assertEqual(DefaultStrategy().get_rate(None, None), Decimal("0.298701299")) - - def test_basket_with_vat_tax(self): - """ - Test that VAT tax value is applied on a basket. - """ - basket = create_basket(price="15.40") - self.assertEqual(basket.total_excl_tax, round(Decimal(15.40), 2)) - self.assertEqual(basket.total_incl_tax, round(Decimal(20.00), 2))