Skip to content

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

Fix codeclimate issue

Unknownffe797e610aa
diff --git a/saleor/graphql/payment/types.py b/saleor/graphql/payment/types.py
index 83af086998..1ecd73a5d3 100644
--- a/saleor/graphql/payment/types.py
+++ b/saleor/graphql/payment/types.py
@@ -1,7 +1,7 @@
import graphene
+import graphene_django_optimizer as gql_optimizer
from django_countries.fields import Country
from graphene import relay
-import graphene_django_optimizer as gql_optimizer
from ...payment import GATEWAYS_ENUM, ChargeStatus, models
from ..account.types import Address
diff --git a/saleor/payment/models.py b/saleor/payment/models.py
index 013dae1116..d8b81a36c3 100644
--- a/saleor/payment/models.py
+++ b/saleor/payment/models.py
@@ -108,12 +108,13 @@ class Payment(models.Model):
and txn.is_success for txn in transactions]):
return money
- # Calculate authorized amount from all succeeded auth transactions
- for txn in transactions:
- # Bypass non-authorized transactions
- if not (txn.kind == TransactionKind.AUTH and txn.is_success):
- continue
+ # Filter the succeeded auth transactions
+ authorized_txns = [
+ txn for txn in transactions
+ if txn.kind == TransactionKind.AUTH and txn.is_success]
+ # Calculate authorized amount from all succeeded auth transactions
+ for txn in authorized_txns:
money += Money(
txn.amount, self.currency or settings.DEFAULT_CURRENCY)