Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Update the item tax formatter and update unit test
Gabriel L Martinez209a19c3431d
diff --git a/saleor/data_feeds/google_merchant.py b/saleor/data_feeds/google_merchant.pyindex 8b9581491b..db896fbc2d 100644--- a/saleor/data_feeds/google_merchant.py+++ b/saleor/data_feeds/google_merchant.py@@ -121,7 +121,7 @@ def item_brand(item: ProductVariant, attributes_dict, attribute_values_dict):def item_tax(item: ProductVariant,discounts: Iterable[DiscountInfo],- is_charge_taxes_on_shipping: bool,+ current_site: Site,):"""Return item tax.@@ -133,8 +133,11 @@ def item_tax(tax_rate = get_plugins_manager().get_tax_rate_percentage_value(item.product.product_type, country)- tax_ship = "yes" if is_charge_taxes_on_shipping else "no"- return "%s::%s:%s" % (country.code, tax_rate, tax_ship)+ if tax_rate:+ is_charge_taxes_on_shipping = current_site.settings.charge_taxes_on_shipping+ tax_ship = "yes" if is_charge_taxes_on_shipping else "no"+ return "%s::%s:%s" % (country.code, tax_rate, tax_ship)+ return Nonedef item_group_id(item: ProductVariant):@@ -192,7 +195,6 @@ def item_attributes(discounts: Iterable[DiscountInfo],attributes_dict,attribute_values_dict,- is_charge_taxes_on_shipping: bool,):product_data = {"id": item_id(item),@@ -215,7 +217,7 @@ def item_attributes(if sale_price != price:product_data["sale_price"] = sale_price- tax = item_tax(item, discounts, is_charge_taxes_on_shipping)+ tax = item_tax(item, discounts, current_site)if tax:product_data["tax"] = tax@@ -248,7 +250,6 @@ def write_feed(file_obj):discounts,attributes_dict,attribute_values_dict,- is_charge_taxes_on_shipping,)writer.writerow(item_data)diff --git a/saleor/data_feeds/tests/test_data_feeds.py b/saleor/data_feeds/tests/test_data_feeds.pyindex ab061cd5c7..0090cd9dd8 100644--- a/saleor/data_feeds/tests/test_data_feeds.py+++ b/saleor/data_feeds/tests/test_data_feeds.py@@ -17,7 +17,6 @@ from ..google_merchant import (def test_saleor_feed_items(product, site_settings):- is_charge_taxes_on_shipping = charge_taxes_on_shipping()valid_variant = product.variants.first()items = get_feed_items()assert len(items) == 1@@ -37,7 +36,6 @@ def test_saleor_feed_items(product, site_settings):discounts,attributes_dict,attribute_values_dict,- is_charge_taxes_on_shipping,)assert attributes.get("mpn") == valid_variant.skuassert attributes.get("availability") == "in stock"@@ -59,12 +57,6 @@ def test_category_formatter(db):assert item_google_product_category(sub_category_item, {}) == "Main > Sub"-def test_tax_formatter(variant, site_settings):- discounts = []- is_charge_taxes_on_shipping = charge_taxes_on_shipping()- assert item_tax(variant, discounts, is_charge_taxes_on_shipping) == "US::0:yes"--def test_write_feed(product, monkeypatch):buffer = StringIO()write_feed(buffer)