Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove explicit currency= when instantiating Money objects
Rafał Pitońb72dd5a731b5
diff --git a/docs/architecture/money.rst b/docs/architecture/money.rstindex c857ba78ae..9dfcbe54ad 100644--- a/docs/architecture/money.rst+++ b/docs/architecture/money.rst@@ -17,7 +17,7 @@ Money and TaxedMoneyIn Saleor's codebase, money amounts exist either as `Money` or `TaxedMoney` instances.-`Money` is a type representing amount of money in specific currency: 100 USD is represented by `Money(100, currency='USD')`. This type doesn't hold any additional information useful for commerce but, unlike `Decimal`, it implements safeguards and checks for calculations and comparisions of monetary values. Money amounts are stored on model using `MoneyField` that provides its own safechecks on currency and precision of stored amount. If you ever need to get to the `Decimal` of your `Money` object, you'll find it on the `amount` property.+`Money` is a type representing amount of money in specific currency: 100 USD is represented by `Money(100, 'USD')`. This type doesn't hold any additional information useful for commerce but, unlike `Decimal`, it implements safeguards and checks for calculations and comparisions of monetary values. Money amounts are stored on model using `MoneyField` that provides its own safechecks on currency and precision of stored amount. If you ever need to get to the `Decimal` of your `Money` object, you'll find it on the `amount` property.Products and shipping methods prices are stored using `MoneyField` and are assumed to be gross amounts. Those amounts are then naively converted to `TaxedMoney` objects using the `TaxedAmount(net=item.price, gross=item.price)` approach with conversion happening before resolving item's final price (before taxes and discounts).diff --git a/saleor/checkout/core.py b/saleor/checkout/core.pyindex 9b5ef07873..e6eaa4e698 100644--- a/saleor/checkout/core.py+++ b/saleor/checkout/core.py@@ -216,7 +216,7 @@ class Checkout:value = self.storage.get('discount_value')currency = self.storage.get('discount_currency')if value is not None and currency is not None:- return Money(value, currency=currency)+ return Money(value, currency)return None@discount.setter@@ -319,8 +319,8 @@ class Checkout:shipping_price = self.shipping_method.get_total_price()else:shipping_price = TaxedMoney(- net=Money(0, currency=settings.DEFAULT_CURRENCY),- gross=Money(0, currency=settings.DEFAULT_CURRENCY))+ net=Money(0, settings.DEFAULT_CURRENCY),+ gross=Money(0, settings.DEFAULT_CURRENCY))order_data = {'language_code': get_language(),diff --git a/saleor/core/utils/__init__.py b/saleor/core/utils/__init__.pyindex 5f3479719b..e8c0fdbe60 100644--- a/saleor/core/utils/__init__.py+++ b/saleor/core/utils/__init__.py@@ -19,8 +19,8 @@ from prices import Money, TaxedMoney, MoneyRangefrom ...account.models import UserZERO_TAXED_MONEY = TaxedMoney(- net=Money(0, currency=settings.DEFAULT_CURRENCY),- gross=Money(0, currency=settings.DEFAULT_CURRENCY))+ net=Money(0, settings.DEFAULT_CURRENCY),+ gross=Money(0, settings.DEFAULT_CURRENCY))georeader = geolite2.reader()diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.pyindex 9a47c5a337..48cbde7767 100644--- a/saleor/core/utils/random_data.py+++ b/saleor/core/utils/random_data.py@@ -230,8 +230,7 @@ def create_products_by_schema(placeholder_dir, how_many, create_images,class SaleorProvider(BaseProvider):def money(self):return Money(- fake.pydecimal(2, 2, positive=True),- currency=settings.DEFAULT_CURRENCY)+ fake.pydecimal(2, 2, positive=True), settings.DEFAULT_CURRENCY)def delivery_region(self):return random.choice(DELIVERY_REGIONS)diff --git a/saleor/dashboard/discount/forms.py b/saleor/dashboard/discount/forms.pyindex a39530bad8..6509e008dc 100644--- a/saleor/dashboard/discount/forms.py+++ b/saleor/dashboard/discount/forms.py@@ -108,7 +108,7 @@ def country_choices():class ShippingVoucherForm(forms.ModelForm):limit = MoneyField(- min_value=Money(0, currency=settings.DEFAULT_CURRENCY),+ min_value=Money(0, settings.DEFAULT_CURRENCY),required=False, currency=settings.DEFAULT_CURRENCY)apply_to = forms.ChoiceField(choices=country_choices,@@ -134,7 +134,7 @@ class ShippingVoucherForm(forms.ModelForm):class ValueVoucherForm(forms.ModelForm):limit = MoneyField(- min_value=Money(0, currency=settings.DEFAULT_CURRENCY),+ min_value=Money(0, settings.DEFAULT_CURRENCY),required=False, currency=settings.DEFAULT_CURRENCY)class Meta:diff --git a/saleor/discount/models.py b/saleor/discount/models.pyindex 5f5bf5d1c3..6ba002992f 100644--- a/saleor/discount/models.py+++ b/saleor/discount/models.py@@ -113,7 +113,7 @@ class Voucher(models.Model):def get_discount(self):if self.discount_value_type == DiscountValueType.FIXED:discount_amount = Money(- self.discount_value, currency=settings.DEFAULT_CURRENCY)+ self.discount_value, settings.DEFAULT_CURRENCY)return partial(fixed_discount, discount=discount_amount)if self.discount_value_type == DiscountValueType.PERCENTAGE:return partial(percentage_discount, percentage=self.discount_value)@@ -162,8 +162,7 @@ class Sale(models.Model):def get_discount(self):if self.type == DiscountValueType.FIXED:- discount_amount = Money(- self.value, currency=settings.DEFAULT_CURRENCY)+ discount_amount = Money(self.value, settings.DEFAULT_CURRENCY)return partial(fixed_discount, discount=discount_amount)if self.type == DiscountValueType.PERCENTAGE:return partial(percentage_discount, percentage=self.value)diff --git a/saleor/discount/templatetags/voucher.py b/saleor/discount/templatetags/voucher.pyindex c3460c4797..03476ae211 100644--- a/saleor/discount/templatetags/voucher.py+++ b/saleor/discount/templatetags/voucher.py@@ -7,5 +7,5 @@ register = template.Library()@register.simple_tagdef discount_as_negative(discount, html=False):- zero = Money(0, currency=discount.currency)+ zero = Money(0, discount.currency)return prices_i18n.amount(zero - discount, 'html' if html else 'text')diff --git a/saleor/discount/utils.py b/saleor/discount/utils.pyindex f56bab3b61..16abe8d323 100644--- a/saleor/discount/utils.py+++ b/saleor/discount/utils.py@@ -115,7 +115,7 @@ def _get_product_or_category_voucher_discount_for_checkout(voucher, checkout):discounts = (voucher.get_discount_amount_for(price) for price in prices)total_amount = sum(- discounts, Money(0, currency=settings.DEFAULT_CURRENCY))+ discounts, Money(0, settings.DEFAULT_CURRENCY))return total_amountproduct_total = sum(prices, ZERO_TAXED_MONEY)return voucher.get_discount_amount_for(product_total)diff --git a/saleor/order/models.py b/saleor/order/models.pyindex c85b0b44a8..5143c3c024 100644--- a/saleor/order/models.py+++ b/saleor/order/models.py@@ -102,8 +102,8 @@ class Order(models.Model):payment.get_total_price() for payment inself.payments.filter(status=PaymentStatus.CONFIRMED)],TaxedMoney(- net=Money(0, currency=settings.DEFAULT_CURRENCY),- gross=Money(0, currency=settings.DEFAULT_CURRENCY)))+ net=Money(0, settings.DEFAULT_CURRENCY),+ gross=Money(0, settings.DEFAULT_CURRENCY)))return total_paid.gross >= self.total.grossdef get_user_current_email(self):@@ -313,13 +313,13 @@ class Payment(BasePayment):def get_total_price(self):return TaxedMoney(- net=Money(self.total - self.tax, currency=self.currency),- gross=Money(self.total, currency=self.currency))+ net=Money(self.total - self.tax, self.currency),+ gross=Money(self.total, self.currency))def get_captured_price(self):return TaxedMoney(- net=Money(self.captured_amount, currency=self.currency),- gross=Money(self.captured_amount, currency=self.currency))+ net=Money(self.captured_amount, self.currency),+ gross=Money(self.captured_amount, self.currency))class OrderHistoryEntry(models.Model):diff --git a/saleor/product/models.py b/saleor/product/models.pyindex 8a79a33582..ac639ed348 100644--- a/saleor/product/models.py+++ b/saleor/product/models.py@@ -264,7 +264,7 @@ class ProductVariant(models.Model):stock = [stock_item for stock_item in self.stock.all()if stock_item.quantity_available >= quantity]- zero_price = Money(0, currency=settings.DEFAULT_CURRENCY)+ zero_price = Money(0, settings.DEFAULT_CURRENCY)stock = sorted(stock, key=(lambda s: s.cost_price or zero_price), reverse=False)if stock:diff --git a/tests/conftest.py b/tests/conftest.pyindex a72cad628f..6b2399ab33 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -242,7 +242,7 @@ def product_in_stock(product_type, default_category):attributes = {smart_text(product_attr.pk): smart_text(attr_value.pk)}product = Product.objects.create(- name='Test product', price=Money('10.00', currency='USD'),+ name='Test product', price=Money('10.00', 'USD'),product_type=product_type, attributes=attributes,category=default_category)@@ -257,14 +257,14 @@ def product_in_stock(product_type, default_category):warehouse_2 = StockLocation.objects.create(name='Warehouse 2')warehouse_3 = StockLocation.objects.create(name='Warehouse 3')Stock.objects.create(- variant=variant, cost_price=Money('1.00', currency='USD'),- quantity=5, quantity_allocated=5, location=warehouse_1)+ variant=variant, cost_price=Money('1.00', 'USD'), quantity=5,+ quantity_allocated=5, location=warehouse_1)Stock.objects.create(- variant=variant, cost_price=Money('100.00', currency='USD'),- quantity=5, quantity_allocated=5, location=warehouse_2)+ variant=variant, cost_price=Money('100.00', 'USD'), quantity=5,+ quantity_allocated=5, location=warehouse_2)Stock.objects.create(- variant=variant, cost_price=Money('10.00', currency='USD'),- quantity=5, quantity_allocated=0, location=warehouse_3)+ variant=variant, cost_price=Money('10.00', 'USD'), quantity=5,+ quantity_allocated=0, location=warehouse_3)return product@@ -274,7 +274,7 @@ def product_without_shipping(default_category):name='Type with no shipping', has_variants=False,is_shipping_required=False)product = Product.objects.create(- name='Test product', price=Money('10.00', currency='USD'),+ name='Test product', price=Money('10.00', 'USD'),product_type=product_type, category=default_category)ProductVariant.objects.create(product=product, sku='SKU_B')return product@@ -287,17 +287,17 @@ def product_list(product_type, default_category):attributes = {smart_text(product_attr.pk): smart_text(attr_value.pk)}product_1 = Product.objects.create(- name='Test product 1', price=Money('10.00', currency='USD'),+ name='Test product 1', price=Money('10.00', 'USD'),product_type=product_type, attributes=attributes, is_published=True,category=default_category)product_2 = Product.objects.create(- name='Test product 2', price=Money('20.00', currency='USD'),+ name='Test product 2', price=Money('20.00', 'USD'),product_type=product_type, attributes=attributes, is_published=False,category=default_category)product_3 = Product.objects.create(- name='Test product 3', price=Money('20.00', currency='USD'),+ name='Test product 3', price=Money('20.00', 'USD'),product_type=product_type, attributes=attributes, is_published=True,category=default_category)@@ -308,9 +308,8 @@ def product_list(product_type, default_category):def order_list(admin_user, billing_address):data = {'billing_address': billing_address, 'user': admin_user,- 'user_email': admin_user.email,- 'total_net': Money(123, currency='USD'),- 'total_gross': Money(123, currency='USD')}+ 'user_email': admin_user.email, 'total_net': Money(123, 'USD'),+ 'total_gross': Money(123, 'USD')}order = Order.objects.create(**data)order1 = Order.objects.create(**data)order2 = Order.objects.create(**data)@@ -342,7 +341,7 @@ def product_with_image(product_in_stock, product_image):@pytest.fixturedef unavailable_product(product_type, default_category):product = Product.objects.create(- name='Test product', price=Money('10.00', currency='USD'),+ name='Test product', price=Money('10.00', 'USD'),product_type=product_type, is_published=False,category=default_category)return product@@ -351,7 +350,7 @@ def unavailable_product(product_type, default_category):@pytest.fixturedef product_with_images(product_type, default_category):product = Product.objects.create(- name='Test product', price=Money('10.00', currency='USD'),+ name='Test product', price=Money('10.00', 'USD'),product_type=product_type, category=default_category)file_mock_0 = MagicMock(spec=File, name='FileMock0')file_mock_0.name = 'image0.jpg'@@ -376,7 +375,7 @@ def voucher(db): # pylint: disable=W0613def order_with_lines(order, product_type, default_category):group = DeliveryGroup.objects.create(order=order)product = Product.objects.create(- name='Test product', price=Money('10.00', currency='USD'),+ name='Test product', price=Money('10.00', 'USD'),product_type=product_type, category=default_category)OrderLine.objects.create(@@ -389,7 +388,7 @@ def order_with_lines(order, product_type, default_category):unit_price_net=Decimal('10.00'),unit_price_gross=Decimal('10.00'))product = Product.objects.create(- name='Test product 2', price=Money('20.00', currency='USD'),+ name='Test product 2', price=Money('20.00', 'USD'),product_type=product_type, category=default_category)OrderLine.objects.create(@@ -402,7 +401,7 @@ def order_with_lines(order, product_type, default_category):unit_price_net=Decimal('20.00'),unit_price_gross=Decimal('20.00'))product = Product.objects.create(- name='Test product 3', price=Money('30.00', currency='USD'),+ name='Test product 3', price=Money('30.00', 'USD'),product_type=product_type, category=default_category)OrderLine.objects.create(@@ -423,13 +422,13 @@ def order_with_lines(order, product_type, default_category):def order_with_lines_and_stock(order, product_type, default_category):group = DeliveryGroup.objects.create(order=order)product = Product.objects.create(- name='Test product', price=Money('10.00', currency='USD'),+ name='Test product', price=Money('10.00', 'USD'),product_type=product_type, category=default_category)variant = ProductVariant.objects.create(product=product, sku='SKU_A')warehouse = StockLocation.objects.create(name='Warehouse 1')stock = Stock.objects.create(- variant=variant, cost_price=Money(1, currency='USD'),- quantity=5, quantity_allocated=3, location=warehouse)+ variant=variant, cost_price=Money(1, 'USD'), quantity=5,+ quantity_allocated=3, location=warehouse)OrderLine.objects.create(delivery_group=group,product=product,@@ -442,12 +441,12 @@ def order_with_lines_and_stock(order, product_type, default_category):stock=stock,stock_location=stock.location.name)product = Product.objects.create(- name='Test product 2', price=Money('20.00', currency='USD'),+ name='Test product 2', price=Money('20.00', 'USD'),product_type=product_type, category=default_category)variant = ProductVariant.objects.create(product=product, sku='SKU_B')stock = Stock.objects.create(- variant=variant, cost_price=Money(2, currency='USD'),- quantity=2, quantity_allocated=2, location=warehouse)+ variant=variant, cost_price=Money(2, 'USD'), quantity=2,+ quantity_allocated=2, location=warehouse)OrderLine.objects.create(delivery_group=group,product=product,@@ -470,8 +469,8 @@ def order_with_variant_from_different_stocks(order_with_lines_and_stock):variant = ProductVariant.objects.get(sku=line.product_sku)warehouse_2 = StockLocation.objects.create(name='Warehouse 2')stock = Stock.objects.create(- variant=variant, cost_price=Money(1, currency='USD'),- quantity=5, quantity_allocated=2, location=warehouse_2)+ variant=variant, cost_price=Money(1, 'USD'), quantity=5,+ quantity_allocated=2, location=warehouse_2)OrderLine.objects.create(delivery_group=line.delivery_group,product=variant.product,@@ -485,8 +484,8 @@ def order_with_variant_from_different_stocks(order_with_lines_and_stock):stock_location=stock.location.name)warehouse_2 = StockLocation.objects.create(name='Warehouse 3')Stock.objects.create(- variant=variant, cost_price=Money(1, currency='USD'),- quantity=5, quantity_allocated=0, location=warehouse_2)+ variant=variant, cost_price=Money(1, 'USD'), quantity=5,+ quantity_allocated=0, location=warehouse_2)return order_with_lines_and_stock@@ -494,13 +493,13 @@ def order_with_variant_from_different_stocks(order_with_lines_and_stock):def delivery_group(order, product_type, default_category):group = DeliveryGroup.objects.create(order=order)product = Product.objects.create(- name='Test product', price=Money('10.00', currency='USD'),+ name='Test product', price=Money('10.00', 'USD'),product_type=product_type, category=default_category)variant = ProductVariant.objects.create(product=product, sku='SKU_A')warehouse = StockLocation.objects.create(name='Warehouse 2')stock = Stock.objects.create(- variant=variant, cost_price=Money(1, currency='USD'),- quantity=5, quantity_allocated=3, location=warehouse)+ variant=variant, cost_price=Money(1, 'USD'), quantity=5,+ quantity_allocated=3, location=warehouse)OrderLine.objects.create(delivery_group=group,product=product,diff --git a/tests/dashboard/test_discount.py b/tests/dashboard/test_discount.pyindex 38a519bc3d..7b5ecca4ca 100644--- a/tests/dashboard/test_discount.py+++ b/tests/dashboard/test_discount.py@@ -41,4 +41,4 @@ def test_voucher_shipping_add(admin_client):assert voucher.end_date == date(2018, 6, 1)assert voucher.discount_value_type == DiscountValueType.FIXEDassert voucher.discount_value == Decimal('15.99')- assert voucher.limit == Money('59.99', currency='USD')+ assert voucher.limit == Money('59.99', 'USD')diff --git a/tests/test_checkout.py b/tests/test_checkout.pyindex cddf86d7f9..cad78f9003 100644--- a/tests/test_checkout.py+++ b/tests/test_checkout.py@@ -68,8 +68,8 @@ def test_checkout_deliveries():def test_checkout_deliveries_with_shipping_method(monkeypatch):- shipping_cost = Money(3, currency=settings.DEFAULT_CURRENCY)- items_cost = Money(5, currency=settings.DEFAULT_CURRENCY)+ shipping_cost = Money(3, settings.DEFAULT_CURRENCY)+ items_cost = Money(5, settings.DEFAULT_CURRENCY)cost_with_shipping = items_cost + shipping_costitems_price = TaxedMoney(net=items_cost, gross=items_cost)@@ -233,7 +233,7 @@ def test_checkout_discount(request_cart, sale, product_in_stock):request_cart.add(variant, 1)checkout = Checkout(request_cart, AnonymousUser(), 'tracking_code')assert checkout.get_total() == TaxedMoney(- net=Money(5, currency="USD"), gross=Money(5, currency="USD"))+ net=Money(5, 'USD'), gross=Money(5, 'USD'))def test_checkout_create_order_insufficient_stock(diff --git a/tests/test_discounts.py b/tests/test_discounts.pyindex 95f872db8a..02d73f9b1b 100644--- a/tests/test_discounts.py+++ b/tests/test_discounts.py@@ -17,14 +17,13 @@ from saleor.product.models import Product, ProductVariant@pytest.mark.parametrize('limit, value', [- (Money(5, currency='USD'), Money(10, currency='USD')),- (Money(10, currency='USD'), Money(10, currency='USD'))])+ (Money(5, 'USD'), Money(10, 'USD')),+ (Money(10, 'USD'), Money(10, 'USD'))])def test_valid_voucher_limit(settings, limit, value):voucher = Voucher(code='unique', type=VoucherType.SHIPPING,discount_value_type=DiscountValueType.FIXED,- discount_value=Money(10, currency='USD'),- limit=limit)+ discount_value=Money(10, 'USD'), limit=limit)voucher.validate_limit(TaxedMoney(net=value, gross=value))@@ -45,7 +44,7 @@ def test_variant_discounts(product_in_stock):value=50)high_discount.products.add(product_in_stock)final_price = variant.get_price_per_item(discounts=Sale.objects.all())- assert final_price.gross == Money(0, currency='USD')+ assert final_price.gross == Money(0, 'USD')@pytest.mark.integration@@ -70,12 +69,11 @@ def test_value_voucher_checkout_discount(code='unique', type=VoucherType.VALUE,discount_value_type=discount_type,discount_value=discount_value,- limit=Money(limit, currency='USD') if limit is not None else None)- subtotal = TaxedMoney(- net=Money(total, currency='USD'), gross=Money(total, currency='USD'))+ limit=Money(limit, 'USD') if limit is not None else None)+ subtotal = TaxedMoney(net=Money(total, 'USD'), gross=Money(total, 'USD'))checkout = Mock(get_subtotal=Mock(return_value=subtotal))discount = get_voucher_discount_for_checkout(voucher, checkout)- assert discount == Money(expected_value, currency='USD')+ assert discount == Money(expected_value, 'USD')def test_value_voucher_checkout_discount_not_applicable(settings):@@ -83,13 +81,12 @@ def test_value_voucher_checkout_discount_not_applicable(settings):code='unique', type=VoucherType.VALUE,discount_value_type=DiscountValueType.FIXED,discount_value=10,- limit=Money(100, currency='USD'))- subtotal = TaxedMoney(- net=Money(10, currency='USD'), gross=Money(10, currency='USD'))+ limit=Money(100, 'USD'))+ subtotal = TaxedMoney(net=Money(10, 'USD'), gross=Money(10, 'USD'))checkout = Mock(get_subtotal=Mock(return_value=subtotal))with pytest.raises(NotApplicable) as e:get_voucher_discount_for_checkout(voucher, checkout)- assert e.value.limit == Money(100, currency='USD')+ assert e.value.limit == Money(100, 'USD')@pytest.mark.parametrize(@@ -101,15 +98,13 @@ def test_value_voucher_checkout_discount_not_applicable(settings):def test_shipping_voucher_checkout_discount(settings, shipping_cost, shipping_country_code, discount_value,discount_type, apply_to, expected_value):- subtotal = TaxedMoney(- net=Money(100, currency='USD'), gross=Money(100, currency='USD'))+ subtotal = TaxedMoney(net=Money(100, 'USD'), gross=Money(100, 'USD'))shipping_total = TaxedMoney(- net=Money(shipping_cost, currency='USD'),- gross=Money(shipping_cost, currency='USD'))+ net=Money(shipping_cost, 'USD'), gross=Money(shipping_cost, 'USD'))checkout = Mock(get_subtotal=Mock(return_value=subtotal),is_shipping_required=True, shipping_method=Mock(- price=Money(shipping_cost, currency='USD'),+ price=Money(shipping_cost, 'USD'),country_code=shipping_country_code,get_total_price=Mock(return_value=shipping_total)))voucher = Voucher(@@ -119,23 +114,23 @@ def test_shipping_voucher_checkout_discount(apply_to=apply_to,limit=None)discount = get_voucher_discount_for_checkout(voucher, checkout)- assert discount == Money(expected_value, currency='USD')+ assert discount == Money(expected_value, 'USD')@pytest.mark.parametrize('is_shipping_required, shipping_method, discount_value, discount_type, ''apply_to, limit, subtotal, error_msg', [(True, Mock(country_code='PL'), 10, DiscountValueType.FIXED,- 'US', None, Money(10, currency='USD'),+ 'US', None, Money(10, 'USD'),'This offer is only valid in United States of America.'),(True, None, 10, DiscountValueType.FIXED,- None, None, Money(10, currency='USD'),+ None, None, Money(10, 'USD'),'Please select a shipping method first.'),(False, None, 10, DiscountValueType.FIXED,- None, None, Money(10, currency='USD'),+ None, None, Money(10, 'USD'),'Your order does not require shipping.'),- (True, Mock(price=Money(10, currency='USD')), 10,- DiscountValueType.FIXED, None, 5, Money(2, currency='USD'),+ (True, Mock(price=Money(10, 'USD')), 10,+ DiscountValueType.FIXED, None, 5, Money(2, 'USD'),'This offer is only valid for orders over $5.00.')])def test_shipping_voucher_checkout_discount_not_applicable(settings, is_shipping_required, shipping_method, discount_value,@@ -149,7 +144,7 @@ def test_shipping_voucher_checkout_discount_not_applicable(code='unique', type=VoucherType.SHIPPING,discount_value_type=discount_type,discount_value=discount_value,- limit=Money(limit, currency='USD') if limit is not None else None,+ limit=Money(limit, 'USD') if limit is not None else None,apply_to=apply_to)with pytest.raises(NotApplicable) as e:get_voucher_discount_for_checkout(voucher, checkout)@@ -289,8 +284,8 @@ def test_products_voucher_checkout_discount_not('saleor.discount.utils.get_product_variants_and_prices',lambda cart, product: ((None, TaxedMoney(- net=Money(p, currency='USD'), gross=Money(p, currency='USD')))- for p in prices))+ net=Money(price, 'USD'), gross=Money(price, 'USD')))+ for price in prices))voucher = Voucher(code='unique', type=VoucherType.PRODUCT,discount_value_type=discount_type,@@ -304,11 +299,11 @@ def test_products_voucher_checkout_discount_not(@pytest.mark.django_dbdef test_sale_applies_to_correct_products(product_type, default_category):product = Product.objects.create(- name='Test Product', price=Money(10, currency='USD'), description='',+ name='Test Product', price=Money(10, 'USD'), description='',pk=10, product_type=product_type, category=default_category)variant = ProductVariant.objects.create(product=product, sku='firstvar')product2 = Product.objects.create(- name='Second product', price=Money(15, currency='USD'), description='',+ name='Second product', price=Money(15, 'USD'), description='',product_type=product_type, category=default_category)sec_variant = ProductVariant.objects.create(product=product2, sku='secvar', pk=10)@@ -318,7 +313,7 @@ def test_sale_applies_to_correct_products(product_type, default_category):assert product2 not in sale.products.all()product_discount = get_product_discount_on_sale(sale, variant.product)discounted_price = product_discount(product.price)- assert discounted_price == Money(7, currency='USD')+ assert discounted_price == Money(7, 'USD')with pytest.raises(NotApplicable):get_product_discount_on_sale(sale, sec_variant.product)diff --git a/tests/test_order.py b/tests/test_order.pyindex 0ddf99754a..2370d44610 100644--- a/tests/test_order.py+++ b/tests/test_order.py@@ -12,15 +12,14 @@ from saleor.order.utils import add_variant_to_delivery_group, recalculate_orderdef test_total_setter():- price = TaxedMoney(- net=Money(10, currency='USD'), gross=Money(15, currency='USD'))+ price = TaxedMoney(net=Money(10, 'USD'), gross=Money(15, 'USD'))order = models.Order()order.total = price- assert order.total_net == Money(10, currency='USD')- assert order.total.net == Money(10, currency='USD')- assert order.total_gross == Money(15, currency='USD')- assert order.total.gross == Money(15, currency='USD')- assert order.total.tax == Money(5, currency='USD')+ assert order.total_net == Money(10, 'USD')+ assert order.total.net == Money(10, 'USD')+ assert order.total_gross == Money(15, 'USD')+ assert order.total.gross == Money(15, 'USD')+ assert order.total.tax == Money(5, 'USD')def test_order_get_subtotal(order_with_lines):diff --git a/tests/test_payment.py b/tests/test_payment.pyindex 0d3c215e76..c8c94a896c 100644--- a/tests/test_payment.py+++ b/tests/test_payment.py@@ -7,7 +7,7 @@ from saleor.order.models import Paymentdef test_get_purchased_items(order_with_lines, settings, voucher):payment = Payment.objects.create(order=order_with_lines, variant='paypal')- discount = Money('10.0', currency=settings.DEFAULT_CURRENCY)+ discount = Money('10.0', settings.DEFAULT_CURRENCY)assert len(payment.get_purchased_items()) == len(order_with_lines.get_lines())