diff --git a/website_sale_aplicoop/tests/test_pricing_delegation.py b/website_sale_aplicoop/tests/test_pricing_delegation.py index 1481511..47b067d 100644 --- a/website_sale_aplicoop/tests/test_pricing_delegation.py +++ b/website_sale_aplicoop/tests/test_pricing_delegation.py @@ -129,6 +129,67 @@ class TestStandardPricelistResolution(PricingDelegationCommon, TransactionCase): self.assertEqual(resolved, expected) +@tagged("post_install", "-at_install") +class TestTaxDisplayFollowsTheWebsite(PricingDelegationCommon, TransactionCase): + """Displayed prices honour the website's `Display Product Prices`. + + Eskaera used to hardcode the tax-included display and ignore the setting. + Now it follows website_sale, which means a website left on the Odoo default + (`tax_excluded`) shows prices without VAT -- correct, but surprising enough + to be worth pinning down here. + """ + + def setUp(self): + super().setUp() + self.pricelist = self._create_pricelist("Display PL") + self.tax_21 = self._create_tax("IVA 21%", 21.0) + self.product = self._create_product("Display Product", 100.0, self.tax_21) + + def _price(self): + return self.controller._get_pricing_info( + self.product, self.pricelist, quantity=1.0 + ) + + def test_gross_price_on_a_tax_included_website(self): + """A consumer-facing website quotes what the member pays.""" + self.website.show_line_subtotals_tax_selection = "tax_included" + + pricing = self._price() + + self.assertAlmostEqual(pricing["price"], 121.0, places=2) + self.assertAlmostEqual(pricing["price_unit"], 100.0, places=2) + self.assertTrue(pricing["tax_included"]) + + def test_net_price_on_a_tax_excluded_website(self): + """A website set to tax-excluded shows the net price.""" + self.website.show_line_subtotals_tax_selection = "tax_excluded" + + pricing = self._price() + + self.assertAlmostEqual(pricing["price"], 100.0, places=2) + self.assertAlmostEqual(pricing["price_unit"], 100.0, places=2) + self.assertFalse(pricing["tax_included"]) + + def test_the_setting_is_what_moves_the_price(self): + """Nothing but the website setting changes between the two.""" + self.website.show_line_subtotals_tax_selection = "tax_included" + gross = self._price()["price"] + + self.website.show_line_subtotals_tax_selection = "tax_excluded" + net = self._price()["price"] + + self.assertAlmostEqual(gross - net, 21.0, places=2) + + def test_batched_listing_follows_the_same_setting(self): + """The listing path must not disagree with the single-product one.""" + self.website.show_line_subtotals_tax_selection = "tax_excluded" + + batched = self.controller._compute_price_info(self.product, self.pricelist) + + self.assertAlmostEqual(batched[self.product.id]["price"], 100.0, places=2) + self.assertFalse(batched[self.product.id]["tax_included"]) + + @tagged("post_install", "-at_install") class TestTaxIncludedFiscalPosition(PricingDelegationCommon, TransactionCase): """A remapped tax-included tax must rebase the displayed price.""" diff --git a/website_sale_aplicoop/views/res_config_settings_views.xml b/website_sale_aplicoop/views/res_config_settings_views.xml index b64d3da..a289fa4 100644 --- a/website_sale_aplicoop/views/res_config_settings_views.xml +++ b/website_sale_aplicoop/views/res_config_settings_views.xml @@ -21,6 +21,21 @@ +
+
+
+
+

Shop Performance