Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove some saleor's dependencies from plugins
Maciej Korycinski4d0c18c79688
diff --git a/saleor/core/extensions/manager.py b/saleor/core/extensions/manager.pyindex 5e42782a6c..ce25d01942 100644--- a/saleor/core/extensions/manager.py+++ b/saleor/core/extensions/manager.py@@ -8,11 +8,11 @@ from prices import Money, MoneyRange, TaxedMoney, TaxedMoneyRangefrom ..taxes import TaxType, quantize_priceif TYPE_CHECKING:+ from .plugin import BasePluginfrom ...checkout.models import Checkout, CheckoutLinefrom ...product.models import Productfrom ...account.models import Addressfrom ...order.models import OrderLine, Order- from .plugin import BasePluginclass ExtensionsManager:diff --git a/saleor/core/extensions/plugins/avatax/__init__.py b/saleor/core/extensions/plugins/avatax/__init__.pyindex 64472f320e..0bd31d70bd 100644--- a/saleor/core/extensions/plugins/avatax/__init__.py+++ b/saleor/core/extensions/plugins/avatax/__init__.py@@ -6,13 +6,11 @@ from urllib.parse import urljoinimport requestsfrom django.conf import settings+from django.contrib.sites.models import Sitefrom django.core.cache import cachefrom django.utils.translation import pgettext_lazyfrom requests.auth import HTTPBasicAuth-from ....taxes import charge_taxes_on_shipping, include_taxes_in_prices-from ....utils import get_company_address # FIXME shouldn't use logic from saleor-if TYPE_CHECKING:from .....checkout.models import Checkoutfrom .....order.models import Order@@ -171,7 +169,7 @@ def append_line_to_data(tax_included: Optional[bool] = None,):if tax_included is None:- tax_included = include_taxes_in_prices()+ tax_included = Site.objects.get_current().settings.include_taxes_in_pricesdata.append({"quantity": quantity,@@ -210,7 +208,10 @@ def get_checkout_lines_data(description=description,)- if charge_taxes_on_shipping() and checkout.shipping_method:+ charge_taxes_on_shipping = (+ Site.objects.get_current().settings.charge_taxes_on_shipping+ )+ if charge_taxes_on_shipping and checkout.shipping_method:append_line_to_data(data,quantity=1,@@ -253,7 +254,10 @@ def get_order_lines_data(order: "Order") -> List[Dict[str, str]]:description=order.discount_name,tax_included=True, # Voucher should be always applied as a gross amount)- if charge_taxes_on_shipping() and order.shipping_method:+ charge_taxes_on_shipping = (+ Site.objects.get_current().settings.charge_taxes_on_shipping+ )+ if charge_taxes_on_shipping and order.shipping_method:append_line_to_data(data,quantity=1,@@ -274,7 +278,7 @@ def generate_request_data(commit=False,currency=settings.DEFAULT_CURRENCY,):- company_address = get_company_address()+ company_address = Site.objects.get_current().settings.company_addressif company_address:company_address = company_address.as_data()else:diff --git a/saleor/core/extensions/plugins/avatax/plugin.py b/saleor/core/extensions/plugins/avatax/plugin.pyindex e7c7891613..8b0eadcd48 100644--- a/saleor/core/extensions/plugins/avatax/plugin.py+++ b/saleor/core/extensions/plugins/avatax/plugin.py@@ -6,7 +6,6 @@ from urllib.parse import urljoinfrom django.conf import settingsfrom prices import Money, TaxedMoney, TaxedMoneyRange-from .....checkout import models as checkout_modelsfrom ....taxes import TaxType, zero_taxed_moneyfrom ....taxes.errors import TaxErrorfrom ...plugin import BasePlugin@@ -26,7 +25,7 @@ from . import (from .tasks import api_post_request_taskif TYPE_CHECKING:- from .....checkout.models import Checkout+ from .....checkout.models import Checkout, CheckoutLinefrom .....order.models import Order, OrderLinelogger = logging.getLogger(__name__)@@ -56,7 +55,7 @@ class AvataxPlugin(BasePlugin):def calculate_checkout_total(self,- checkout: "checkout_models.Checkout",+ checkout: "Checkout",discounts: List["DiscountInfo"],previous_value: TaxedMoney,) -> TaxedMoney:@@ -83,7 +82,7 @@ class AvataxPlugin(BasePlugin):def calculate_checkout_subtotal(self,- checkout: "checkout_models.Checkout",+ checkout: "Checkout",discounts: List["DiscountInfo"],previous_value: TaxedMoney,) -> TaxedMoney:@@ -114,7 +113,7 @@ class AvataxPlugin(BasePlugin):def calculate_checkout_shipping(self,- checkout: "checkout_models.Checkout",+ checkout: "Checkout",discounts: List["DiscountInfo"],previous_value: TaxedMoney,) -> TaxedMoney:@@ -182,7 +181,7 @@ class AvataxPlugin(BasePlugin):def calculate_checkout_line_total(self,- checkout_line: "checkout_models.CheckoutLine",+ checkout_line: "CheckoutLine",discounts: List["DiscountInfo"],previous_value: TaxedMoney,) -> TaxedMoney: