Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Update the item_tax to add is_charge_taxes_on_shipping as argument
Gabriel L Martinez6058237242ed
diff --git a/saleor/data_feeds/google_merchant.py b/saleor/data_feeds/google_merchant.pyindex 19473c2abe..01b5b71554 100644--- a/saleor/data_feeds/google_merchant.py+++ b/saleor/data_feeds/google_merchant.py@@ -42,8 +42,6 @@ ATTRIBUTES = ["description",]-IS_CHARGE_TAXES_ON_SHIPPING = False-def get_feed_file_url():return default_storage.url(FILE_PATH)@@ -120,7 +118,11 @@ def item_brand(item: ProductVariant, attributes_dict, attribute_values_dict):return brand-def item_tax(item: ProductVariant, discounts: Iterable[DiscountInfo]):+def item_tax(+ item: ProductVariant,+ discounts: Iterable[DiscountInfo],+ is_charge_taxes_on_shipping: bool+):"""Return item tax.For some countries you need to set tax info@@ -131,7 +133,7 @@ def item_tax(item: ProductVariant, discounts: Iterable[DiscountInfo]):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"+ tax_ship = "yes" if is_charge_taxes_on_shipping else "no"return "%s::%s:%s" % (country.code, tax_rate, tax_ship)@@ -190,6 +192,7 @@ def item_attributes(discounts: Iterable[DiscountInfo],attributes_dict,attribute_values_dict,+ is_charge_taxes_on_shipping: bool,):product_data = {"id": item_id(item),@@ -212,7 +215,7 @@ def item_attributes(if sale_price != price:product_data["sale_price"] = sale_price- tax = item_tax(item, discounts)+ tax = item_tax(item, discounts, is_charge_taxes_on_shipping)if tax:product_data["tax"] = tax@@ -225,7 +228,7 @@ def item_attributes(def write_feed(file_obj):"""Write feed contents info provided file object."""- IS_CHARGE_TAXES_ON_SHIPPING = charge_taxes_on_shipping()+ is_charge_taxes_on_shipping = charge_taxes_on_shipping()writer = csv.DictWriter(file_obj, ATTRIBUTES, dialect=csv.excel_tab)writer.writeheader()categories = Category.objects.all()@@ -245,6 +248,7 @@ 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 6053132d78..c85d22829b 100644--- a/saleor/data_feeds/tests/test_data_feeds.py+++ b/saleor/data_feeds/tests/test_data_feeds.py@@ -11,10 +11,12 @@ from ..google_merchant import (item_availability,item_google_product_category,write_feed,+ charge_taxes_on_shipping,)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@@ -34,6 +36,7 @@ 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"