Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Rollback to pass is_charge_taxes_on_shipping directly item_tax

Gabriel L Martinez3afd3e5ea4dd
diff --git a/saleor/data_feeds/google_merchant.py b/saleor/data_feeds/google_merchant.py
index b1d5ae7d79..21f7520652 100644
--- a/saleor/data_feeds/google_merchant.py
+++ b/saleor/data_feeds/google_merchant.py
@@ -10,6 +10,7 @@ from django.utils import timezone
from django.utils.encoding import smart_text
from django_countries.fields import Country
+from ..core.taxes import charge_taxes_on_shipping
from ..discount import DiscountInfo
from ..discount.utils import fetch_discounts
from ..plugins.manager import get_plugins_manager
@@ -118,7 +119,9 @@ def item_brand(item: ProductVariant, attributes_dict, attribute_values_dict):
def item_tax(
- item: ProductVariant, discounts: Iterable[DiscountInfo], current_site: Site,
+ item: ProductVariant,
+ discounts: Iterable[DiscountInfo],
+ is_charge_taxes_on_shipping: bool,
):
"""Return item tax.
@@ -131,7 +134,6 @@ def item_tax(
item.product.product_type, country
)
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 None
@@ -192,6 +194,7 @@ def item_attributes(
discounts: Iterable[DiscountInfo],
attributes_dict,
attribute_values_dict,
+ is_charge_taxes_on_shipping: bool,
):
product_data = {
"id": item_id(item),
@@ -214,7 +217,7 @@ def item_attributes(
if sale_price != price:
product_data["sale_price"] = sale_price
- tax = item_tax(item, discounts, current_site)
+ tax = item_tax(item, discounts, is_charge_taxes_on_shipping)
if tax:
product_data["tax"] = tax
@@ -227,6 +230,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()
writer = csv.DictWriter(file_obj, ATTRIBUTES, dialect=csv.excel_tab)
writer.writeheader()
categories = Category.objects.all()
@@ -246,6 +250,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.py
index 6053132d78..e303d0e2f5 100644
--- a/saleor/data_feeds/tests/test_data_feeds.py
+++ b/saleor/data_feeds/tests/test_data_feeds.py
@@ -4,6 +4,7 @@ from unittest.mock import Mock
from django.utils.encoding import smart_text
+from ...core.taxes import charge_taxes_on_shipping
from ...product.models import AttributeValue, Category
from ..google_merchant import (
get_feed_items,
@@ -15,6 +16,7 @@ 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
@@ -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.sku
assert attributes.get("availability") == "in stock"