Skip to content

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

Renaming get_total_price methods

TOMEK65d888ba61e3
diff --git a/saleor/checkout/models.py b/saleor/checkout/models.py
index 57aa361466..d84d991ba2 100644
--- a/saleor/checkout/models.py
+++ b/saleor/checkout/models.py
@@ -82,7 +82,7 @@ class Cart(models.Model):
def get_shipping_price(self, taxes):
return (
- self.shipping_method.get_total_price(taxes)
+ self.shipping_method.get_total(taxes)
if self.shipping_method and self.is_shipping_required()
else ZERO_TAXED_MONEY)
diff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.py
index 70954e29c4..3bbfda16b1 100644
--- a/saleor/checkout/utils.py
+++ b/saleor/checkout/utils.py
@@ -661,7 +661,7 @@ def _get_shipping_voucher_discount_for_cart(voucher, cart):
'This offer is not valid in your country.')
raise NotApplicable(msg)
return get_shipping_voucher_discount(
- voucher, cart.get_subtotal(), shipping_method.get_total_price())
+ voucher, cart.get_subtotal(), shipping_method.get_total())
def _get_products_voucher_discount(order_or_cart, voucher):
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.py
index 46e1ebfd76..1620d4c72f 100644
--- a/saleor/dashboard/order/forms.py
+++ b/saleor/dashboard/order/forms.py
@@ -178,7 +178,7 @@ class OrderShippingForm(forms.ModelForm):
def save(self, commit=True):
method = self.instance.shipping_method
self.instance.shipping_method_name = method.name
- self.instance.shipping_price = method.get_total_price(self.taxes)
+ self.instance.shipping_price = method.get_total(self.taxes)
recalculate_order(self.instance)
return super().save(commit)
diff --git a/saleor/dashboard/order/views.py b/saleor/dashboard/order/views.py
index da05aaf5ed..9178c25ed2 100644
--- a/saleor/dashboard/order/views.py
+++ b/saleor/dashboard/order/views.py
@@ -135,7 +135,7 @@ def order_details(request, order_pk):
can_refund = (
payment.status == PaymentStatus.CONFIRMED and
payment.variant != CustomPaymentChoices.MANUAL)
- preauthorized = payment.get_total_price()
+ preauthorized = payment.get_total()
if payment.status == PaymentStatus.CONFIRMED:
captured = payment.get_captured_price()
balance = captured - order.total.gross
diff --git a/saleor/graphql/order/mutations/orders.py b/saleor/graphql/order/mutations/orders.py
index a5c8847a52..097eaff6f4 100644
--- a/saleor/graphql/order/mutations/orders.py
+++ b/saleor/graphql/order/mutations/orders.py
@@ -173,7 +173,7 @@ class OrderUpdateShipping(BaseMutation):
return OrderUpdateShipping(errors=errors)
order.shipping_method = method
- order.shipping_price = method.get_total_price(info.context.taxes)
+ order.shipping_price = method.get_total(info.context.taxes)
order.shipping_method_name = method.name
order.save(
update_fields=[
diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.py
index 521323963a..289129e681 100644
--- a/saleor/graphql/order/types.py
+++ b/saleor/graphql/order/types.py
@@ -126,7 +126,7 @@ class Order(CountableDjangoObjectType):
def resolve_total_authorized(obj, info):
payment = obj.get_last_payment()
if payment:
- return payment.get_total_price().gross
+ return payment.get_total().gross
@staticmethod
def resolve_total_captured(obj, info):
diff --git a/saleor/order/models.py b/saleor/order/models.py
index 5daedf0f13..1b6920a39d 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -115,7 +115,7 @@ class Order(models.Model):
def is_fully_paid(self):
total_paid = sum(
[
- payment.get_total_price() for payment in
+ payment.get_total() for payment in
self.payments.filter(status=PaymentStatus.CONFIRMED)],
ZERO_TAXED_MONEY)
return total_paid.gross >= self.total.gross
@@ -312,7 +312,7 @@ class Payment(BasePayment):
currency=self.order.discount_amount.currency))
return lines
- def get_total_price(self):
+ def get_total(self):
return TaxedMoney(
net=Money(self.total - self.tax, self.currency),
gross=Money(self.total, self.currency))
diff --git a/saleor/order/utils.py b/saleor/order/utils.py
index b1a8c33e6a..6a59bded10 100644
--- a/saleor/order/utils.py
+++ b/saleor/order/utils.py
@@ -86,7 +86,7 @@ def update_order_prices(order, discounts):
line.save()
if order.shipping_method:
- order.shipping_price = order.shipping_method.get_total_price(taxes)
+ order.shipping_price = order.shipping_method.get_total(taxes)
order.save()
recalculate_order(order)
diff --git a/saleor/shipping/models.py b/saleor/shipping/models.py
index 58d67163a8..d02f123191 100644
--- a/saleor/shipping/models.py
+++ b/saleor/shipping/models.py
@@ -41,7 +41,7 @@ class ShippingZone(models.Model):
@property
def price_range(self):
prices = [
- shipping_method.get_total_price()
+ shipping_method.get_total()
for shipping_method in self.shipping_methods.all()]
if prices:
return MoneyRange(min(prices).net, max(prices).net)
@@ -124,7 +124,7 @@ class ShippingMethod(models.Model):
self.type, get_weight_type_display(
self.minimum_order_weight, self.maximum_order_weight))
- def get_total_price(self, taxes=None):
+ def get_total(self, taxes=None):
return get_taxed_shipping_price(self.price, taxes)
def get_ajax_label(self):
diff --git a/templates/dashboard/index.html b/templates/dashboard/index.html
index 5ce1593a3c..0ac28cddcd 100644
--- a/templates/dashboard/index.html
+++ b/templates/dashboard/index.html
@@ -48,7 +48,7 @@
{{ payment.order.user|default:_("Guest") }}
</td>
<td class="right-align">
- {% price payment.get_total_price.gross %}
+ {% price payment.get_total.gross %}
</td>
</tr>
{% endfor %}
diff --git a/tests/api/test_order.py b/tests/api/test_order.py
index 0fc1b4f7ce..2e966bedb2 100644
--- a/tests/api/test_order.py
+++ b/tests/api/test_order.py
@@ -735,7 +735,7 @@ def test_order_capture(admin_api_client, payment_preauth, admin_user):
}
"""
order_id = graphene.Node.to_global_id('Order', order.id)
- amount = float(payment_preauth.get_total_price().gross.amount)
+ amount = float(payment_preauth.get_total().gross.amount)
variables = json.dumps({'id': order_id, 'amount': amount})
response = admin_api_client.post(
reverse('api'), {'query': query, 'variables': variables})
@@ -855,7 +855,7 @@ def test_order_refund(admin_api_client, payment_confirmed):
}
"""
order_id = graphene.Node.to_global_id('Order', order.id)
- amount = float(payment_confirmed.get_total_price().gross.amount)
+ amount = float(payment_confirmed.get_total().gross.amount)
variables = json.dumps({'id': order_id, 'amount': amount})
response = admin_api_client.post(
reverse('api'), {'query': query, 'variables': variables})
@@ -956,7 +956,7 @@ def test_order_update_shipping(
assert data['order']['id'] == order_id
order.refresh_from_db()
- shipping_price = shipping_method.get_total_price()
+ shipping_price = shipping_method.get_total()
assert order.shipping_method == shipping_method
assert order.shipping_price_net == shipping_price.net
assert order.shipping_price_gross == shipping_price.gross
@@ -966,7 +966,7 @@ def test_order_update_shipping(
def test_order_update_shipping_clear_shipping_method(
admin_api_client, order, admin_user, shipping_method):
order.shipping_method = shipping_method
- order.shipping_price = shipping_method.get_total_price()
+ order.shipping_price = shipping_method.get_total()
order.shipping_method_name = 'Example shipping'
order.save()
diff --git a/tests/conftest.py b/tests/conftest.py
index 7878125471..4467e4b0ac 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -452,7 +452,7 @@ def order_with_lines(
method = shipping_zone.shipping_methods.get()
order.shipping_method_name = method.name
order.shipping_method = method
- order.shipping_price = method.get_total_price(taxes)
+ order.shipping_price = method.get_total(taxes)
order.save()
recalculate_order(order)
diff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.py
index 8756a10a91..b97ab413f0 100644
--- a/tests/dashboard/test_order.py
+++ b/tests/dashboard/test_order.py
@@ -937,7 +937,7 @@ def test_view_order_shipping_edit(
assert get_redirect_location(response) == redirect_url
draft_order.refresh_from_db()
assert draft_order.shipping_method_name == method.name
- assert draft_order.shipping_price == method.get_total_price(taxes=vatlayer)
+ assert draft_order.shipping_price == method.get_total(taxes=vatlayer)
assert draft_order.shipping_method == method
diff --git a/tests/test_checkout.py b/tests/test_checkout.py
index 34264d67cd..8f2551cb54 100644
--- a/tests/test_checkout.py
+++ b/tests/test_checkout.py
@@ -589,7 +589,7 @@ def test_get_discount_for_cart_shipping_voucher(
get_subtotal=Mock(return_value=subtotal),
is_shipping_required=Mock(return_value=True),
shipping_method=Mock(
- get_total_price=Mock(return_value=shipping_total)),
+ get_total=Mock(return_value=shipping_total)),
shipping_address=Mock(country=Country(shipping_country_code)))
voucher = Voucher(
code='unique', type=VoucherType.SHIPPING,
diff --git a/tests/test_order.py b/tests/test_order.py
index 61748b7483..ad5e84ee66 100644
--- a/tests/test_order.py
+++ b/tests/test_order.py
@@ -396,7 +396,7 @@ def test_update_order_prices(order_with_lines):
line_2 = order_with_lines.lines.last()
price_1 = line_1.variant.get_price(taxes=taxes)
price_2 = line_2.variant.get_price(taxes=taxes)
- shipping_price = order_with_lines.shipping_method.get_total_price(taxes)
+ shipping_price = order_with_lines.shipping_method.get_total(taxes)
update_order_prices(order_with_lines, None)
diff --git a/tests/test_shipping.py b/tests/test_shipping.py
index 9eee1a78ea..36d77cc7e5 100644
--- a/tests/test_shipping.py
+++ b/tests/test_shipping.py
@@ -29,7 +29,7 @@ def test_get_taxed_shipping_price(
assert shipping_price == expected_price
-def test_shipping_get_total_price(monkeypatch, shipping_zone, vatlayer):
+def test_shipping_get_total(monkeypatch, shipping_zone, vatlayer):
method = shipping_zone.shipping_methods.get()
price = Money(10, 'USD')
taxed_price = TaxedMoney(
@@ -37,7 +37,7 @@ def test_shipping_get_total_price(monkeypatch, shipping_zone, vatlayer):
mock_get_price = Mock(return_value=taxed_price)
monkeypatch.setattr(
'saleor.shipping.models.get_taxed_shipping_price', mock_get_price)
- method.get_total_price(taxes=vatlayer)
+ method.get_total(taxes=vatlayer)
mock_get_price.assert_called_once_with(price, vatlayer)