Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Revert changes from checkout models and utils
IKarbowiakb20b6fc9e2ef
diff --git a/saleor/checkout/models.py b/saleor/checkout/models.pyindex cc7e3561a7..2e96e47adc 100644--- a/saleor/checkout/models.py+++ b/saleor/checkout/models.py@@ -1,4 +1,5 @@"""Checkout-related ORM models."""+from operator import attrgetterfrom typing import TYPE_CHECKING, Optionalfrom uuid import uuid4@@ -138,7 +139,8 @@ class Checkout(ModelWithMetadata):return next(matching_lines, None)def get_last_active_payment(self) -> Optional["Payment"]:- return self.payments.filter(is_active=True).last()+ payments = [payment for payment in self.payments.all() if payment.is_active]+ return max(payments, default=None, key=attrgetter("pk"))def set_country(self, country_code: str, commit: bool = False, replace: bool = Truediff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.pyindex 1efa5649c1..b716f295f0 100644--- a/saleor/checkout/utils.py+++ b/saleor/checkout/utils.py@@ -6,7 +6,6 @@ from typing import Iterable, List, Optional, Tuplefrom django.core.exceptions import ValidationErrorfrom django.db import transactionfrom django.db.models import Max, Min, Sum-from django.db.models.functions import Coalescefrom django.utils import timezonefrom django.utils.encoding import smart_textfrom django.utils.translation import get_language@@ -761,9 +760,8 @@ def is_fully_paid(Note that these payments may not be captured or charged at all."""- total_paid = checkout.payments.filter(is_active=True).aggregate(- total_sum=Coalesce(Sum("total"), 0)- )["total_sum"]+ payments = [payment for payment in checkout.payments.all() if payment.is_active]+ total_paid = sum([p.total for p in payments])checkout_total = (calculations.checkout_total(checkout=checkout, lines=lines, discounts=discounts)- checkout.get_total_gift_cards_balance()