Skip to content

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

Bump ruff and mypy (#17861)

Marcin Gębalae60ad19f0c9b
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 0c9e3d02e3..03f8247295 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -15,7 +15,7 @@ repos:
exclude_types: [svg]
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.11.13
+ rev: v0.12.1
hooks:
- id: ruff
args: [ --fix ]
diff --git a/poetry.lock b/poetry.lock
index 60cd92a53c..f882af5c6d 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -1254,39 +1254,38 @@ sftp = ["paramiko (>=1.15)"]
[[package]]
name = "django-stubs"
-version = "5.1.3"
+version = "5.2.1"
description = "Mypy stubs for Django"
optional = false
-python-versions = ">=3.8"
+python-versions = ">=3.10"
groups = ["dev"]
files = [
- {file = "django_stubs-5.1.3-py3-none-any.whl", hash = "sha256:716758ced158b439213062e52de6df3cff7c586f9f9ad7ab59210efbea5dfe78"},
- {file = "django_stubs-5.1.3.tar.gz", hash = "sha256:8c230bc5bebee6da282ba8a27ad1503c84a0c4cd2f46e63d149e76d2a63e639a"},
+ {file = "django_stubs-5.2.1-py3-none-any.whl", hash = "sha256:c0e170d70329c27e737a5b80c5518fb6161d0c4792321d11a4a93dcda120f4ef"},
+ {file = "django_stubs-5.2.1.tar.gz", hash = "sha256:e58260958e58f7b6a8da6bba56d6b31d16c0414079a4aa6baa01c668bd08d39d"},
]
[package.dependencies]
-asgiref = "*"
django = "*"
-django-stubs-ext = ">=5.1.3"
-mypy = {version = ">=1.12,<1.16", optional = true, markers = "extra == \"compatible-mypy\""}
-types-PyYAML = "*"
+django-stubs-ext = ">=5.2.1"
+mypy = {version = ">=1.13,<1.17", optional = true, markers = "extra == \"compatible-mypy\""}
+types-pyyaml = "*"
typing-extensions = ">=4.11.0"
[package.extras]
-compatible-mypy = ["mypy (>=1.12,<1.16)"]
+compatible-mypy = ["mypy (>=1.13,<1.17)"]
oracle = ["oracledb"]
-redis = ["redis"]
+redis = ["redis", "types-redis"]
[[package]]
name = "django-stubs-ext"
-version = "5.1.3"
+version = "5.2.1"
description = "Monkey-patching and extensions for django-stubs"
optional = false
-python-versions = ">=3.8"
+python-versions = ">=3.10"
groups = ["main", "dev"]
files = [
- {file = "django_stubs_ext-5.1.3-py3-none-any.whl", hash = "sha256:64561fbc53e963cc1eed2c8eb27e18b8e48dcb90771205180fe29fc8a59e55fd"},
- {file = "django_stubs_ext-5.1.3.tar.gz", hash = "sha256:3e60f82337f0d40a362f349bf15539144b96e4ceb4dbd0239be1cd71f6a74ad0"},
+ {file = "django_stubs_ext-5.2.1-py3-none-any.whl", hash = "sha256:98fb0646f1a1ef07708eec5f6f7d27523f12c0c8714abae8db981571ff957588"},
+ {file = "django_stubs_ext-5.2.1.tar.gz", hash = "sha256:fc0582cb3289306c43ce4a0a15af86922ce1dbec3c19eab80980ee70c04e0392"},
]
[package.dependencies]
@@ -2681,48 +2680,49 @@ files = [
[[package]]
name = "mypy"
-version = "1.15.0"
+version = "1.16.1"
description = "Optional static typing for Python"
optional = false
python-versions = ">=3.9"
groups = ["dev"]
files = [
- {file = "mypy-1.15.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:979e4e1a006511dacf628e36fadfecbcc0160a8af6ca7dad2f5025529e082c13"},
- {file = "mypy-1.15.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c4bb0e1bd29f7d34efcccd71cf733580191e9a264a2202b0239da95984c5b559"},
- {file = "mypy-1.15.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:be68172e9fd9ad8fb876c6389f16d1c1b5f100ffa779f77b1fb2176fcc9ab95b"},
- {file = "mypy-1.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c7be1e46525adfa0d97681432ee9fcd61a3964c2446795714699a998d193f1a3"},
- {file = "mypy-1.15.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:2e2c2e6d3593f6451b18588848e66260ff62ccca522dd231cd4dd59b0160668b"},
- {file = "mypy-1.15.0-cp310-cp310-win_amd64.whl", hash = "sha256:6983aae8b2f653e098edb77f893f7b6aca69f6cffb19b2cc7443f23cce5f4828"},
- {file = "mypy-1.15.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:2922d42e16d6de288022e5ca321cd0618b238cfc5570e0263e5ba0a77dbef56f"},
- {file = "mypy-1.15.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:2ee2d57e01a7c35de00f4634ba1bbf015185b219e4dc5909e281016df43f5ee5"},
- {file = "mypy-1.15.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:973500e0774b85d9689715feeffcc980193086551110fd678ebe1f4342fb7c5e"},
- {file = "mypy-1.15.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5a95fb17c13e29d2d5195869262f8125dfdb5c134dc8d9a9d0aecf7525b10c2c"},
- {file = "mypy-1.15.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:1905f494bfd7d85a23a88c5d97840888a7bd516545fc5aaedff0267e0bb54e2f"},
- {file = "mypy-1.15.0-cp311-cp311-win_amd64.whl", hash = "sha256:c9817fa23833ff189db061e6d2eff49b2f3b6ed9856b4a0a73046e41932d744f"},
- {file = "mypy-1.15.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:aea39e0583d05124836ea645f412e88a5c7d0fd77a6d694b60d9b6b2d9f184fd"},
- {file = "mypy-1.15.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2f2147ab812b75e5b5499b01ade1f4a81489a147c01585cda36019102538615f"},
- {file = "mypy-1.15.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ce436f4c6d218a070048ed6a44c0bbb10cd2cc5e272b29e7845f6a2f57ee4464"},
- {file = "mypy-1.15.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8023ff13985661b50a5928fc7a5ca15f3d1affb41e5f0a9952cb68ef090b31ee"},
- {file = "mypy-1.15.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:1124a18bc11a6a62887e3e137f37f53fbae476dc36c185d549d4f837a2a6a14e"},
- {file = "mypy-1.15.0-cp312-cp312-win_amd64.whl", hash = "sha256:171a9ca9a40cd1843abeca0e405bc1940cd9b305eaeea2dda769ba096932bb22"},
- {file = "mypy-1.15.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:93faf3fdb04768d44bf28693293f3904bbb555d076b781ad2530214ee53e3445"},
- {file = "mypy-1.15.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:811aeccadfb730024c5d3e326b2fbe9249bb7413553f15499a4050f7c30e801d"},
- {file = "mypy-1.15.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:98b7b9b9aedb65fe628c62a6dc57f6d5088ef2dfca37903a7d9ee374d03acca5"},
- {file = "mypy-1.15.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c43a7682e24b4f576d93072216bf56eeff70d9140241f9edec0c104d0c515036"},
- {file = "mypy-1.15.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:baefc32840a9f00babd83251560e0ae1573e2f9d1b067719479bfb0e987c6357"},
- {file = "mypy-1.15.0-cp313-cp313-win_amd64.whl", hash = "sha256:b9378e2c00146c44793c98b8d5a61039a048e31f429fb0eb546d93f4b000bedf"},
- {file = "mypy-1.15.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:e601a7fa172c2131bff456bb3ee08a88360760d0d2f8cbd7a75a65497e2df078"},
- {file = "mypy-1.15.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:712e962a6357634fef20412699a3655c610110e01cdaa6180acec7fc9f8513ba"},
- {file = "mypy-1.15.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f95579473af29ab73a10bada2f9722856792a36ec5af5399b653aa28360290a5"},
- {file = "mypy-1.15.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8f8722560a14cde92fdb1e31597760dc35f9f5524cce17836c0d22841830fd5b"},
- {file = "mypy-1.15.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:1fbb8da62dc352133d7d7ca90ed2fb0e9d42bb1a32724c287d3c76c58cbaa9c2"},
- {file = "mypy-1.15.0-cp39-cp39-win_amd64.whl", hash = "sha256:d10d994b41fb3497719bbf866f227b3489048ea4bbbb5015357db306249f7980"},
- {file = "mypy-1.15.0-py3-none-any.whl", hash = "sha256:5469affef548bd1895d86d3bf10ce2b44e33d86923c29e4d675b3e323437ea3e"},
- {file = "mypy-1.15.0.tar.gz", hash = "sha256:404534629d51d3efea5c800ee7c42b72a6554d6c400e6a79eafe15d11341fd43"},
+ {file = "mypy-1.16.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b4f0fed1022a63c6fec38f28b7fc77fca47fd490445c69d0a66266c59dd0b88a"},
+ {file = "mypy-1.16.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:86042bbf9f5a05ea000d3203cf87aa9d0ccf9a01f73f71c58979eb9249f46d72"},
+ {file = "mypy-1.16.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ea7469ee5902c95542bea7ee545f7006508c65c8c54b06dc2c92676ce526f3ea"},
+ {file = "mypy-1.16.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:352025753ef6a83cb9e7f2427319bb7875d1fdda8439d1e23de12ab164179574"},
+ {file = "mypy-1.16.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:ff9fa5b16e4c1364eb89a4d16bcda9987f05d39604e1e6c35378a2987c1aac2d"},
+ {file = "mypy-1.16.1-cp310-cp310-win_amd64.whl", hash = "sha256:1256688e284632382f8f3b9e2123df7d279f603c561f099758e66dd6ed4e8bd6"},
+ {file = "mypy-1.16.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:472e4e4c100062488ec643f6162dd0d5208e33e2f34544e1fc931372e806c0cc"},
+ {file = "mypy-1.16.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ea16e2a7d2714277e349e24d19a782a663a34ed60864006e8585db08f8ad1782"},
+ {file = "mypy-1.16.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:08e850ea22adc4d8a4014651575567b0318ede51e8e9fe7a68f25391af699507"},
+ {file = "mypy-1.16.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:22d76a63a42619bfb90122889b903519149879ddbf2ba4251834727944c8baca"},
+ {file = "mypy-1.16.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:2c7ce0662b6b9dc8f4ed86eb7a5d505ee3298c04b40ec13b30e572c0e5ae17c4"},
+ {file = "mypy-1.16.1-cp311-cp311-win_amd64.whl", hash = "sha256:211287e98e05352a2e1d4e8759c5490925a7c784ddc84207f4714822f8cf99b6"},
+ {file = "mypy-1.16.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:af4792433f09575d9eeca5c63d7d90ca4aeceda9d8355e136f80f8967639183d"},
+ {file = "mypy-1.16.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:66df38405fd8466ce3517eda1f6640611a0b8e70895e2a9462d1d4323c5eb4b9"},
+ {file = "mypy-1.16.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:44e7acddb3c48bd2713994d098729494117803616e116032af192871aed80b79"},
+ {file = "mypy-1.16.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0ab5eca37b50188163fa7c1b73c685ac66c4e9bdee4a85c9adac0e91d8895e15"},
+ {file = "mypy-1.16.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:dedb6229b2c9086247e21a83c309754b9058b438704ad2f6807f0d8227f6ebdd"},
+ {file = "mypy-1.16.1-cp312-cp312-win_amd64.whl", hash = "sha256:1f0435cf920e287ff68af3d10a118a73f212deb2ce087619eb4e648116d1fe9b"},
+ {file = "mypy-1.16.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ddc91eb318c8751c69ddb200a5937f1232ee8efb4e64e9f4bc475a33719de438"},
+ {file = "mypy-1.16.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:87ff2c13d58bdc4bbe7dc0dedfe622c0f04e2cb2a492269f3b418df2de05c536"},
+ {file = "mypy-1.16.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0a7cfb0fe29fe5a9841b7c8ee6dffb52382c45acdf68f032145b75620acfbd6f"},
+ {file = "mypy-1.16.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:051e1677689c9d9578b9c7f4d206d763f9bbd95723cd1416fad50db49d52f359"},
+ {file = "mypy-1.16.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:d5d2309511cc56c021b4b4e462907c2b12f669b2dbeb68300110ec27723971be"},
+ {file = "mypy-1.16.1-cp313-cp313-win_amd64.whl", hash = "sha256:4f58ac32771341e38a853c5d0ec0dfe27e18e27da9cdb8bbc882d2249c71a3ee"},
+ {file = "mypy-1.16.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:7fc688329af6a287567f45cc1cefb9db662defeb14625213a5b7da6e692e2069"},
+ {file = "mypy-1.16.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:5e198ab3f55924c03ead626ff424cad1732d0d391478dfbf7bb97b34602395da"},
+ {file = "mypy-1.16.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:09aa4f91ada245f0a45dbc47e548fd94e0dd5a8433e0114917dc3b526912a30c"},
+ {file = "mypy-1.16.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:13c7cd5b1cb2909aa318a90fd1b7e31f17c50b242953e7dd58345b2a814f6383"},
+ {file = "mypy-1.16.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:58e07fb958bc5d752a280da0e890c538f1515b79a65757bbdc54252ba82e0b40"},
+ {file = "mypy-1.16.1-cp39-cp39-win_amd64.whl", hash = "sha256:f895078594d918f93337a505f8add9bd654d1a24962b4c6ed9390e12531eb31b"},
+ {file = "mypy-1.16.1-py3-none-any.whl", hash = "sha256:5fc2ac4027d0ef28d6ba69a0343737a23c4d1b83672bf38d1fe237bdc0643b37"},
+ {file = "mypy-1.16.1.tar.gz", hash = "sha256:6bd00a0a2094841c5e47e7374bb42b83d64c527a502e3334e1173a0c24437bab"},
]
[package.dependencies]
mypy_extensions = ">=1.0.0"
+pathspec = ">=0.9.0"
typing_extensions = ">=4.6.0"
[package.extras]
@@ -3004,6 +3004,18 @@ files = [
{file = "pastel-0.2.1.tar.gz", hash = "sha256:e6581ac04e973cac858828c6202c1e1e81fee1dc7de7683f3e1ffe0bfd8a573d"},
]
+[[package]]
+name = "pathspec"
+version = "0.12.1"
+description = "Utility library for gitignore style pattern matching of file paths."
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"},
+ {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"},
+]
+
[[package]]
name = "petl"
version = "1.7.15"
diff --git a/pyproject.toml b/pyproject.toml
index 9cdb6185d9..f041221098 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -280,7 +280,8 @@ target-version = "py312"
"E501", # Line too long
"PT019", # Fixture without value is injected as parameter, use @pytest.mark.usefixtures instead
"PYI041", # Use `float` instead of `int | float`
- "RET504" # Unnecessary assignment before return statement
+ "RET504", # Unnecessary assignment before return statement
+ "UP046" # Parameter syntax for generic classes; not supported by mypy: https://github.com/python/mypy/issues/18507
]
[tool.ruff.lint.flake8-pytest-style]
diff --git a/saleor/asgi/cors_handler.py b/saleor/asgi/cors_handler.py
index 9f47416fcc..be1acc6d3e 100644
--- a/saleor/asgi/cors_handler.py
+++ b/saleor/asgi/cors_handler.py
@@ -1,5 +1,4 @@
from fnmatch import fnmatchcase
-from typing import cast
from asgiref.typing import (
ASGI3Application,
@@ -8,7 +7,6 @@ from asgiref.typing import (
ASGISendEvent,
HTTPResponseBodyEvent,
HTTPResponseStartEvent,
- HTTPScope,
Scope,
)
from django.conf import settings
@@ -35,7 +33,6 @@ def cors_handler(application: ASGI3Application) -> ASGI3Application:
origin_match = True
break
if scope["method"] == "OPTIONS":
- scope = cast(HTTPScope, scope)
response_headers: list[tuple[bytes, bytes]] = [
(b"access-control-allow-credentials", b"true"),
(
diff --git a/saleor/checkout/migrations/0050_auto_20220713_1057.py b/saleor/checkout/migrations/0050_auto_20220713_1057.py
index d6c5f737d0..f131f0e9fa 100644
--- a/saleor/checkout/migrations/0050_auto_20220713_1057.py
+++ b/saleor/checkout/migrations/0050_auto_20220713_1057.py
@@ -32,14 +32,14 @@ class Migration(migrations.Migration):
model_name="checkout",
name="shipping_price_gross_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.AddField(
model_name="checkout",
name="shipping_price_net_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.AddField(
@@ -53,28 +53,28 @@ class Migration(migrations.Migration):
model_name="checkout",
name="subtotal_gross_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.AddField(
model_name="checkout",
name="subtotal_net_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.AddField(
model_name="checkout",
name="total_gross_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.AddField(
model_name="checkout",
name="total_net_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.AddField(
@@ -93,14 +93,14 @@ class Migration(migrations.Migration):
model_name="checkoutline",
name="total_price_gross_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.AddField(
model_name="checkoutline",
name="total_price_net_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
]
diff --git a/saleor/checkout/migrations/0063_checkout_base_total_and_subtotal.py b/saleor/checkout/migrations/0063_checkout_base_total_and_subtotal.py
index 43a765a0ce..7711440af5 100644
--- a/saleor/checkout/migrations/0063_checkout_base_total_and_subtotal.py
+++ b/saleor/checkout/migrations/0063_checkout_base_total_and_subtotal.py
@@ -18,14 +18,14 @@ class Migration(migrations.Migration):
model_name="checkout",
name="base_subtotal_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.AddField(
model_name="checkout",
name="base_total_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.RunSQL(
diff --git a/saleor/checkout/migrations/0072_alter_checkoutline_undiscounted_unit_price_amount.py b/saleor/checkout/migrations/0072_alter_checkoutline_undiscounted_unit_price_amount.py
index ca7385c6e8..ef6c285d60 100644
--- a/saleor/checkout/migrations/0072_alter_checkoutline_undiscounted_unit_price_amount.py
+++ b/saleor/checkout/migrations/0072_alter_checkoutline_undiscounted_unit_price_amount.py
@@ -17,7 +17,7 @@ class Migration(migrations.Migration):
model_name="checkoutline",
name="undiscounted_unit_price_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
],
diff --git a/saleor/checkout/migrations/0073_checkout_external_shipping_method_id_and_more.py b/saleor/checkout/migrations/0073_checkout_external_shipping_method_id_and_more.py
index 54f2320655..99f3e41225 100644
--- a/saleor/checkout/migrations/0073_checkout_external_shipping_method_id_and_more.py
+++ b/saleor/checkout/migrations/0073_checkout_external_shipping_method_id_and_more.py
@@ -29,7 +29,7 @@ class Migration(migrations.Migration):
model_name="checkout",
name="undiscounted_base_shipping_price_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.RunSQL(
diff --git a/saleor/checkout/migrations/0075_alter_checkout_base_subtotal_amount_and_more.py b/saleor/checkout/migrations/0075_alter_checkout_base_subtotal_amount_and_more.py
index ed387cdfb9..fd172aa5c9 100644
--- a/saleor/checkout/migrations/0075_alter_checkout_base_subtotal_amount_and_more.py
+++ b/saleor/checkout/migrations/0075_alter_checkout_base_subtotal_amount_and_more.py
@@ -15,14 +15,14 @@ class Migration(migrations.Migration):
model_name="checkout",
name="base_subtotal_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="checkout",
name="base_total_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
@@ -36,49 +36,49 @@ class Migration(migrations.Migration):
model_name="checkout",
name="shipping_price_gross_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="checkout",
name="shipping_price_net_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="checkout",
name="subtotal_gross_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="checkout",
name="subtotal_net_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="checkout",
name="total_gross_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="checkout",
name="total_net_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="checkout",
name="undiscounted_base_shipping_price_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
@@ -92,14 +92,14 @@ class Migration(migrations.Migration):
model_name="checkoutline",
name="total_price_gross_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="checkoutline",
name="total_price_net_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
diff --git a/saleor/checkout/migrations/0079_alter_checkoutline_prior_unit_price_amount_and_more.py b/saleor/checkout/migrations/0079_alter_checkoutline_prior_unit_price_amount_and_more.py
index ec4ef129e2..2006600692 100644
--- a/saleor/checkout/migrations/0079_alter_checkoutline_prior_unit_price_amount_and_more.py
+++ b/saleor/checkout/migrations/0079_alter_checkoutline_prior_unit_price_amount_and_more.py
@@ -22,7 +22,7 @@ class Migration(migrations.Migration):
model_name="checkoutline",
name="undiscounted_unit_price_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
]
diff --git a/saleor/checkout/tests/fixtures/checkout_with_discount.py b/saleor/checkout/tests/fixtures/checkout_with_discount.py
index e7d920f3d3..227ed95e86 100644
--- a/saleor/checkout/tests/fixtures/checkout_with_discount.py
+++ b/saleor/checkout/tests/fixtures/checkout_with_discount.py
@@ -21,8 +21,8 @@ def checkout_with_item_on_promotion(checkout_with_item):
variant = line.variant
- reward_value = Decimal("5")
- reward_value_prior = Decimal("2")
+ reward_value = Decimal(5)
+ reward_value_prior = Decimal(2)
rule = promotion.rules.create(
catalogue_predicate={
@@ -71,7 +71,7 @@ def checkout_with_item_and_order_discount(
):
channel = checkout_with_item.channel
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = catalogue_promotion_without_rules.rules.create(
order_predicate={
diff --git a/saleor/checkout/tests/fixtures/checkout_with_transaction.py b/saleor/checkout/tests/fixtures/checkout_with_transaction.py
index e849518fdf..00164b0583 100644
--- a/saleor/checkout/tests/fixtures/checkout_with_transaction.py
+++ b/saleor/checkout/tests/fixtures/checkout_with_transaction.py
@@ -13,6 +13,6 @@ def checkout_with_item_and_transaction_item(checkout_with_item):
available_actions=["refund"],
currency="USD",
checkout_id=checkout_with_item.pk,
- charged_value=Decimal("10"),
+ charged_value=Decimal(10),
)
return checkout_with_item
diff --git a/saleor/checkout/tests/test_base_calculations.py b/saleor/checkout/tests/test_base_calculations.py
index c9fc45da95..f58cc40650 100644
--- a/saleor/checkout/tests/test_base_calculations.py
+++ b/saleor/checkout/tests/test_base_calculations.py
@@ -178,7 +178,7 @@ def test_calculate_base_line_unit_price_with_percentage_voucher(
unit_price = calculate_base_line_unit_price(checkout_line_info)
# then
- expected_voucher_amount = Money(Decimal("1"), checkout_with_single_item.currency)
+ expected_voucher_amount = Money(Decimal(1), checkout_with_single_item.currency)
expected_price = variant.get_price(
channel_listing=checkout_line_info.channel_listing,
)
@@ -403,7 +403,7 @@ def test_calculate_base_line_total_price_with_1_cent_variant_on_10_percentage_di
checkout_line.save()
rule = PromotionRule.objects.first()
- rule.reward_value = Decimal("10")
+ rule.reward_value = Decimal(10)
rule.reward_value_type = RewardValueType.PERCENTAGE
# Set product price to 0.01 USD
@@ -502,7 +502,7 @@ def test_calculate_base_line_total_price_with_percentage_voucher(
total_price = calculate_base_line_total_price(checkout_line_info)
# then
- expected_voucher_amount = Money(Decimal("1"), checkout_with_single_item.currency)
+ expected_voucher_amount = Money(Decimal(1), checkout_with_single_item.currency)
expected_unit_price = variant.get_price(
channel_listing=checkout_line_info.channel_listing,
)
@@ -541,7 +541,7 @@ def test_calculate_base_line_total_price_with_discounts_apply_once_per_order(
total_price = calculate_base_line_total_price(checkout_line_info)
# then
- expected_voucher_amount = Money(Decimal("1"), checkout_with_single_item.currency)
+ expected_voucher_amount = Money(Decimal(1), checkout_with_single_item.currency)
expected_unit_price = variant.get_price(
channel_listing=checkout_line_info.channel_listing,
)
diff --git a/saleor/checkout/tests/test_calculations.py b/saleor/checkout/tests/test_calculations.py
index fbe7992626..f7c5c011e4 100644
--- a/saleor/checkout/tests/test_calculations.py
+++ b/saleor/checkout/tests/test_calculations.py
@@ -48,7 +48,7 @@ from ..fetch import CheckoutLineInfo, fetch_checkout_info, fetch_checkout_lines
@pytest.fixture
def tax_data(checkout_with_items, checkout_lines):
checkout = checkout_with_items
- tax_rate = Decimal("23")
+ tax_rate = Decimal(23)
net = Decimal("10.000")
gross = Decimal("12.300")
lines = checkout_lines
diff --git a/saleor/checkout/tests/test_checkout.py b/saleor/checkout/tests/test_checkout.py
index f6cf347fad..cb5455c1f3 100644
--- a/saleor/checkout/tests/test_checkout.py
+++ b/saleor/checkout/tests/test_checkout.py
@@ -1607,7 +1607,7 @@ def test_recalculate_checkout_discount_with_promotion(
)
line_info = lines[0]
- reward_value = Decimal("1")
+ reward_value = Decimal(1)
rule = catalogue_promotion_without_rules.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
@@ -1691,7 +1691,7 @@ def test_recalculate_checkout_discount_with_checkout_discount_voucher_not_applic
checkout_info = fetch_checkout_info(checkout, lines, manager)
line_info = lines[0]
- reward_value = Decimal("1")
+ reward_value = Decimal(1)
rule = catalogue_promotion_without_rules.rules.create(
name="Fixed promotion rule",
order_predicate={
diff --git a/saleor/checkout/tests/test_tasks.py b/saleor/checkout/tests/test_tasks.py
index dc48328154..d1845fa5d6 100644
--- a/saleor/checkout/tests/test_tasks.py
+++ b/saleor/checkout/tests/test_tasks.py
@@ -48,7 +48,7 @@ def test_delete_expired_anonymous_checkouts(checkouts_list, variant, customer_us
variant=variant,
quantity=1,
undiscounted_unit_price_amount=variant_listings_map.get(
- expired_anonymous_checkout.channel_id, Decimal("11")
+ expired_anonymous_checkout.channel_id, Decimal(11)
),
)
)
@@ -64,7 +64,7 @@ def test_delete_expired_anonymous_checkouts(checkouts_list, variant, customer_us
variant=variant,
quantity=1,
undiscounted_unit_price_amount=variant_listings_map.get(
- not_expired_checkout_1.channel_id, Decimal("11")
+ not_expired_checkout_1.channel_id, Decimal(11)
),
)
)
@@ -80,7 +80,7 @@ def test_delete_expired_anonymous_checkouts(checkouts_list, variant, customer_us
variant=variant,
quantity=1,
undiscounted_unit_price_amount=variant_listings_map.get(
- not_expired_checkout_2.channel_id, Decimal("11")
+ not_expired_checkout_2.channel_id, Decimal(11)
),
)
)
@@ -96,7 +96,7 @@ def test_delete_expired_anonymous_checkouts(checkouts_list, variant, customer_us
variant=variant,
quantity=1,
undiscounted_unit_price_amount=variant_listings_map.get(
- not_expired_checkout_3.channel_id, Decimal("11")
+ not_expired_checkout_3.channel_id, Decimal(11)
),
)
)
@@ -148,7 +148,7 @@ def test_delete_expired_user_checkouts(checkouts_list, variant, customer_user):
variant=variant,
quantity=1,
undiscounted_unit_price_amount=variant_listings_map.get(
- expired_user_checkout_1.channel_id, Decimal("11")
+ expired_user_checkout_1.channel_id, Decimal(11)
),
)
)
@@ -164,7 +164,7 @@ def test_delete_expired_user_checkouts(checkouts_list, variant, customer_user):
variant=variant,
quantity=1,
undiscounted_unit_price_amount=variant_listings_map.get(
- expired_user_checkout_2.channel_id, Decimal("11")
+ expired_user_checkout_2.channel_id, Decimal(11)
),
)
)
@@ -180,7 +180,7 @@ def test_delete_expired_user_checkouts(checkouts_list, variant, customer_user):
variant=variant,
quantity=1,
undiscounted_unit_price_amount=variant_listings_map.get(
- not_expired_checkout_1.channel_id, Decimal("11")
+ not_expired_checkout_1.channel_id, Decimal(11)
),
)
)
@@ -196,7 +196,7 @@ def test_delete_expired_user_checkouts(checkouts_list, variant, customer_user):
variant=variant,
quantity=1,
undiscounted_unit_price_amount=variant_listings_map.get(
- not_expired_checkout_2.channel_id, Decimal("11")
+ not_expired_checkout_2.channel_id, Decimal(11)
),
)
)
@@ -212,7 +212,7 @@ def test_delete_expired_user_checkouts(checkouts_list, variant, customer_user):
variant=variant,
quantity=1,
undiscounted_unit_price_amount=variant_listings_map.get(
- not_expired_checkout_3.channel_id, Decimal("11")
+ not_expired_checkout_3.channel_id, Decimal(11)
),
)
)
@@ -304,7 +304,7 @@ def test_delete_expired_checkouts(checkouts_list, customer_user, variant):
variant=variant,
quantity=1,
undiscounted_unit_price_amount=variant_listings_map.get(
- expired_anonymous_checkout.channel_id, Decimal("11")
+ expired_anonymous_checkout.channel_id, Decimal(11)
),
)
)
@@ -319,7 +319,7 @@ def test_delete_expired_checkouts(checkouts_list, customer_user, variant):
variant=variant,
quantity=1,
undiscounted_unit_price_amount=variant_listings_map.get(
- expired_user_checkout.channel_id, Decimal("11")
+ expired_user_checkout.channel_id, Decimal(11)
),
)
)
@@ -404,7 +404,7 @@ def test_delete_expired_checkouts_doesnt_delete_when_transaction_amount_exists(
variant=variant,
quantity=1,
undiscounted_unit_price_amount=variant_listings_map.get(
- expired_anonymous_checkout.channel_id, Decimal("11")
+ expired_anonymous_checkout.channel_id, Decimal(11)
),
)
)
@@ -444,7 +444,7 @@ def test_delete_expired_checkouts_doesnt_delete_when_transaction_amount_exists(
variant=variant,
quantity=1,
undiscounted_unit_price_amount=variant_listings_map.get(
- expired_user_checkout.channel_id, Decimal("11")
+ expired_user_checkout.channel_id, Decimal(11)
),
)
)
diff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.py
index 5f85135a8c..73738873ed 100644
--- a/saleor/checkout/utils.py
+++ b/saleor/checkout/utils.py
@@ -934,7 +934,7 @@ def remove_voucher_from_checkout(checkout: Checkout):
checkout.voucher_code = None
checkout.discount_name = None
checkout.translated_discount_name = None
- checkout.discount_amount = Decimal("0")
+ checkout.discount_amount = Decimal(0)
checkout.save(
update_fields=[
"voucher_code",
diff --git a/saleor/core/db/filters.py b/saleor/core/db/filters.py
index e96a83ba96..3cb59add45 100644
--- a/saleor/core/db/filters.py
+++ b/saleor/core/db/filters.py
@@ -7,5 +7,5 @@ class PostgresILike(IContains):
def as_postgresql(self, compiler, connection):
lhs, lhs_params = self.process_lhs(compiler, connection)
rhs, rhs_params = self.process_rhs(compiler, connection)
- params = lhs_params + rhs_params
+ params = lhs_params + rhs_params # type: ignore[operator]
return f"{lhs} ILIKE {rhs}", params
diff --git a/saleor/core/logging.py b/saleor/core/logging.py
index 6bade78ea3..734a002485 100644
--- a/saleor/core/logging.py
+++ b/saleor/core/logging.py
@@ -8,7 +8,7 @@ from .. import __version__ as saleor_version
class JsonFormatter(BaseFormatter):
- converter = time.gmtime
+ converter = time.gmtime # type: ignore[assignment]
def add_fields(self, log_record, record, message_dict):
super().add_fields(log_record, record, message_dict)
diff --git a/saleor/core/prices.py b/saleor/core/prices.py
index 0271152ecc..3195b5c9d3 100644
--- a/saleor/core/prices.py
+++ b/saleor/core/prices.py
@@ -18,7 +18,9 @@ MAXIMUM_PRICE = (
)
-def quantize_price(price: PriceType, currency: str) -> PriceType:
+def quantize_price[PriceType: (TaxedMoney, Money, Decimal, TaxedMoneyRange)](
+ price: PriceType, currency: str
+) -> PriceType:
precision = get_currency_precision(currency)
number_places = Decimal(10) ** -precision
return price.quantize(number_places)
diff --git a/saleor/discount/tests/fixtures/benchmark.py b/saleor/discount/tests/fixtures/benchmark.py
index 4d6d3fc322..651c6ef8a4 100644
--- a/saleor/discount/tests/fixtures/benchmark.py
+++ b/saleor/discount/tests/fixtures/benchmark.py
@@ -22,7 +22,7 @@ def promotion_list_for_benchmark(channel_USD, channel_PLN, product_list):
promotion=promotion,
catalogue_predicate={},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("10"),
+ reward_value=Decimal(10),
)
for promotion in promotions
]
diff --git a/saleor/discount/tests/fixtures/promotion.py b/saleor/discount/tests/fixtures/promotion.py
index 198718a1d6..bdd9168c58 100644
--- a/saleor/discount/tests/fixtures/promotion.py
+++ b/saleor/discount/tests/fixtures/promotion.py
@@ -33,7 +33,7 @@ def catalogue_promotion(channel_USD, product, collection):
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("10"),
+ reward_value=Decimal(10),
),
PromotionRule(
name="Fixed promotion rule",
@@ -47,7 +47,7 @@ def catalogue_promotion(channel_USD, product, collection):
}
},
reward_value_type=RewardValueType.FIXED,
- reward_value=Decimal("5"),
+ reward_value=Decimal(5),
),
]
)
@@ -156,7 +156,7 @@ def promotion_list(channel_USD, product, collection):
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("10"),
+ reward_value=Decimal(10),
),
PromotionRule(
name="Promotion 1 fixed rule",
@@ -170,7 +170,7 @@ def promotion_list(channel_USD, product, collection):
}
},
reward_value_type=RewardValueType.FIXED,
- reward_value=Decimal("5"),
+ reward_value=Decimal(5),
),
PromotionRule(
name="Promotion 2 percentage rule",
@@ -184,7 +184,7 @@ def promotion_list(channel_USD, product, collection):
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("10"),
+ reward_value=Decimal(10),
),
PromotionRule(
name="Promotion 3 fixed rule",
@@ -198,7 +198,7 @@ def promotion_list(channel_USD, product, collection):
}
},
reward_value_type=RewardValueType.FIXED,
- reward_value=Decimal("5"),
+ reward_value=Decimal(5),
),
]
)
@@ -225,7 +225,7 @@ def promotion_10_percentage(channel_USD, product_list, product):
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("10"),
+ reward_value=Decimal(10),
)
rule.channels.add(channel_USD)
return promotion
@@ -324,7 +324,7 @@ def promotion_converted_from_sale_list(channel_USD, product_list, category, coll
promotion=promotion,
catalogue_predicate=predicate,
reward_value_type=RewardValueType.FIXED,
- reward_value=Decimal("5"),
+ reward_value=Decimal(5),
)
for promotion, predicate in zip(promotions, predicates, strict=False)
]
diff --git a/saleor/discount/tests/fixtures/promotion_rule.py b/saleor/discount/tests/fixtures/promotion_rule.py
index 31636e1b2c..2a6a85687d 100644
--- a/saleor/discount/tests/fixtures/promotion_rule.py
+++ b/saleor/discount/tests/fixtures/promotion_rule.py
@@ -21,7 +21,7 @@ def promotion_rule(channel_USD, catalogue_promotion, product):
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("25"),
+ reward_value=Decimal(25),
)
rule.channels.add(channel_USD)
return rule
@@ -36,7 +36,7 @@ def order_promotion_rule(channel_USD, order_promotion_without_rules):
"discountedObjectPredicate": {"baseSubtotalPrice": {"range": {"gte": 20}}}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("25"),
+ reward_value=Decimal(25),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
)
rule.channels.add(channel_USD)
@@ -69,7 +69,7 @@ def rule_info(
variant_channel_listing = variant.channel_listings.get(channel_id=channel_USD.id)
listing_promotion_rule = variant_channel_listing.variantlistingpromotionrule.create(
promotion_rule=promotion_rule,
- discount_amount=Decimal("10"),
+ discount_amount=Decimal(10),
currency=channel_USD.currency_code,
)
return VariantPromotionRuleInfo(
diff --git a/saleor/discount/tests/test_discounts.py b/saleor/discount/tests/test_discounts.py
index 77e40b3f17..07adeac641 100644
--- a/saleor/discount/tests/test_discounts.py
+++ b/saleor/discount/tests/test_discounts.py
@@ -109,7 +109,7 @@ def test_valid_voucher_min_checkout_items_quantity(voucher):
def test_percentage_discounts(product, channel_USD, catalogue_promotion_without_rules):
# given
variant = product.variants.get()
- reward_value = Decimal("50")
+ reward_value = Decimal(50)
rule = catalogue_promotion_without_rules.rules.create(
catalogue_predicate={
"productPredicate": {
@@ -123,10 +123,10 @@ def test_percentage_discounts(product, channel_USD, catalogue_promotion_without_
variant_channel_listing = variant.channel_listings.get(channel=channel_USD)
variant_channel_listing.variantlistingpromotionrule.create(
promotion_rule=rule,
- discount_amount=Decimal("5"),
+ discount_amount=Decimal(5),
currency=channel_USD.currency_code,
)
- price = Decimal("10")
+ price = Decimal(10)
# when
final_price = variant.get_price(
@@ -142,7 +142,7 @@ def test_percentage_discounts(product, channel_USD, catalogue_promotion_without_
def test_fixed_discounts(product, channel_USD, catalogue_promotion_without_rules):
# given
variant = product.variants.get()
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = catalogue_promotion_without_rules.rules.create(
catalogue_predicate={
"productPredicate": {
@@ -156,10 +156,10 @@ def test_fixed_discounts(product, channel_USD, catalogue_promotion_without_rules
variant_channel_listing = variant.channel_listings.get(channel=channel_USD)
variant_channel_listing.variantlistingpromotionrule.create(
promotion_rule=rule,
- discount_amount=Decimal("1"),
+ discount_amount=Decimal(1),
currency=channel_USD.currency_code,
)
- price = Decimal("10")
+ price = Decimal(10)
# when
final_price = variant.get_price(
diff --git a/saleor/discount/tests/test_tasks.py b/saleor/discount/tests/test_tasks.py
index dbc1c2abf9..ec1b9d4ee4 100644
--- a/saleor/discount/tests/test_tasks.py
+++ b/saleor/discount/tests/test_tasks.py
@@ -93,7 +93,7 @@ def test_handle_promotion_toggle(
}
},
reward_value_type=RewardValueType.FIXED,
- reward_value=Decimal("5"),
+ reward_value=Decimal(5),
)
)
diff --git a/saleor/discount/tests/test_utils/test_calculate_discounted_price_for_promotions.py b/saleor/discount/tests/test_utils/test_calculate_discounted_price_for_promotions.py
index 6e4f01621a..f5f8f052af 100644
--- a/saleor/discount/tests/test_utils/test_calculate_discounted_price_for_promotions.py
+++ b/saleor/discount/tests/test_utils/test_calculate_discounted_price_for_promotions.py
@@ -33,7 +33,7 @@ def test_variant_discounts_multiple_promotions(product, channel_USD):
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("10"),
+ reward_value=Decimal(10),
),
PromotionRule(
name="Promotion 2 percentage rule",
@@ -44,7 +44,7 @@ def test_variant_discounts_multiple_promotions(product, channel_USD):
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("50"),
+ reward_value=Decimal(50),
),
]
)
@@ -106,7 +106,7 @@ def test_variant_discounts_multiple_promotions_and_rules(product, channel_USD):
}
},
reward_value_type=RewardValueType.FIXED,
- reward_value=Decimal("1"),
+ reward_value=Decimal(1),
),
PromotionRule(
name="Promotion rule 2",
@@ -117,7 +117,7 @@ def test_variant_discounts_multiple_promotions_and_rules(product, channel_USD):
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("5"),
+ reward_value=Decimal(5),
),
PromotionRule(
name="Promotion rule 4",
@@ -128,7 +128,7 @@ def test_variant_discounts_multiple_promotions_and_rules(product, channel_USD):
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("50"),
+ reward_value=Decimal(50),
),
]
)
diff --git a/saleor/discount/tests/test_utils/test_copy_unit_discount_data_to_order_line.py b/saleor/discount/tests/test_utils/test_copy_unit_discount_data_to_order_line.py
index f07a968d22..2e46a6bd81 100644
--- a/saleor/discount/tests/test_utils/test_copy_unit_discount_data_to_order_line.py
+++ b/saleor/discount/tests/test_utils/test_copy_unit_discount_data_to_order_line.py
@@ -23,7 +23,7 @@ def test_copy_unit_discount_data_to_order_line_multiple_discounts(
rule_discount.reason = rule_discount_reason
rule_discount.save(update_fields=["reason"])
- manual_reward_value = Decimal("2")
+ manual_reward_value = Decimal(2)
manual_discount_reason = "Manual discount"
line.discounts.create(
type=DiscountType.MANUAL,
diff --git a/saleor/discount/tests/test_utils/test_create_or_update_discount_objects_from_promotion_for_checkout.py b/saleor/discount/tests/test_utils/test_create_or_update_discount_objects_from_promotion_for_checkout.py
index 7a25f7fdd2..ddb4ee920e 100644
--- a/saleor/discount/tests/test_utils/test_create_or_update_discount_objects_from_promotion_for_checkout.py
+++ b/saleor/discount/tests/test_utils/test_create_or_update_discount_objects_from_promotion_for_checkout.py
@@ -55,7 +55,7 @@ def test_create_fixed_discount(
line_info1 = checkout_lines_info[0]
product_line1 = line_info1.product
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
rule = catalogue_promotion_without_rules.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
@@ -153,7 +153,7 @@ def test_update_catalogue_discount(
line_info1 = checkout_lines_info[0]
product_line1 = line_info1.product
- actual_reward_value = Decimal("5")
+ actual_reward_value = Decimal(5)
discount_to_update = line_info1.line.discounts.create(
type=DiscountType.PROMOTION,
value_type=RewardValueType.FIXED,
@@ -164,7 +164,7 @@ def test_update_catalogue_discount(
)
checkout_lines_info[0].discounts.append(discount_to_update)
- reward_value = Decimal("7")
+ reward_value = Decimal(7)
assert reward_value > actual_reward_value
rule = catalogue_promotion_without_rules.rules.create(
name="Percentage promotion rule",
@@ -226,7 +226,7 @@ def test_create_fixed_discount_multiple_quantity_in_lines(
line_info1 = checkout_lines_with_multiple_quantity_info[0]
product_line1 = line_info1.product
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
rule = catalogue_promotion_without_rules.rules.create(
catalogue_predicate={
"productPredicate": {
@@ -329,7 +329,7 @@ def test_create_fixed_discount_multiple_quantity_in_lines_discount_bigger_than_t
rule.channels.add(line_info1.channel)
listing = line_info1.channel_listing
- discounted_price = Decimal("0")
+ discounted_price = Decimal(0)
listing.discounted_price_amount = discounted_price
listing.save(update_fields=["discounted_price_amount"])
@@ -387,7 +387,7 @@ def test_create_percentage_discount(
line_info1 = checkout_lines_info[0]
product_line1 = line_info1.product
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
rule = catalogue_promotion_without_rules.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
@@ -478,7 +478,7 @@ def test_create_percentage_discount_multiple_quantity_in_lines(
line_info1 = checkout_lines_with_multiple_quantity_info[0]
product_line1 = line_info1.product
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
rule = catalogue_promotion_without_rules.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
@@ -568,8 +568,8 @@ def test_two_promotions_applied_to_two_different_lines(
line_info2 = checkout_lines_info[1]
product_line2 = line_info2.product
- reward_value_1 = Decimal("2")
- reward_value_2 = Decimal("1")
+ reward_value_1 = Decimal(2)
+ reward_value_2 = Decimal(1)
rule_1, rule_2 = PromotionRule.objects.bulk_create(
[
PromotionRule(
@@ -744,7 +744,7 @@ def test_create_percentage_discount_1_cent_variant_on_10_percentage_discount(
product_line1 = line_info1.product
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
rule = catalogue_promotion_without_rules.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
@@ -839,7 +839,7 @@ def test_promotion_not_valid_anymore(
line_info1 = checkout_lines_info[0]
product_line1 = line_info1.product
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
rule = catalogue_promotion_without_rules.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
@@ -885,8 +885,8 @@ def test_one_of_promotion_rule_not_valid_anymore_one_updated(
line_info1 = checkout_lines_info[0]
product_line1 = line_info1.product
- reward_value_1 = Decimal("2")
- reward_value_2 = Decimal("10")
+ reward_value_1 = Decimal(2)
+ reward_value_2 = Decimal(10)
rule_1, rule_2 = PromotionRule.objects.bulk_create(
[
PromotionRule(
@@ -938,7 +938,7 @@ def test_one_of_promotion_rule_not_valid_anymore_one_updated(
CheckoutLineDiscount(
line=line_info1.line,
value_type=RewardValueType.PERCENTAGE,
- value=Decimal("10"),
+ value=Decimal(10),
currency=line_info1.channel.currency_code,
type=DiscountType.PROMOTION,
promotion_rule=rule_1,
@@ -1043,7 +1043,7 @@ def test_create_discount_with_promotion_translation(
line_info1 = checkout_lines_info[0]
product_line1 = line_info1.product
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
rule = catalogue_promotion_without_rules.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
@@ -1107,7 +1107,7 @@ def test_create_discount_with_rule_translation(
line_info1 = checkout_lines_info[0]
product_line1 = line_info1.product
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
rule = catalogue_promotion_without_rules.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
@@ -1172,7 +1172,7 @@ def test_create_discount_with_promotion_and_rule_translation(
line_info1 = checkout_lines_info[0]
product_line1 = line_info1.product
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
rule = catalogue_promotion_without_rules.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
@@ -1239,7 +1239,7 @@ def test_create_or_update_discount_for_gift_promotion_line(
gift_line_discount = gift_line_info.line.discounts.first()
gift_product = gift_line_info.line.variant.product
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
rule = catalogue_promotion_without_rules.rules.create(
catalogue_predicate={
"productPredicate": {
@@ -1366,7 +1366,7 @@ def test_create_or_update_discount_objects_from_promotion(
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("25"),
+ reward_value=Decimal(25),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
),
PromotionRule(
@@ -1382,7 +1382,7 @@ def test_create_or_update_discount_objects_from_promotion(
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("50"),
+ reward_value=Decimal(50),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
),
]
@@ -1445,7 +1445,7 @@ def test_create_or_update_discount_objects_from_promotion_best_rule_applies(
}
},
reward_value_type=RewardValueType.FIXED,
- reward_value=Decimal("12"),
+ reward_value=Decimal(12),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
),
PromotionRule(
@@ -1461,7 +1461,7 @@ def test_create_or_update_discount_objects_from_promotion_best_rule_applies(
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("25"),
+ reward_value=Decimal(25),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
),
PromotionRule(
@@ -1477,7 +1477,7 @@ def test_create_or_update_discount_objects_from_promotion_best_rule_applies(
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("50"),
+ reward_value=Decimal(50),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
),
]
@@ -1550,7 +1550,7 @@ def test_create_or_update_discount_objects_from_promotion_subtotal_price_discoun
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("50"),
+ reward_value=Decimal(50),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
),
]
@@ -1627,7 +1627,7 @@ def test_update_gift_discount(
gift_line.save(update_fields=["variant"])
gift_discount = gift_line.discounts.first()
- gift_discount.value = Decimal("2")
+ gift_discount.value = Decimal(2)
gift_discount.save(update_fields=["value"])
lines_info, _ = fetch_checkout_lines(checkout)
@@ -1717,7 +1717,7 @@ def test_create_or_update_discount_objects_from_promotion_gift_rule_applies(
}
},
reward_value_type=RewardValueType.FIXED,
- reward_value=top_price - Decimal("1"),
+ reward_value=top_price - Decimal(1),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
),
PromotionRule(
@@ -1731,7 +1731,7 @@ def test_create_or_update_discount_objects_from_promotion_gift_rule_applies(
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=top_price - Decimal("2"),
+ reward_value=top_price - Decimal(2),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
),
PromotionRule(
@@ -1745,7 +1745,7 @@ def test_create_or_update_discount_objects_from_promotion_gift_rule_applies(
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=top_price + Decimal("10"),
+ reward_value=top_price + Decimal(10),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
),
]
@@ -1811,8 +1811,8 @@ def test_create_or_update_discount_objects_from_promotion_gift_line_removed(
subtotal_mock.return_value = price
delivery_price_mock.return_value = delivery_price
- reward_value_1 = top_price + Decimal("2")
- reward_value_2 = top_price + Decimal("10")
+ reward_value_1 = top_price + Decimal(2)
+ reward_value_2 = top_price + Decimal(10)
rules = PromotionRule.objects.bulk_create(
[
PromotionRule(
@@ -1914,7 +1914,7 @@ def test_create_or_update_discount_from_promotion_voucher_code_set_checkout_disc
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("25"),
+ reward_value=Decimal(25),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
)
rule.channels.add(checkout_info.channel)
@@ -1972,7 +1972,7 @@ def test_create_or_update_discount_from_promotion_checkout_discount_updated(
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("25"),
+ reward_value=Decimal(25),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
)
rule.channels.add(checkout_info.channel)
@@ -2037,7 +2037,7 @@ def test_create_or_update_discount_from_promotion_rule_not_applies_anymore(
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("25"),
+ reward_value=Decimal(25),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
)
rule.channels.add(checkout_info.channel)
@@ -2070,7 +2070,7 @@ def test_create_discount_objects_for_order_promotions_race_condition(
checkout = checkout_info.checkout
channel = checkout_info.channel
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
rule = promotion.rules.create(
order_predicate={
"total_price": {
@@ -2094,7 +2094,7 @@ def test_create_discount_objects_for_order_promotions_race_condition(
}
},
reward_value_type=RewardValueType.FIXED,
- reward_value=Decimal("1"),
+ reward_value=Decimal(1),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
)
rule0.channels.add(channel)
@@ -2134,7 +2134,7 @@ def test_create_or_update_order_discount_race_condition(
promotion = catalogue_promotion_without_rules
channel = checkout_info.channel
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
rule = promotion.rules.create(
order_predicate={
"total_price": {
diff --git a/saleor/discount/tests/test_utils/test_create_voucher_discount_object_for_order.py b/saleor/discount/tests/test_utils/test_create_voucher_discount_object_for_order.py
index 8329bbf415..17406298f7 100644
--- a/saleor/discount/tests/test_utils/test_create_voucher_discount_object_for_order.py
+++ b/saleor/discount/tests/test_utils/test_create_voucher_discount_object_for_order.py
@@ -24,7 +24,7 @@ def test_create_discount_for_voucher_specific_product_fixed(
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- unit_discount_amount = Decimal("5")
+ unit_discount_amount = Decimal(5)
voucher_listing.discount_value = unit_discount_amount
voucher_listing.save(update_fields=["discount_value"])
voucher.discount_value_type = DiscountValueType.FIXED
@@ -124,7 +124,7 @@ def test_create_discount_for_voucher_specific_product_percentage(
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- discount_value = Decimal("10")
+ discount_value = Decimal(10)
voucher_listing.discount_value = discount_value
voucher_listing.save(update_fields=["discount_value"])
voucher.discount_value_type = DiscountValueType.PERCENTAGE
@@ -228,7 +228,7 @@ def test_create_discount_for_voucher_apply_once_per_order_percentage(
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- discount_value = Decimal("10")
+ discount_value = Decimal(10)
voucher_listing.discount_value = discount_value
voucher_listing.save(update_fields=["discount_value"])
@@ -338,7 +338,7 @@ def test_create_discount_for_voucher_apply_once_per_order_fixed(
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- discount_amount = Decimal("5")
+ discount_amount = Decimal(5)
voucher_listing.discount_value = discount_amount
voucher_listing.save(update_fields=["discount_value"])
@@ -445,7 +445,7 @@ def test_create_discount_for_voucher_entire_order_fixed(
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- discount_amount = Decimal("35")
+ discount_amount = Decimal(35)
voucher_listing.discount_value = discount_amount
voucher_listing.save(update_fields=["discount_value"])
@@ -560,7 +560,7 @@ def test_create_discount_for_voucher_entire_order_multiple_lines(
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- discount_amount = Decimal("3")
+ discount_amount = Decimal(3)
voucher_listing.discount_value = discount_amount
voucher_listing.save(update_fields=["discount_value"])
@@ -655,7 +655,7 @@ def test_create_discount_for_voucher_entire_order_percentage(
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- discount_value = Decimal("50")
+ discount_value = Decimal(50)
voucher_listing.discount_value = discount_value
voucher_listing.save(update_fields=["discount_value"])
@@ -764,7 +764,7 @@ def test_create_discount_for_voucher_shipping_fixed(
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- discount_value = Decimal("5")
+ discount_value = Decimal(5)
voucher_listing.discount_value = discount_value
voucher_listing.save(update_fields=["discount_value"])
@@ -840,7 +840,7 @@ def test_create_discount_for_voucher_shipping_percentage(
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- discount_value = Decimal("50")
+ discount_value = Decimal(50)
voucher_listing.discount_value = discount_value
voucher_listing.save(update_fields=["discount_value"])
diff --git a/saleor/discount/tests/test_utils/test_fetch_promotion_rules_for_checkout.py b/saleor/discount/tests/test_utils/test_fetch_promotion_rules_for_checkout.py
index 83fd9bd1b1..c886001869 100644
--- a/saleor/discount/tests/test_utils/test_fetch_promotion_rules_for_checkout.py
+++ b/saleor/discount/tests/test_utils/test_fetch_promotion_rules_for_checkout.py
@@ -71,7 +71,7 @@ def test_fetch_promotion_rules_for_checkout_relevant_channel_only(
promotion=promotion,
order_predicate=order_predicate,
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("10"),
+ reward_value=Decimal(10),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
)
rule_2.channels.add(checkout_JPY.channel)
diff --git a/saleor/discount/tests/test_utils/test_fetch_promotion_rules_for_order.py b/saleor/discount/tests/test_utils/test_fetch_promotion_rules_for_order.py
index bc709522cf..34f5fdc381 100644
--- a/saleor/discount/tests/test_utils/test_fetch_promotion_rules_for_order.py
+++ b/saleor/discount/tests/test_utils/test_fetch_promotion_rules_for_order.py
@@ -56,7 +56,7 @@ def test_fetch_promotion_rules_for_order_relevant_channel_only(
promotion=promotion,
order_predicate=order_predicate,
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("10"),
+ reward_value=Decimal(10),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
)
rule_2.channels.add(order_JPY.channel)
diff --git a/saleor/discount/tests/test_utils/test_get_variants_to_promotions_map.py b/saleor/discount/tests/test_utils/test_get_variants_to_promotions_map.py
index 330853ea95..0a78a07fb1 100644
--- a/saleor/discount/tests/test_utils/test_get_variants_to_promotions_map.py
+++ b/saleor/discount/tests/test_utils/test_get_variants_to_promotions_map.py
@@ -16,8 +16,8 @@ def test_get_variants_to_promotions_map(
promotion = catalogue_promotion_without_rules
variant = product.variants.first()
- percentage_reward_value = Decimal("10")
- reward_value = Decimal("2")
+ percentage_reward_value = Decimal(10)
+ reward_value = Decimal(2)
rule_1 = promotion.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
@@ -72,8 +72,8 @@ def test_get_variants_to_promotions_map_from_different_promotions(
)
variant = product.variants.first()
- percentage_reward_value = Decimal("10")
- reward_value = Decimal("2")
+ percentage_reward_value = Decimal(10)
+ reward_value = Decimal(2)
rule_1 = promotion.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
@@ -133,7 +133,7 @@ def test_get_variants_to_promotions_map_no_matching_rules(
# given
promotion = catalogue_promotion_without_rules
- percentage_reward_value = Decimal("10")
+ percentage_reward_value = Decimal(10)
rule = promotion.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
diff --git a/saleor/discount/tests/test_utils/test_mark_active_promotion_rules_as_dirty.py b/saleor/discount/tests/test_utils/test_mark_active_promotion_rules_as_dirty.py
index e6df63cf9b..d94bde27ac 100644
--- a/saleor/discount/tests/test_utils/test_mark_active_promotion_rules_as_dirty.py
+++ b/saleor/discount/tests/test_utils/test_mark_active_promotion_rules_as_dirty.py
@@ -56,7 +56,7 @@ def test_mark_active_catalogue_promotion_rules_as_dirty_with_multiple_channels(
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("10"),
+ reward_value=Decimal(10),
variants_dirty=False,
)
@@ -104,7 +104,7 @@ def test_mark_active_promotion_rules_as_dirty_with_multiple_promotions_and_chann
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("10"),
+ reward_value=Decimal(10),
variants_dirty=False,
)
diff --git a/saleor/discount/tests/test_utils/test_mark_promotion_rules_as_dirty.py b/saleor/discount/tests/test_utils/test_mark_promotion_rules_as_dirty.py
index a74360a837..38c3c64db8 100644
--- a/saleor/discount/tests/test_utils/test_mark_promotion_rules_as_dirty.py
+++ b/saleor/discount/tests/test_utils/test_mark_promotion_rules_as_dirty.py
@@ -38,7 +38,7 @@ def test_mark_catalogue_promotion_rules_as_dirty_single_promotion(
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("10"),
+ reward_value=Decimal(10),
variants_dirty=False,
)
@@ -76,7 +76,7 @@ def test_mark_catalogue_promotion_rules_as_dirty_multiple_promotion(
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("10"),
+ reward_value=Decimal(10),
variants_dirty=False,
)
diff --git a/saleor/discount/tests/test_utils/test_update_rule_variant_relation.py b/saleor/discount/tests/test_utils/test_update_rule_variant_relation.py
index 0d0e29f0eb..62da21f117 100644
--- a/saleor/discount/tests/test_utils/test_update_rule_variant_relation.py
+++ b/saleor/discount/tests/test_utils/test_update_rule_variant_relation.py
@@ -24,7 +24,7 @@ def test_update_rule_variant_relation(
]
new_variant_ids = [variant.id for variant in new_variants]
- percentage_reward_value = Decimal("10")
+ percentage_reward_value = Decimal(10)
rule = promotion.rules.create(
name="Percentage promotion rule",
catalogue_predicate={"variantPredicate": {"ids": new_variant_global_ids}},
diff --git a/saleor/discount/tests/test_utils/test_update_voucher_discount_object_for_order.py b/saleor/discount/tests/test_utils/test_update_voucher_discount_object_for_order.py
index 2fd846f23a..ae4975523c 100644
--- a/saleor/discount/tests/test_utils/test_update_voucher_discount_object_for_order.py
+++ b/saleor/discount/tests/test_utils/test_update_voucher_discount_object_for_order.py
@@ -323,7 +323,7 @@ def test_update_voucher_discount_apply_once_per_order_with_specific_product(
# apply specific product voucher for line 1 variant
voucher_listing_2 = voucher_2.channel_listings.get(channel=order.channel)
- voucher_2_discount_value = Decimal("20")
+ voucher_2_discount_value = Decimal(20)
voucher_listing_2.discount_value = voucher_2_discount_value
voucher_listing_2.save(update_fields=["discount_value"])
order.voucher = voucher_2
@@ -443,7 +443,7 @@ def test_update_voucher_discount_specific_product_with_entire_order(
# apply entire order voucher
voucher_listing_2 = voucher_2.channel_listings.get(channel=order.channel)
- voucher_2_discount_value = Decimal("20")
+ voucher_2_discount_value = Decimal(20)
voucher_listing_2.discount_value = voucher_2_discount_value
voucher_listing_2.save(update_fields=["discount_value"])
order.voucher = voucher_2
@@ -839,7 +839,7 @@ def test_update_voucher_discount_shipping_with_entire_order(
# apply entire order voucher
voucher_listing_2 = voucher_2.channel_listings.get(channel=order.channel)
- voucher_2_discount_value = Decimal("20")
+ voucher_2_discount_value = Decimal(20)
voucher_listing_2.discount_value = voucher_2_discount_value
voucher_listing_2.save(update_fields=["discount_value"])
order.voucher = voucher_2
diff --git a/saleor/discount/utils/manual_discount.py b/saleor/discount/utils/manual_discount.py
index f0addd82f9..4f63b6d5b6 100644
--- a/saleor/discount/utils/manual_discount.py
+++ b/saleor/discount/utils/manual_discount.py
@@ -12,7 +12,7 @@ from ..models import OrderDiscount
T = TypeVar("T", Money, TaxedMoney)
-def apply_discount_to_value(
+def apply_discount_to_value[T: (Money, TaxedMoney)](
value: Decimal,
value_type: str | None,
currency: str,
diff --git a/saleor/graphql/account/dataloaders.py b/saleor/graphql/account/dataloaders.py
index 08e8e418f0..8c539d52c7 100644
--- a/saleor/graphql/account/dataloaders.py
+++ b/saleor/graphql/account/dataloaders.py
@@ -1,6 +1,6 @@
from collections import defaultdict
from collections.abc import Iterable
-from typing import Generic, TypeVar, cast
+from typing import TypeVar, cast
from ...account.models import Address, CustomerEvent, Group, User
from ...channel.models import Channel
@@ -87,7 +87,7 @@ class PermissionByCodenameLoader(DataLoader[str, Permission]):
K = TypeVar("K")
-class BaseAccessibleChannels(DataLoader[K, list[Channel]], Generic[K]):
+class BaseAccessibleChannels[K](DataLoader[K, list[Channel]]):
def get_group_to_channels_map(self, group_ids):
groups_with_no_channel_restriction = Group.objects.using(
self.database_connection_name
diff --git a/saleor/graphql/account/mutations/permission_group/permission_group_create.py b/saleor/graphql/account/mutations/permission_group/permission_group_create.py
index da8f47a4f1..f12869df98 100644
--- a/saleor/graphql/account/mutations/permission_group/permission_group_create.py
+++ b/saleor/graphql/account/mutations/permission_group/permission_group_create.py
@@ -137,7 +137,9 @@ class PermissionGroupCreate(DeprecatedModelMutation):
)
@classmethod
- def check_permissions(cls, context, permissions=None, **data):
+ def check_permissions(
+ cls, context, permissions=None, require_all_permissions=False, **data
+ ):
app = get_app_promise(context).get()
if app:
raise PermissionDenied(
diff --git a/saleor/graphql/account/mutations/permission_group/permission_group_delete.py b/saleor/graphql/account/mutations/permission_group/permission_group_delete.py
index 31da316726..5f984480e4 100644
--- a/saleor/graphql/account/mutations/permission_group/permission_group_delete.py
+++ b/saleor/graphql/account/mutations/permission_group/permission_group_delete.py
@@ -66,7 +66,9 @@ class PermissionGroupDelete(ModelDeleteMutation):
cls.check_if_group_can_be_removed(requestor, instance)
@classmethod
- def check_permissions(cls, context, permissions=None, **data):
+ def check_permissions(
+ cls, context, permissions=None, require_all_permissions=False, **data
+ ):
app = get_app_promise(context).get()
if app:
raise PermissionDenied(
diff --git a/saleor/graphql/account/mutations/permission_group/permission_group_update.py b/saleor/graphql/account/mutations/permission_group/permission_group_update.py
index 0839083ad8..4e4554a1bb 100644
--- a/saleor/graphql/account/mutations/permission_group/permission_group_update.py
+++ b/saleor/graphql/account/mutations/permission_group/permission_group_update.py
@@ -96,14 +96,9 @@ class PermissionGroupUpdate(PermissionGroupCreate):
cls.call_event(manager.permission_group_updated, instance)
@classmethod
- def clean_input(
- cls,
- info,
- instance,
- data,
- ):
+ def clean_input(cls, info: ResolveInfo, instance, data, **kwargs):
requestor = info.context.user
- cls.ensure_requestor_can_manage_group(info, requestor, instance)
+ cls.ensure_requestor_can_manage_group(info, requestor, instance) # type: ignore[arg-type]
errors: defaultdict[str, list[ValidationError]] = defaultdict(list)
permission_fields = ("add_permissions", "remove_permissions", "permissions")
diff --git a/saleor/graphql/account/mutations/staff/staff_create.py b/saleor/graphql/account/mutations/staff/staff_create.py
index 090839e52a..a3c93f0e42 100644
--- a/saleor/graphql/account/mutations/staff/staff_create.py
+++ b/saleor/graphql/account/mutations/staff/staff_create.py
@@ -86,7 +86,9 @@ class StaffCreate(DeprecatedModelMutation):
]
@classmethod
- def check_permissions(cls, context, permissions=None, **data):
+ def check_permissions(
+ cls, context, permissions=None, require_all_permissions=False, **data
+ ):
app = get_app_promise(context).get()
if app:
raise PermissionDenied(
diff --git a/saleor/graphql/app/mutations/app_activate.py b/saleor/graphql/app/mutations/app_activate.py
index eb53508840..5d0366923d 100644
--- a/saleor/graphql/app/mutations/app_activate.py
+++ b/saleor/graphql/app/mutations/app_activate.py
@@ -29,7 +29,7 @@ class AppActivate(DeprecatedModelMutation):
]
@classmethod
- def perform_mutation(cls, _root, info, /, *, id):
+ def perform_mutation(cls, _root, info, /, *, id): # type: ignore[override]
qs = models.App.objects.filter(removed_at__isnull=True)
app = cls.get_instance(
info,
diff --git a/saleor/graphql/app/mutations/app_deactivate.py b/saleor/graphql/app/mutations/app_deactivate.py
index 0346e1e6f0..74d607beb2 100644
--- a/saleor/graphql/app/mutations/app_deactivate.py
+++ b/saleor/graphql/app/mutations/app_deactivate.py
@@ -29,7 +29,7 @@ class AppDeactivate(DeprecatedModelMutation):
]
@classmethod
- def perform_mutation(cls, _root, info, /, *, id):
+ def perform_mutation(cls, _root, info, /, *, id): # type: ignore[override]
qs = models.App.objects.filter(removed_at__isnull=True)
app = cls.get_instance(
info,
diff --git a/saleor/graphql/app/mutations/app_token_create.py b/saleor/graphql/app/mutations/app_token_create.py
index 9591d7e050..4a740d7301 100644
--- a/saleor/graphql/app/mutations/app_token_create.py
+++ b/saleor/graphql/app/mutations/app_token_create.py
@@ -6,6 +6,7 @@ from ....app import models
from ....app.error_codes import AppErrorCode
from ....permission.enums import AppPermission
from ...account.utils import can_manage_app
+from ...core import ResolveInfo
from ...core.doc_category import DOC_CATEGORY_APPS
from ...core.mutations import DeprecatedModelMutation
from ...core.types import AppError, BaseInputObjectType
@@ -56,7 +57,7 @@ class AppTokenCreate(DeprecatedModelMutation):
return response
@classmethod
- def clean_input(cls, info, instance, data):
+ def clean_input(cls, info: ResolveInfo, instance, data, *, input_cls=None):
cleaned_input = super().clean_input(info, instance, data)
app = cleaned_input.get("app")
validate_app_is_not_removed(app, data.get("app"), "app")
diff --git a/saleor/graphql/app/mutations/app_update.py b/saleor/graphql/app/mutations/app_update.py
index 4c6918e10c..75dff33531 100644
--- a/saleor/graphql/app/mutations/app_update.py
+++ b/saleor/graphql/app/mutations/app_update.py
@@ -46,7 +46,7 @@ class AppUpdate(DeprecatedModelMutation):
return instance
@classmethod
- def clean_input(cls, info, instance, data, **kwargs):
+ def clean_input(cls, info: ResolveInfo, instance, data, **kwargs):
cleaned_input = super().clean_input(info, instance, data, **kwargs)
requestor = get_user_or_app_from_context(info.context)
if not requestor_is_superuser(requestor) and not can_manage_app(
diff --git a/saleor/graphql/channel/mutations/channel_update.py b/saleor/graphql/channel/mutations/channel_update.py
index 88a750f695..7b1bb009a4 100644
--- a/saleor/graphql/channel/mutations/channel_update.py
+++ b/saleor/graphql/channel/mutations/channel_update.py
@@ -139,7 +139,7 @@ class ChannelUpdate(DeprecatedModelMutation):
return cleaned_input
@classmethod
- def check_permissions(cls, context, permissions=None, **data):
+ def check_permissions(cls, context, permissions=None, **data): # type: ignore[override]
permissions = [ChannelPermissions.MANAGE_CHANNELS]
has_permission = super().check_permissions(
context, permissions, require_all_permissions=False, **data
diff --git a/saleor/graphql/checkout/mutations/checkout_shipping_address_update.py b/saleor/graphql/checkout/mutations/checkout_shipping_address_update.py
index 45c8e05b94..eb76726679 100644
--- a/saleor/graphql/checkout/mutations/checkout_shipping_address_update.py
+++ b/saleor/graphql/checkout/mutations/checkout_shipping_address_update.py
@@ -124,7 +124,7 @@ class CheckoutShippingAddressUpdate(AddressMetadataMixin, BaseMutation, I18nMixi
)
@classmethod
- def perform_mutation(
+ def perform_mutation( # type: ignore[override]
cls,
_root,
info,
diff --git a/saleor/graphql/checkout/mutations/order_create_from_checkout.py b/saleor/graphql/checkout/mutations/order_create_from_checkout.py
index 9cf1ee2409..3e1a0d220b 100644
--- a/saleor/graphql/checkout/mutations/order_create_from_checkout.py
+++ b/saleor/graphql/checkout/mutations/order_create_from_checkout.py
@@ -138,7 +138,7 @@ class OrderCreateFromCheckout(BaseMutation):
]
@classmethod
- def check_permissions(cls, context, permissions=None, **data):
+ def check_permissions(cls, context, permissions=None, **data): # type: ignore[override]
"""Determine whether app has rights to perform this mutation."""
permissions = permissions or cls._meta.permissions
app = getattr(context, "app", None)
diff --git a/saleor/graphql/checkout/mutations/utils.py b/saleor/graphql/checkout/mutations/utils.py
index 501b4f990b..5771635f8c 100644
--- a/saleor/graphql/checkout/mutations/utils.py
+++ b/saleor/graphql/checkout/mutations/utils.py
@@ -596,12 +596,12 @@ def _set_checkout_base_subtotal_and_total_on_checkout_creation(
channel_id=checkout.channel_id,
).values_list("variant_id", "discounted_price_amount", "price_amount")
}
- subtotal = Decimal("0")
+ subtotal = Decimal(0)
for line in checkout.lines.all():
if price_amount := line.price_override:
price = price_amount
else:
- price = variant_id_to_discounted_price.get(line.variant_id) or Decimal("0")
+ price = variant_id_to_discounted_price.get(line.variant_id) or Decimal(0)
subtotal += price * line.quantity
checkout.base_subtotal = Money(subtotal, checkout.currency)
# base total and subtotal is the same, as there is no option to set the
diff --git a/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_payment.py b/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_payment.py
index 619d90648f..9602a1eb7b 100644
--- a/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_payment.py
+++ b/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_payment.py
@@ -1153,7 +1153,7 @@ def test_checkout_with_order_promotion_complete(
"expected_voucher_discount_value",
),
[
- (True, DiscountValueType.FIXED, Decimal("1")),
+ (True, DiscountValueType.FIXED, Decimal(1)),
(False, DiscountValueType.PERCENTAGE, Decimal(10)),
],
)
@@ -1312,7 +1312,7 @@ def test_checkout_with_voucher_complete_product_on_promotion(
checkout_line_variant = checkout_line.variant
channel = checkout.channel
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = catalogue_promotion_without_rules.rules.create(
catalogue_predicate={
"productPredicate": {
@@ -1442,7 +1442,7 @@ def test_checkout_with_voucher_complete_product_on_promotion(
"expected_voucher_discount_value",
),
[
- (True, DiscountValueType.FIXED, Decimal("3")),
+ (True, DiscountValueType.FIXED, Decimal(3)),
(False, DiscountValueType.PERCENTAGE, Decimal(10)),
],
)
@@ -1831,8 +1831,8 @@ def test_checkout_complete_with_voucher_paid_by_gift_card(
manager=manager, checkout_info=checkout_info, lines=lines, address=address
)
- gift_card.initial_balance_amount = total_without_gc.gross.amount + Decimal("1")
- gift_card.current_balance_amount = total_without_gc.gross.amount + Decimal("1")
+ gift_card.initial_balance_amount = total_without_gc.gross.amount + Decimal(1)
+ gift_card.current_balance_amount = total_without_gc.gross.amount + Decimal(1)
gift_card.save()
expected_gc_balance_amount = (
@@ -1917,7 +1917,7 @@ def test_checkout_complete_free_shipping_voucher_and_gift_card(
shipping_listing = shipping_method.channel_listings.get(
channel_id=checkout.channel_id
)
- shipping_listing.price_amount = Decimal("35")
+ shipping_listing.price_amount = Decimal(35)
shipping_listing.save(update_fields=["price_amount"])
checkout.gift_cards.add(gift_card)
@@ -2049,7 +2049,7 @@ def test_checkout_complete_product_on_promotion(
channel = checkout.channel
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = catalogue_promotion_without_rules.rules.create(
catalogue_predicate={
"productPredicate": {
@@ -2190,7 +2190,7 @@ def test_checkout_complete_product_on_promotion_deleted_promotion_instance(
checkout_line_variant = checkout_line.variant
channel = checkout.channel
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = catalogue_promotion_without_rules.rules.create(
catalogue_predicate={
"productPredicate": {
@@ -2424,7 +2424,7 @@ def test_checkout_complete_product_on_old_sale(
catalogue_promotion_without_rules.old_sale_id = old_sale_id
catalogue_promotion_without_rules.save(update_fields=["old_sale_id"])
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = catalogue_promotion_without_rules.rules.create(
catalogue_predicate={
"productPredicate": {
@@ -2600,7 +2600,7 @@ def test_checkout_with_voucher_on_specific_product_complete_with_product_on_prom
channel = checkout.channel
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = catalogue_promotion_without_rules.rules.create(
catalogue_predicate={
"productPredicate": {
@@ -4120,7 +4120,7 @@ def test_complete_checkout_raises_error_for_local_stock(
payment = payment_dummy
payment.is_active = True
payment.order = None
- payment.total = Decimal("20")
+ payment.total = Decimal(20)
payment.currency = checkout.currency
payment.checkout = checkout
payment.save()
diff --git a/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_transactions.py b/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_transactions.py
index 75d39c461b..49466fec15 100644
--- a/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_transactions.py
+++ b/saleor/graphql/checkout/tests/mutations/test_checkout_complete_with_transactions.py
@@ -683,10 +683,10 @@ def test_checkout_paid_with_multiple_transactions(
)
transaction = transaction_item_generator(
- checkout_id=checkout.pk, charged_value=total.gross.amount - Decimal("10")
+ checkout_id=checkout.pk, charged_value=total.gross.amount - Decimal(10)
)
second_transaction = transaction_item_generator(
- checkout_id=checkout.pk, charged_value=Decimal("10")
+ checkout_id=checkout.pk, charged_value=Decimal(10)
)
update_checkout_payment_statuses(
@@ -746,7 +746,7 @@ def test_checkout_partially_paid(
)
transaction_item_generator(
- checkout_id=checkout.pk, charged_value=total.gross.amount - Decimal("10")
+ checkout_id=checkout.pk, charged_value=total.gross.amount - Decimal(10)
)
update_checkout_payment_statuses(
@@ -799,7 +799,7 @@ def test_checkout_partially_paid_allow_unpaid_order(
)
transaction = transaction_item_generator(
- checkout_id=checkout.pk, charged_value=total.gross.amount - Decimal("10")
+ checkout_id=checkout.pk, charged_value=total.gross.amount - Decimal(10)
)
update_checkout_payment_statuses(
@@ -1808,7 +1808,7 @@ def test_checkout_complete_with_shipping_voucher_and_gift_card(
shipping_listing = shipping_method.channel_listings.get(
channel_id=checkout_with_gift_card.channel_id
)
- shipping_listing.price_amount = Decimal("35")
+ shipping_listing.price_amount = Decimal(35)
shipping_listing.save(update_fields=["price_amount"])
checkout = prepare_checkout_for_test(
@@ -2182,7 +2182,7 @@ def test_checkout_complete_with_entire_order_voucher_paid_with_gift_card_and_tra
shipping_listing = shipping_method.channel_listings.get(
channel_id=checkout_with_voucher_percentage.channel_id
)
- shipping_listing.price_amount = Decimal("35")
+ shipping_listing.price_amount = Decimal(35)
shipping_listing.save(update_fields=["price_amount"])
checkout = prepare_checkout_for_test(
@@ -2312,8 +2312,8 @@ def test_checkout_complete_with_voucher_paid_with_gift_card(
manager=manager, checkout_info=checkout_info, lines=lines, address=address
)
- gift_card.initial_balance_amount = total_without_gc.gross.amount + Decimal("1")
- gift_card.current_balance_amount = total_without_gc.gross.amount + Decimal("1")
+ gift_card.initial_balance_amount = total_without_gc.gross.amount + Decimal(1)
+ gift_card.current_balance_amount = total_without_gc.gross.amount + Decimal(1)
gift_card.save()
expected_gc_balance_amount = (
@@ -2384,7 +2384,7 @@ def test_checkout_complete_with_voucher_paid_with_gift_card(
"expected_voucher_discount_value",
),
[
- (True, DiscountValueType.FIXED, Decimal("1")),
+ (True, DiscountValueType.FIXED, Decimal(1)),
(False, DiscountValueType.PERCENTAGE, Decimal(10)),
],
)
@@ -2510,7 +2510,7 @@ def test_checkout_complete_with_voucher_apply_once_per_order_and_gift_card(
shipping_listing = shipping_method.channel_listings.get(
channel_id=checkout.channel_id
)
- shipping_listing.price_amount = Decimal("35")
+ shipping_listing.price_amount = Decimal(35)
shipping_listing.save(update_fields=["price_amount"])
code = voucher_percentage.codes.first()
@@ -2702,7 +2702,7 @@ def test_checkout_complete_with_shipping_voucher(
shipping_listing = shipping_method.channel_listings.get(
channel_id=checkout.channel_id
)
- shipping_listing.price_amount = Decimal("35")
+ shipping_listing.price_amount = Decimal(35)
shipping_listing.save(update_fields=["price_amount"])
checkout.discount = shipping_listing.price
checkout.save(update_fields=["discount_amount"])
@@ -2834,7 +2834,7 @@ def test_checkout_with_voucher_complete_product_on_sale(
checkout_line_variant = checkout_line.variant
channel = checkout.channel
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = catalogue_promotion_without_rules.rules.create(
catalogue_predicate={
"productPredicate": {
@@ -2938,7 +2938,7 @@ def test_checkout_with_voucher_complete_product_on_sale(
"expected_voucher_discount_value",
),
[
- (True, DiscountValueType.FIXED, Decimal("3")),
+ (True, DiscountValueType.FIXED, Decimal(3)),
(False, DiscountValueType.PERCENTAGE, Decimal(10)),
],
)
@@ -3052,7 +3052,7 @@ def test_checkout_complete_with_voucher_on_specific_product_and_gift_card(
shipping_listing = shipping_method.channel_listings.get(
channel_id=checkout_with_item_and_voucher_specific_products.channel_id
)
- shipping_listing.price_amount = Decimal("35")
+ shipping_listing.price_amount = Decimal(35)
shipping_listing.save(update_fields=["price_amount"])
checkout = prepare_checkout_for_test(
@@ -3167,7 +3167,7 @@ def test_checkout_complete_product_on_promotion(
channel = checkout.channel
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = catalogue_promotion_without_rules.rules.create(
catalogue_predicate={
"productPredicate": {
@@ -3275,8 +3275,8 @@ def test_checkout_complete_multiple_rules_applied(
channel = checkout.channel
- reward_value_1 = Decimal("2")
- reward_value_2 = Decimal("10")
+ reward_value_1 = Decimal(2)
+ reward_value_2 = Decimal(10)
rule_1, rule_2 = PromotionRule.objects.bulk_create(
[
PromotionRule(
@@ -3416,7 +3416,7 @@ def test_checkout_complete_multiple_rules_applied(
"expected_voucher_discount_value",
),
[
- (True, DiscountValueType.FIXED, Decimal("3")),
+ (True, DiscountValueType.FIXED, Decimal(3)),
(False, DiscountValueType.PERCENTAGE, Decimal(10)),
],
)
diff --git a/saleor/graphql/checkout/tests/mutations/test_checkout_lines_add.py b/saleor/graphql/checkout/tests/mutations/test_checkout_lines_add.py
index 1942db27ef..75fa47c9aa 100644
--- a/saleor/graphql/checkout/tests/mutations/test_checkout_lines_add.py
+++ b/saleor/graphql/checkout/tests/mutations/test_checkout_lines_add.py
@@ -380,7 +380,7 @@ def test_add_to_existing_line_catalogue_and_order_discount_applies(
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("50"),
+ reward_value=Decimal(50),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
)
rule.channels.add(channel_USD)
@@ -489,7 +489,7 @@ def test_add_to_existing_line_on_promotion_with_voucher_order_promotion_not_appl
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("50"),
+ reward_value=Decimal(50),
reward_type=RewardType.SUBTOTAL_DISCOUNT,
)
rule.channels.add(channel_USD)
@@ -621,9 +621,9 @@ def test_add_to_existing_line_catalogue_and_gift_reward_applies(
if line_data["isGift"] is True
][0]
unit_price = gift_line_data["unitPrice"]["gross"]["amount"]
- assert Decimal(unit_price) == Decimal("0")
+ assert Decimal(unit_price) == Decimal(0)
total_price = gift_line_data["totalPrice"]["gross"]["amount"]
- assert Decimal(total_price) == Decimal("0")
+ assert Decimal(total_price) == Decimal(0)
variants = gift_promotion_rule.gifts.all()
variant_listings = ProductVariantChannelListing.objects.filter(variant__in=variants)
@@ -635,13 +635,13 @@ def test_add_to_existing_line_catalogue_and_gift_reward_applies(
undiscounted_total_price = gift_line_data["undiscountedTotalPrice"]["amount"]
assert Decimal(undiscounted_total_price) == top_price
unit_price = gift_line_data["unitPrice"]["gross"]["amount"]
- assert Decimal(unit_price) == Decimal("0")
+ assert Decimal(unit_price) == Decimal(0)
total_price = gift_line_data["totalPrice"]["gross"]["amount"]
- assert Decimal(total_price) == Decimal("0")
+ assert Decimal(total_price) == Decimal(0)
checkout_discount_amount = data["checkout"]["discount"]["amount"]
# Both catalogue and gift discount are only visible on line level
- assert Decimal(checkout_discount_amount) == Decimal("0")
+ assert Decimal(checkout_discount_amount) == Decimal(0)
assert checkout.discounts.count() == 0
@@ -1221,7 +1221,7 @@ def test_checkout_lines_add_custom_price_and_catalogue_promotion(
# given
variant = variant_on_promotion
variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
- price = Decimal("16")
+ price = Decimal(16)
promotion_rule = variant.channel_listings.get(
channel=checkout.channel
diff --git a/saleor/graphql/checkout/tests/mutations/test_checkout_lines_update.py b/saleor/graphql/checkout/tests/mutations/test_checkout_lines_update.py
index f0d54ae9e5..79bab72ecb 100644
--- a/saleor/graphql/checkout/tests/mutations/test_checkout_lines_update.py
+++ b/saleor/graphql/checkout/tests/mutations/test_checkout_lines_update.py
@@ -771,7 +771,7 @@ def test_checkout_lines_update_with_custom_price_and_fixed_catalogue_promotion(
reward_value = line_discount.value
variant_id = graphene.Node.to_global_id("ProductVariant", line.variant_id)
- custom_price = Decimal("15")
+ custom_price = Decimal(15)
variables = {
"id": to_global_id_or_none(checkout),
@@ -822,13 +822,13 @@ def test_checkout_lines_update_with_custom_price_and_percentage_catalogue_promot
promotion_rule = line_discount.promotion_rule
reward_value_type = RewardValueType.PERCENTAGE
- reward_value = Decimal("50")
+ reward_value = Decimal(50)
promotion_rule.reward_value_type = reward_value_type
promotion_rule.reward_value = reward_value
promotion_rule.save(update_fields=["reward_value_type", "reward_value"])
variant_id = graphene.Node.to_global_id("ProductVariant", line.variant_id)
- custom_price = Decimal("40")
+ custom_price = Decimal(40)
variables = {
"id": to_global_id_or_none(checkout),
@@ -886,7 +886,7 @@ def test_checkout_lines_update_with_0_custom_price_and_catalogue_promotion(
line_discount = line.discounts.first()
variant_id = graphene.Node.to_global_id("ProductVariant", line.variant_id)
- custom_price = Decimal("0")
+ custom_price = Decimal(0)
variables = {
"id": to_global_id_or_none(checkout),
diff --git a/saleor/graphql/checkout/tests/mutations/test_checkout_remove_promo_code.py b/saleor/graphql/checkout/tests/mutations/test_checkout_remove_promo_code.py
index e625f584dd..9cd52bfeb3 100644
--- a/saleor/graphql/checkout/tests/mutations/test_checkout_remove_promo_code.py
+++ b/saleor/graphql/checkout/tests/mutations/test_checkout_remove_promo_code.py
@@ -671,7 +671,7 @@ def test_checkout_remove_voucher_code_order_promotion_discount_applied(
):
# given
checkout = checkout_with_voucher
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
order_promotion_rule.reward_value = reward_value
order_promotion_rule.reward_value_type = RewardValueType.FIXED
order_promotion_rule.save(update_fields=["reward_value", "reward_value_type"])
diff --git a/saleor/graphql/checkout/tests/mutations/test_checkout_shipping_method_update.py b/saleor/graphql/checkout/tests/mutations/test_checkout_shipping_method_update.py
index e64b6e385d..b72002284d 100644
--- a/saleor/graphql/checkout/tests/mutations/test_checkout_shipping_method_update.py
+++ b/saleor/graphql/checkout/tests/mutations/test_checkout_shipping_method_update.py
@@ -123,7 +123,7 @@ def test_checkout_shipping_method_update_external_shipping_method(
):
settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]
response_method_id = "abcd"
- method_price = Decimal("10")
+ method_price = Decimal(10)
method_name = "Provider - Economy"
mock_json_response = [
{
@@ -177,7 +177,7 @@ def test_checkout_shipping_method_update_overwrites_external_shipping(
# given
checkout = checkout_with_item_and_shipping_method
checkout.external_shipping_method_id = "ext-ship"
- checkout.undiscounted_base_shipping_price_amount = Decimal("110")
+ checkout.undiscounted_base_shipping_price_amount = Decimal(110)
checkout.shipping_method_name = "Ext shipping"
checkout.shipping_address = address
checkout.save()
@@ -361,7 +361,7 @@ def test_checkout_shipping_method_update_excluded_webhook(
assert errors[0]["code"] == CheckoutErrorCode.SHIPPING_METHOD_NOT_APPLICABLE.name
assert checkout.shipping_method is None
assert checkout.external_shipping_method_id is None
- assert checkout.undiscounted_base_shipping_price_amount == Decimal("0")
+ assert checkout.undiscounted_base_shipping_price_amount == Decimal(0)
assert checkout.shipping_method_name is None
@@ -396,7 +396,7 @@ def test_checkout_shipping_method_update_excluded_postal_code(
assert errors[0]["code"] == CheckoutErrorCode.SHIPPING_METHOD_NOT_APPLICABLE.name
assert checkout.shipping_method is None
assert checkout.external_shipping_method_id is None
- assert checkout.undiscounted_base_shipping_price_amount == Decimal("0")
+ assert checkout.undiscounted_base_shipping_price_amount == Decimal(0)
assert checkout.shipping_method_name is None
assert (
mock_is_shipping_method_available.call_count
@@ -566,7 +566,7 @@ def test_checkout_shipping_method_update_shipping_zone_without_channel(
assert errors[0]["code"] == CheckoutErrorCode.SHIPPING_METHOD_NOT_APPLICABLE.name
assert checkout.shipping_method is None
assert checkout.external_shipping_method_id is None
- assert checkout.undiscounted_base_shipping_price_amount == Decimal("0")
+ assert checkout.undiscounted_base_shipping_price_amount == Decimal(0)
assert checkout.shipping_method_name is None
@@ -643,7 +643,7 @@ def test_checkout_update_shipping_method_with_digital(
checkout.refresh_from_db(fields=["shipping_method"])
assert checkout.shipping_method is None
assert checkout.external_shipping_method_id is None
- assert checkout.undiscounted_base_shipping_price_amount == Decimal("0")
+ assert checkout.undiscounted_base_shipping_price_amount == Decimal(0)
assert checkout.shipping_method_name is None
diff --git a/saleor/graphql/checkout/tests/mutations/test_order_create_from_checkout.py b/saleor/graphql/checkout/tests/mutations/test_order_create_from_checkout.py
index 95199e591c..173e864c5f 100644
--- a/saleor/graphql/checkout/tests/mutations/test_order_create_from_checkout.py
+++ b/saleor/graphql/checkout/tests/mutations/test_order_create_from_checkout.py
@@ -860,7 +860,7 @@ def test_order_from_checkout_with_voucher_and_gift_card(
shipping_listing = shipping_method.channel_listings.get(
channel_id=checkout_with_voucher_percentage.channel_id
)
- shipping_listing.price_amount = Decimal("35")
+ shipping_listing.price_amount = Decimal(35)
shipping_listing.save(update_fields=["price_amount"])
code = voucher_percentage.codes.first()
@@ -1107,7 +1107,7 @@ def test_order_from_checkout_with_free_shipping_voucher_and_gift_card(
shipping_listing = shipping_method.channel_listings.get(
channel_id=checkout.channel_id
)
- shipping_amount = Decimal("35")
+ shipping_amount = Decimal(35)
shipping_listing.price_amount = shipping_amount
shipping_listing.save(update_fields=["price_amount"])
diff --git a/saleor/graphql/checkout/tests/test_checkout.py b/saleor/graphql/checkout/tests/test_checkout.py
index c1fb92ed9b..6df579bebd 100644
--- a/saleor/graphql/checkout/tests/test_checkout.py
+++ b/saleor/graphql/checkout/tests/test_checkout.py
@@ -4304,7 +4304,7 @@ def test_checkout_transactions_missing_permission(api_client, checkout):
name="Credit card",
psp_reference="123",
currency="USD",
- authorized_value=Decimal("15"),
+ authorized_value=Decimal(15),
available_actions=[TransactionAction.CHARGE, TransactionAction.CANCEL],
)
query = QUERY_CHECKOUT_TRANSACTIONS
@@ -4325,7 +4325,7 @@ def test_checkout_transactions_with_manage_checkouts(
name="Credit card",
psp_reference="123",
currency="USD",
- authorized_value=Decimal("15"),
+ authorized_value=Decimal(15),
available_actions=[TransactionAction.CHARGE, TransactionAction.CANCEL],
)
query = QUERY_CHECKOUT_TRANSACTIONS
@@ -4353,7 +4353,7 @@ def test_checkout_transactions_with_handle_payments(
name="Credit card",
psp_reference="123",
currency="USD",
- authorized_value=Decimal("15"),
+ authorized_value=Decimal(15),
available_actions=[TransactionAction.CHARGE, TransactionAction.CANCEL],
)
query = QUERY_CHECKOUT_TRANSACTIONS
@@ -4397,9 +4397,9 @@ def test_checkout_payment_statuses(
name="Credit card",
psp_reference="123",
currency="USD",
- authorized_value=Decimal("15"),
- charged_value=Decimal("5"),
- charge_pending_value=Decimal("6"),
+ authorized_value=Decimal(15),
+ charged_value=Decimal(5),
+ charge_pending_value=Decimal(6),
available_actions=[TransactionAction.CHARGE, TransactionAction.CANCEL],
)
query = QUERY_CHECKOUT_STATUSES_AND_BALANCE
@@ -4433,9 +4433,9 @@ def test_checkout_balance(
name="Credit card",
psp_reference="123",
currency="USD",
- authorized_value=Decimal("15"),
- charged_value=Decimal("5"),
- charge_pending_value=Decimal("6"),
+ authorized_value=Decimal(15),
+ charged_value=Decimal(5),
+ charge_pending_value=Decimal(6),
available_actions=[TransactionAction.CHARGE, TransactionAction.CANCEL],
)
query = QUERY_CHECKOUT_STATUSES_AND_BALANCE
diff --git a/saleor/graphql/checkout/tests/test_checkout_filters.py b/saleor/graphql/checkout/tests/test_checkout_filters.py
index 4f104c5099..c425d0a254 100644
--- a/saleor/graphql/checkout/tests/test_checkout_filters.py
+++ b/saleor/graphql/checkout/tests/test_checkout_filters.py
@@ -454,52 +454,52 @@ def test_checkouts_query_with_filter_search_by_token(
("transaction_data", "statuses", "expected_count"),
[
(
- {"authorized_value": Decimal("10")},
+ {"authorized_value": Decimal(10)},
[CheckoutAuthorizeStatusEnum.PARTIAL.name],
1,
),
(
- {"charged_value": Decimal("10")},
+ {"charged_value": Decimal(10)},
[CheckoutAuthorizeStatusEnum.PARTIAL.name],
1,
),
(
- {"authorize_pending_value": Decimal("10")},
+ {"authorize_pending_value": Decimal(10)},
[CheckoutAuthorizeStatusEnum.PARTIAL.name],
1,
),
(
- {"charge_pending_value": Decimal("10")},
+ {"charge_pending_value": Decimal(10)},
[CheckoutAuthorizeStatusEnum.PARTIAL.name],
1,
),
(
- {"authorized_value": Decimal("0")},
+ {"authorized_value": Decimal(0)},
[CheckoutAuthorizeStatusEnum.NONE.name],
1,
),
(
- {"authorized_value": Decimal("200")},
+ {"authorized_value": Decimal(200)},
[CheckoutAuthorizeStatusEnum.FULL.name],
2,
),
(
- {"charged_value": Decimal("200")},
+ {"charged_value": Decimal(200)},
[CheckoutAuthorizeStatusEnum.FULL.name],
2,
),
(
- {"authorize_pending_value": Decimal("200")},
+ {"authorize_pending_value": Decimal(200)},
[CheckoutAuthorizeStatusEnum.FULL.name],
2,
),
(
- {"charge_pending_value": Decimal("200")},
+ {"charge_pending_value": Decimal(200)},
[CheckoutAuthorizeStatusEnum.FULL.name],
2,
),
(
- {"authorized_value": Decimal("10")},
+ {"authorized_value": Decimal(10)},
[
CheckoutAuthorizeStatusEnum.FULL.name,
CheckoutAuthorizeStatusEnum.PARTIAL.name,
@@ -507,7 +507,7 @@ def test_checkouts_query_with_filter_search_by_token(
2,
),
(
- {"authorized_value": Decimal("0")},
+ {"authorized_value": Decimal(0)},
[
CheckoutAuthorizeStatusEnum.FULL.name,
CheckoutAuthorizeStatusEnum.NONE.name,
@@ -515,7 +515,7 @@ def test_checkouts_query_with_filter_search_by_token(
2,
),
(
- {"authorized_value": Decimal("10"), "charged_value": Decimal("90")},
+ {"authorized_value": Decimal(10), "charged_value": Decimal(90)},
[CheckoutAuthorizeStatusEnum.PARTIAL.name],
1,
),
@@ -537,7 +537,7 @@ def test_checkouts_query_with_filter_authorize_status(
currency=channel_USD.currency_code, channel=channel_USD
)
first_checkout.payment_transactions.create(
- currency=checkout_with_prices.currency, authorized_value=Decimal("10")
+ currency=checkout_with_prices.currency, authorized_value=Decimal(10)
)
update_checkout_payment_statuses(
@@ -566,17 +566,17 @@ def test_checkouts_query_with_filter_authorize_status(
("transaction_data", "statuses", "expected_count"),
[
(
- {"charged_value": Decimal("10")},
+ {"charged_value": Decimal(10)},
[CheckoutChargeStatusEnum.PARTIAL.name],
1,
),
(
- {"charge_pending_value": Decimal("10")},
+ {"charge_pending_value": Decimal(10)},
[CheckoutChargeStatusEnum.PARTIAL.name],
1,
),
(
- {"charged_value": Decimal("00")},
+ {"charged_value": Decimal(0)},
[CheckoutChargeStatusEnum.PARTIAL.name],
0,
),
@@ -604,12 +604,12 @@ def test_checkouts_query_with_filter_authorize_status(
1,
),
(
- {"charged_value": Decimal("10")},
+ {"charged_value": Decimal(10)},
[CheckoutChargeStatusEnum.FULL.name, CheckoutChargeStatusEnum.PARTIAL.name],
1,
),
(
- {"charged_value": Decimal("0")},
+ {"charged_value": Decimal(0)},
[CheckoutChargeStatusEnum.FULL.name, CheckoutChargeStatusEnum.NONE.name],
1,
),
@@ -638,7 +638,7 @@ def test_checkouts_query_with_filter_charge_status(
currency=channel_USD.currency_code, channel=channel_USD
)
first_checkout.payment_transactions.create(
- currency=checkout_with_prices.currency, charged_value=Decimal("10")
+ currency=checkout_with_prices.currency, charged_value=Decimal(10)
)
update_checkout_payment_statuses(
diff --git a/saleor/graphql/checkout/tests/test_checkouts_query.py b/saleor/graphql/checkout/tests/test_checkouts_query.py
index ddf519c23d..8f61737ebd 100644
--- a/saleor/graphql/checkout/tests/test_checkouts_query.py
+++ b/saleor/graphql/checkout/tests/test_checkouts_query.py
@@ -87,7 +87,7 @@ def test_query_checkouts_do_not_trigger_external_shipping_webhook_with_flat_rate
settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]
checkout = checkout_with_delivery_method_for_external_shipping
checkout.price_expiration = timezone.now()
- checkout.undiscounted_base_shipping_price_amount = Decimal("100")
+ checkout.undiscounted_base_shipping_price_amount = Decimal(100)
checkout.save()
# when
@@ -143,7 +143,7 @@ def test_query_checkouts_do_not_trigger_external_shipping_webhook_with_tax_app(
settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]
checkout = checkout_with_delivery_method_for_external_shipping
checkout.price_expiration = timezone.now()
- checkout.undiscounted_base_shipping_price_amount = Decimal("100")
+ checkout.undiscounted_base_shipping_price_amount = Decimal(100)
checkout.save()
# when
@@ -198,7 +198,7 @@ def test_query_checkouts_do_not_trigger_exclude_shipping_webhooks_with_flat_rate
settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]
checkout = checkout_with_delivery_method_for_external_shipping
checkout.price_expiration = timezone.now()
- checkout.undiscounted_base_shipping_price_amount = Decimal("100")
+ checkout.undiscounted_base_shipping_price_amount = Decimal(100)
checkout.save()
# when
@@ -253,7 +253,7 @@ def test_query_checkouts_do_not_trigger_exclude_shipping_webhooks_with_tax_app(
settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]
checkout = checkout_with_delivery_method_for_external_shipping
checkout.price_expiration = timezone.now()
- checkout.undiscounted_base_shipping_price_amount = Decimal("100")
+ checkout.undiscounted_base_shipping_price_amount = Decimal(100)
checkout.save()
# when
diff --git a/saleor/graphql/core/connection.py b/saleor/graphql/core/connection.py
index e2633a35a1..c72f0c4163 100644
--- a/saleor/graphql/core/connection.py
+++ b/saleor/graphql/core/connection.py
@@ -678,7 +678,7 @@ class NonNullConnection(BaseConnection):
abstract = True
@classmethod
- def __init_subclass_with_meta__(cls, node=None, name=None, **options):
+ def __init_subclass_with_meta__(cls, node=None, name=None, **options): # type: ignore[override]
super().__init_subclass_with_meta__(node=node, name=name, **options)
# Override the original EdgeBase type to make to `node` field required.
diff --git a/saleor/graphql/core/context.py b/saleor/graphql/core/context.py
index 81305c1611..5c223b1a62 100644
--- a/saleor/graphql/core/context.py
+++ b/saleor/graphql/core/context.py
@@ -1,6 +1,6 @@
import datetime
from dataclasses import dataclass
-from typing import TYPE_CHECKING, Any, Generic, TypeVar
+from typing import TYPE_CHECKING, Any, TypeVar
from django.conf import settings
from django.db.models import QuerySet
@@ -71,7 +71,7 @@ N = TypeVar("N")
@dataclass
-class BaseContext(Generic[N]):
+class BaseContext[N]:
node: N
diff --git a/saleor/graphql/core/dataloaders.py b/saleor/graphql/core/dataloaders.py
index 5f2bbac3a6..30086e927d 100644
--- a/saleor/graphql/core/dataloaders.py
+++ b/saleor/graphql/core/dataloaders.py
@@ -1,6 +1,6 @@
from collections import defaultdict
from collections.abc import Iterable
-from typing import Generic, TypeVar
+from typing import TypeVar
from promise import Promise
from promise.dataloader import DataLoader as BaseLoader
@@ -16,7 +16,7 @@ K = TypeVar("K")
R = TypeVar("R")
-class DataLoader(BaseLoader, Generic[K, R]):
+class DataLoader[K, R](BaseLoader):
context_key: str
context: SaleorContext
database_connection_name: str
diff --git a/saleor/graphql/core/filters/filter_input.py b/saleor/graphql/core/filters/filter_input.py
index c662fef0a5..9bc84d2463 100644
--- a/saleor/graphql/core/filters/filter_input.py
+++ b/saleor/graphql/core/filters/filter_input.py
@@ -42,7 +42,7 @@ class FilterInputObjectType(BaseInputObjectType):
"""
@classmethod
- def __init_subclass_with_meta__(
+ def __init_subclass_with_meta__( # type: ignore[override]
cls, _meta=None, model=None, filterset_class=None, fields=None, **options
):
cls.custom_filterset_class = filterset_class
diff --git a/saleor/graphql/core/filters/where_input.py b/saleor/graphql/core/filters/where_input.py
index 5767da8827..0b48daa8df 100644
--- a/saleor/graphql/core/filters/where_input.py
+++ b/saleor/graphql/core/filters/where_input.py
@@ -25,7 +25,7 @@ class WhereInputObjectType(FilterInputObjectType):
abstract = True
@classmethod
- def __init_subclass_with_meta__(cls, _meta=None, **options):
+ def __init_subclass_with_meta__(cls, _meta=None, **options): # type: ignore[override]
super().__init_subclass_with_meta__(_meta=_meta, **options)
cls._meta.fields.update(
{
diff --git a/saleor/graphql/core/mutations.py b/saleor/graphql/core/mutations.py
index e454506c81..8c53bb8329 100644
--- a/saleor/graphql/core/mutations.py
+++ b/saleor/graphql/core/mutations.py
@@ -650,7 +650,7 @@ class DeprecatedModelMutation(BaseMutation):
abstract = True
@classmethod
- def __init_subclass_with_meta__(
+ def __init_subclass_with_meta__( # type: ignore[override]
cls,
arguments=None,
model=None,
@@ -726,7 +726,7 @@ class DeprecatedModelMutation(BaseMutation):
# handle uploaded files
elif value is not None and is_upload_field(field_item):
value = info.context.FILES.get(value)
- cleaned_input[field_name] = value
+ cleaned_input[field_name] = value # type: ignore[assignment]
# handle other fields
else:
@@ -981,7 +981,7 @@ class BaseBulkMutation(BaseMutation):
abstract = True
@classmethod
- def __init_subclass_with_meta__(
+ def __init_subclass_with_meta__( # type: ignore[override]
cls, model=None, object_type=None, _meta=None, **kwargs
):
if not model:
diff --git a/saleor/graphql/core/tests/test_validators.py b/saleor/graphql/core/tests/test_validators.py
index 8ae658c39c..8210459acb 100644
--- a/saleor/graphql/core/tests/test_validators.py
+++ b/saleor/graphql/core/tests/test_validators.py
@@ -21,11 +21,11 @@ from ..validators import (
[
(Decimal("1.1200"), "USD"),
(Decimal("1.12"), "USD"),
- (Decimal("1"), "USD"),
- (Decimal("1"), "ISK"),
+ (Decimal(1), "USD"),
+ (Decimal(1), "ISK"),
(Decimal("1.00"), "ISK"),
(Decimal("5.12"), None),
- (Decimal("1000"), "USD"),
+ (Decimal(1000), "USD"),
],
)
def test_validate_price_precision(value, currency):
diff --git a/saleor/graphql/core/types/event.py b/saleor/graphql/core/types/event.py
index d53ef4de23..37931e4851 100644
--- a/saleor/graphql/core/types/event.py
+++ b/saleor/graphql/core/types/event.py
@@ -15,7 +15,7 @@ class SubscriptionObjectType(BaseObjectType):
abstract = True
@classmethod
- def __init_subclass_with_meta__(
+ def __init_subclass_with_meta__( # type: ignore[override]
cls,
root_type=None,
enable_dry_run=False,
diff --git a/saleor/graphql/core/types/model.py b/saleor/graphql/core/types/model.py
index 022a6d5902..9a88ba4d6c 100644
--- a/saleor/graphql/core/types/model.py
+++ b/saleor/graphql/core/types/model.py
@@ -18,7 +18,7 @@ MT = TypeVar("MT", bound=Model)
class ModelObjectType(Generic[MT], BaseObjectType):
@classmethod
- def __init_subclass_with_meta__(
+ def __init_subclass_with_meta__( # type: ignore[override]
cls,
interfaces=(),
possible_types=(),
diff --git a/saleor/graphql/core/types/sort_input.py b/saleor/graphql/core/types/sort_input.py
index 82b747c056..0adc945602 100644
--- a/saleor/graphql/core/types/sort_input.py
+++ b/saleor/graphql/core/types/sort_input.py
@@ -23,7 +23,7 @@ class SortInputObjectType(BaseInputObjectType):
abstract = True
@classmethod
- def __init_subclass_with_meta__(
+ def __init_subclass_with_meta__( # type: ignore[override]
cls, container=None, _meta=None, sort_enum=None, type_name=None, **options
):
if not _meta:
diff --git a/saleor/graphql/discount/inputs.py b/saleor/graphql/discount/inputs.py
index 384de1f648..3c9fdfaeac 100644
--- a/saleor/graphql/discount/inputs.py
+++ b/saleor/graphql/discount/inputs.py
@@ -25,7 +25,7 @@ class PredicateInputObjectType(BaseInputObjectType):
abstract = True
@classmethod
- def __init_subclass_with_meta__(cls, _meta=None, **options):
+ def __init_subclass_with_meta__(cls, _meta=None, **options): # type: ignore[override]
super().__init_subclass_with_meta__(_meta=_meta, **options)
cls._meta.fields.update(
{
diff --git a/saleor/graphql/discount/tests/benchmark/test_promotion_create.py b/saleor/graphql/discount/tests/benchmark/test_promotion_create.py
index 7cb3788da2..1fb57beed7 100644
--- a/saleor/graphql/discount/tests/benchmark/test_promotion_create.py
+++ b/saleor/graphql/discount/tests/benchmark/test_promotion_create.py
@@ -49,7 +49,7 @@ def test_promotion_create(
rule_1_channel_ids = [graphene.Node.to_global_id("Channel", channel_USD.pk)]
rule_2_channel_ids = [graphene.Node.to_global_id("Channel", channel_PLN.pk)]
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
catalogue_predicate = {
"OR": [
@@ -166,7 +166,7 @@ def test_promotion_create_order_promotion(
"channels": channel_ids,
"rewardType": RewardTypeEnum.SUBTOTAL_DISCOUNT.name,
"rewardValueType": RewardValueTypeEnum.FIXED.name,
- "rewardValue": Decimal("1"),
+ "rewardValue": Decimal(1),
"orderPredicate": order_predicate_0,
},
{
@@ -174,7 +174,7 @@ def test_promotion_create_order_promotion(
"channels": channel_ids,
"rewardType": RewardTypeEnum.SUBTOTAL_DISCOUNT.name,
"rewardValueType": RewardValueTypeEnum.PERCENTAGE.name,
- "rewardValue": Decimal("10"),
+ "rewardValue": Decimal(10),
"orderPredicate": order_predicate_0,
},
{
diff --git a/saleor/graphql/discount/tests/benchmark/test_promotion_rule_create.py b/saleor/graphql/discount/tests/benchmark/test_promotion_rule_create.py
index 452918a729..29d9b136d6 100644
--- a/saleor/graphql/discount/tests/benchmark/test_promotion_rule_create.py
+++ b/saleor/graphql/discount/tests/benchmark/test_promotion_rule_create.py
@@ -44,7 +44,7 @@ def test_promotion_rule_create(
graphene.Node.to_global_id("Channel", channel.pk)
for channel in [channel_USD, channel_PLN]
]
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
catalogue_predicate = {
"OR": [
diff --git a/saleor/graphql/discount/tests/benchmark/test_promotion_rule_update.py b/saleor/graphql/discount/tests/benchmark/test_promotion_rule_update.py
index 6a879affd1..ece1c70946 100644
--- a/saleor/graphql/discount/tests/benchmark/test_promotion_rule_update.py
+++ b/saleor/graphql/discount/tests/benchmark/test_promotion_rule_update.py
@@ -49,7 +49,7 @@ def test_promotion_rule_update(
]
}
collection.products.add(product_list[2])
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
variables = {
diff --git a/saleor/graphql/discount/tests/mutations/test_promotion_create.py b/saleor/graphql/discount/tests/mutations/test_promotion_create.py
index a52ce15439..894f2f0955 100644
--- a/saleor/graphql/discount/tests/mutations/test_promotion_create.py
+++ b/saleor/graphql/discount/tests/mutations/test_promotion_create.py
@@ -108,7 +108,7 @@ def test_promotion_create_by_staff_user(
}
rule_1_name = "test promotion rule 1"
rule_2_name = "test promotion rule 2"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type_1 = RewardValueTypeEnum.FIXED.name
reward_value_type_2 = RewardValueTypeEnum.PERCENTAGE.name
promotion_type = PromotionTypeEnum.CATALOGUE.name
@@ -225,7 +225,7 @@ def test_promotion_create_by_app(
"description": description_json,
"channels": channel_ids,
"rewardValueType": RewardValueTypeEnum.FIXED.name,
- "rewardValue": Decimal("10"),
+ "rewardValue": Decimal(10),
"cataloguePredicate": catalogue_predicate,
}
],
@@ -297,7 +297,7 @@ def test_promotion_create_by_customer(
"description": description_json,
"channels": channel_ids,
"rewardValueType": RewardValueTypeEnum.FIXED.name,
- "rewardValue": Decimal("10"),
+ "rewardValue": Decimal(10),
"cataloguePredicate": catalogue_predicate,
}
],
@@ -334,7 +334,7 @@ def test_promotion_create_with_order_rule(
"discountedObjectPredicate": {"baseSubtotalPrice": {"range": {"gte": 100}}}
}
rule_name = "test promotion rule 1"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
reward_type = RewardTypeEnum.SUBTOTAL_DISCOUNT.name
channel_ids = [graphene.Node.to_global_id("Channel", channel_USD.pk)]
@@ -423,7 +423,7 @@ def test_promotion_create_fixed_reward_value_multiple_currencies(
"description": description_json,
"channels": channel_ids,
"rewardValueType": RewardValueTypeEnum.FIXED.name,
- "rewardValue": Decimal("10"),
+ "rewardValue": Decimal(10),
"cataloguePredicate": catalogue_predicate,
}
],
@@ -561,7 +561,7 @@ def test_promotion_create_invalid_percentage_value(
"description": description_json,
"channels": channel_ids,
"rewardValueType": RewardValueTypeEnum.PERCENTAGE.name,
- "rewardValue": Decimal("101"),
+ "rewardValue": Decimal(101),
"cataloguePredicate": catalogue_predicate,
}
],
@@ -683,7 +683,7 @@ def test_promotion_create_start_date_and_end_date_after_current_date(
}
rule_1_name = "test promotion rule 1"
rule_2_name = "test promotion rule 2"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type_1 = RewardValueTypeEnum.FIXED.name
reward_value_type_2 = RewardValueTypeEnum.PERCENTAGE.name
promotion_type = PromotionTypeEnum.CATALOGUE.name
@@ -775,7 +775,7 @@ def test_promotion_create_missing_predicate(
rule_1_name = "test promotion rule 1"
rule_2_name = "test promotion rule 2"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type_1 = RewardValueTypeEnum.FIXED.name
reward_value_type_2 = RewardValueTypeEnum.PERCENTAGE.name
rule_1_channel_ids = [graphene.Node.to_global_id("Channel", channel_USD.pk)]
@@ -851,7 +851,7 @@ def test_promotion_create_missing_reward_value(
rule_1_name = "test promotion rule 1"
rule_2_name = "test promotion rule 2"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type_1 = RewardValueTypeEnum.FIXED.name
reward_value_type_2 = RewardValueTypeEnum.PERCENTAGE.name
rule_1_channel_ids = [graphene.Node.to_global_id("Channel", channel_USD.pk)]
@@ -920,7 +920,7 @@ def test_promotion_create_missing_reward_value_type(
rule_1_name = "test promotion rule 1"
rule_2_name = "test promotion rule 2"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
rule_1_channel_ids = [graphene.Node.to_global_id("Channel", channel_USD.pk)]
rule_2_channel_ids = [graphene.Node.to_global_id("Channel", channel_PLN.pk)]
@@ -988,7 +988,7 @@ def test_promotion_create_invalid_channel_id(
rule_1_name = "test promotion rule 1"
rule_2_name = "test promotion rule 2"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type_1 = RewardValueTypeEnum.FIXED.name
reward_value_type_2 = RewardValueTypeEnum.PERCENTAGE.name
rule_1_channel_ids = [graphene.Node.to_global_id("Channel", -1)]
@@ -1064,7 +1064,7 @@ def test_promotion_create_mixed_catalogue_and_order_rules(
}
rule_1_name = "test promotion rule 1"
rule_2_name = "test promotion rule 2"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type_1 = RewardValueTypeEnum.FIXED.name
reward_value_type_2 = RewardValueTypeEnum.PERCENTAGE.name
@@ -1147,7 +1147,7 @@ def test_promotion_create_mixed_currencies_for_price_based_predicate(
"discountedObjectPredicate": {"baseSubtotalPrice": {"range": {"gte": 100}}}
}
rule_name = "test promotion rule 1"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
reward_type = RewardTypeEnum.SUBTOTAL_DISCOUNT.name
channel_ids = [
@@ -1297,7 +1297,7 @@ def test_promotion_create_end_date_before_start_date(
rule_1_name = "test promotion rule 1"
rule_2_name = "test promotion rule 2"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type_1 = RewardValueTypeEnum.FIXED.name
reward_value_type_2 = RewardValueTypeEnum.PERCENTAGE.name
rule_1_channel_ids = [graphene.Node.to_global_id("Channel", channel_USD.pk)]
@@ -1391,7 +1391,7 @@ def test_promotion_create_invalid_catalogue_predicate(
}
rule_1_name = "test promotion rule 1"
rule_2_name = "test promotion rule 2"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type_1 = RewardValueTypeEnum.FIXED.name
reward_value_type_2 = RewardValueTypeEnum.PERCENTAGE.name
@@ -1456,7 +1456,7 @@ def test_promotion_create_exceeds_rules_number_limit(
"discountedObjectPredicate": {"baseSubtotalPrice": {"range": {"gte": 100}}}
}
rule_name = "test promotion rule 1"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
reward_type = RewardTypeEnum.SUBTOTAL_DISCOUNT.name
channel_id = graphene.Node.to_global_id("Channel", channel_USD.pk)
@@ -1589,7 +1589,7 @@ def test_promotion_create_rules_without_channels_and_percentage_reward(
{
"name": "test promotion rule 1",
"rewardValueType": RewardValueTypeEnum.PERCENTAGE.name,
- "rewardValue": Decimal("10"),
+ "rewardValue": Decimal(10),
"cataloguePredicate": catalogue_predicate,
}
],
@@ -1673,13 +1673,13 @@ def test_promotion_create_events_by_staff_user(
"channels": rule_1_channel_ids,
"cataloguePredicate": catalogue_predicate,
"rewardValueType": RewardValueTypeEnum.FIXED.name,
- "rewardValue": Decimal("1"),
+ "rewardValue": Decimal(1),
},
{
"channels": rule_2_channel_ids,
"cataloguePredicate": catalogue_predicate,
"rewardValueType": RewardValueTypeEnum.FIXED.name,
- "rewardValue": Decimal("1"),
+ "rewardValue": Decimal(1),
},
],
}
@@ -1746,13 +1746,13 @@ def test_promotion_create_events_by_app(
"channels": rule_1_channel_ids,
"cataloguePredicate": catalogue_predicate,
"rewardValueType": RewardValueTypeEnum.FIXED.name,
- "rewardValue": Decimal("1"),
+ "rewardValue": Decimal(1),
},
{
"channels": rule_2_channel_ids,
"cataloguePredicate": catalogue_predicate,
"rewardValueType": RewardValueTypeEnum.FIXED.name,
- "rewardValue": Decimal("1"),
+ "rewardValue": Decimal(1),
},
],
}
@@ -1917,7 +1917,7 @@ def test_promotion_create_gift_promotion_with_reward_value(
}
rule_name = "test gift promotion rule"
reward_type = RewardTypeEnum.GIFT.name
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
channel_ids = [graphene.Node.to_global_id("Channel", channel_USD.pk)]
gift_ids = [
graphene.Node.to_global_id("ProductVariant", variant.pk)
@@ -2086,7 +2086,7 @@ def test_promotion_create_without_catalogue_predicate(
"description": description_json,
"channels": channel_ids,
"rewardValueType": RewardValueTypeEnum.PERCENTAGE.name,
- "rewardValue": Decimal("50"),
+ "rewardValue": Decimal(50),
"cataloguePredicate": None,
}
],
diff --git a/saleor/graphql/discount/tests/mutations/test_promotion_rule_create.py b/saleor/graphql/discount/tests/mutations/test_promotion_rule_create.py
index df6a0f7201..2560a7756f 100644
--- a/saleor/graphql/discount/tests/mutations/test_promotion_rule_create.py
+++ b/saleor/graphql/discount/tests/mutations/test_promotion_rule_create.py
@@ -101,7 +101,7 @@ def test_promotion_rule_create_by_staff_user(
]
}
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
rules_count = promotion.rules.count()
@@ -174,7 +174,7 @@ def test_promotion_rule_create_by_app(
]
}
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
rules_count = promotion.rules.count()
@@ -241,7 +241,7 @@ def test_promotion_rule_create_by_customer(
]
}
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
@@ -285,7 +285,7 @@ def test_promotion_rule_create_missing_predicate(
for channel in [channel_USD, channel_PLN]
]
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
rules_count = promotion.rules.count()
@@ -395,7 +395,7 @@ def test_promotion_rule_create_missing_reward_value_type(
"productPredicate": {"ids": [graphene.Node.to_global_id("Product", product.id)]}
}
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
rules_count = promotion.rules.count()
@@ -530,7 +530,7 @@ def test_promotion_rule_invalid_catalogue_predicate(
]
}
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
rules_count = promotion.rules.count()
@@ -591,7 +591,7 @@ def test_promotion_rule_invalid_order_predicate(
]
}
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
rules_count = promotion.rules.count()
@@ -718,7 +718,7 @@ def test_promotion_rule_create_fixed_reward_value_multiple_currencies(
]
}
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
rules_count = promotion.rules.count()
@@ -780,7 +780,7 @@ def test_promotion_rule_create_fixed_reward_no_channels(
]
}
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
rules_count = promotion.rules.count()
@@ -845,7 +845,7 @@ def test_promotion_rule_create_percentage_value_above_100(
]
}
name = "test promotion rule"
- reward_value = Decimal("110")
+ reward_value = Decimal(110)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
rules_count = promotion.rules.count()
@@ -906,7 +906,7 @@ def test_promotion_rule_create_clears_old_sale_id(
]
}
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
rules_count = promotion.rules.count()
@@ -972,7 +972,7 @@ def test_promotion_rule_create_events(
},
]
}
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
@@ -1017,7 +1017,7 @@ def test_promotion_rule_create_serializable_decimal_in_predicate(
catalogue_predicate = {
"productPredicate": {"minimalPrice": {"range": {"gte": "25"}}}
}
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
@@ -1053,7 +1053,7 @@ def test_promotion_rule_create_multiple_predicates(
permission_group_manage_discounts.user_set.add(staff_api_client.user)
channel_id = graphene.Node.to_global_id("Channel", channel_USD.pk)
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
catalogue_predicate = {
@@ -1112,7 +1112,7 @@ def test_promotion_rule_create_mixed_predicates_order(
permission_group_manage_discounts.user_set.add(staff_api_client.user)
channel_id = graphene.Node.to_global_id("Channel", channel_USD.pk)
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
reward_type = RewardTypeEnum.SUBTOTAL_DISCOUNT.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
@@ -1166,7 +1166,7 @@ def test_promotion_rule_create_mixed_predicates_catalogue(
permission_group_manage_discounts.user_set.add(staff_api_client.user)
channel_id = graphene.Node.to_global_id("Channel", channel_USD.pk)
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
catalogue_predicate = {
@@ -1218,7 +1218,7 @@ def test_promotion_rule_create_missing_reward_type(
permission_group_manage_discounts.user_set.add(staff_api_client.user)
channel_id = graphene.Node.to_global_id("Channel", channel_USD.pk)
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
order_predicate = {
@@ -1266,7 +1266,7 @@ def test_promotion_rule_create_reward_type_with_catalogue_predicate(
permission_group_manage_discounts.user_set.add(staff_api_client.user)
channel_id = graphene.Node.to_global_id("Channel", channel_USD.pk)
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
reward_type = RewardTypeEnum.SUBTOTAL_DISCOUNT.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
@@ -1317,7 +1317,7 @@ def test_promotion_rule_create_order_predicate(
permission_group_manage_discounts.user_set.add(staff_api_client.user)
channel_id = graphene.Node.to_global_id("Channel", channel_USD.pk)
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
reward_type = RewardTypeEnum.SUBTOTAL_DISCOUNT.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
@@ -1376,7 +1376,7 @@ def test_promotion_rule_create_mixed_currencies_for_price_based_predicate(
promotion = order_promotion_without_rules
permission_group_manage_discounts.user_set.add(staff_api_client.user)
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
reward_type = RewardTypeEnum.SUBTOTAL_DISCOUNT.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
@@ -1444,7 +1444,7 @@ def test_promotion_rule_create_with_metadata(
"OR": [{"variantPredicate": {"metadata": [{"key": "test", "value": "test"}]}}]
}
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
promotion_id = graphene.Node.to_global_id("Promotion", catalogue_promotion.id)
@@ -1482,7 +1482,7 @@ def test_promotion_rule_create_exceeds_rules_number_limit(
promotion = order_promotion_without_rules
permission_group_manage_discounts.user_set.add(staff_api_client.user)
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
reward_type = RewardTypeEnum.SUBTOTAL_DISCOUNT.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
@@ -1752,7 +1752,7 @@ def test_promotion_rule_create_gift_promotion_with_reward_value(
channel_id = graphene.Node.to_global_id("Channel", channel_USD.pk)
name = "test promotion rule"
reward_type = RewardTypeEnum.GIFT.name
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
order_predicate = {
"discountedObjectPredicate": {"baseSubtotalPrice": {"range": {"gte": "100"}}}
@@ -1902,7 +1902,7 @@ def test_promotion_rule_create_invalid_promotion_id(
}
}
name = "test promotion rule"
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
invalid_promotion_id = graphene.Node.to_global_id(
"PromotionRule", promotion_rule.id
diff --git a/saleor/graphql/discount/tests/mutations/test_promotion_rule_update.py b/saleor/graphql/discount/tests/mutations/test_promotion_rule_update.py
index dbf0d75d47..48e1b82ad5 100644
--- a/saleor/graphql/discount/tests/mutations/test_promotion_rule_update.py
+++ b/saleor/graphql/discount/tests/mutations/test_promotion_rule_update.py
@@ -77,7 +77,7 @@ def test_promotion_rule_update_by_staff_user(
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("5"),
+ reward_value=Decimal(5),
)
rule_id = graphene.Node.to_global_id("PromotionRule", rule.id)
@@ -102,7 +102,7 @@ def test_promotion_rule_update_by_staff_user(
]
}
collection.products.add(product_list[2])
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
rules_count = promotion.rules.count()
@@ -159,7 +159,7 @@ def test_promotion_rule_update_by_app(
add_channel_ids = [graphene.Node.to_global_id("Channel", channel_PLN.pk)]
remove_channel_ids = [graphene.Node.to_global_id("Channel", channel_USD.pk)]
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
rules_count = promotion.rules.count()
@@ -217,7 +217,7 @@ def test_promotion_rule_update_by_customer(
add_channel_ids = [graphene.Node.to_global_id("Channel", channel_PLN.pk)]
remove_channel_ids = [graphene.Node.to_global_id("Channel", channel_USD.pk)]
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
variables = {
@@ -273,7 +273,7 @@ def test_promotion_rule_update_duplicates_channels_in_add_and_remove_field(
},
]
}
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.FIXED.name
variables = {
@@ -350,7 +350,7 @@ def test_promotion_rule_update_invalid_catalogue_predicate(
},
],
}
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
variables = {
"id": rule_id,
@@ -386,7 +386,7 @@ def test_promotion_rule_update_add_channel_with_different_currency_to_fixed_disc
rule_id = graphene.Node.to_global_id("PromotionRule", rule.id)
add_channel_ids = [graphene.Node.to_global_id("Channel", channel_PLN.pk)]
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
variables = {
"id": rule_id,
@@ -429,7 +429,7 @@ def test_promotion_rule_update_remove_last_channel_from_fixed_discount(
rule_id = graphene.Node.to_global_id("PromotionRule", rule.id)
remove_channel_ids = [graphene.Node.to_global_id("Channel", channel_USD.pk)]
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
variables = {
"id": rule_id,
@@ -471,7 +471,7 @@ def test_promotion_rule_update_remove_and_add_channel_with_the_same_currency(
remove_channel_ids = [graphene.Node.to_global_id("Channel", channel_USD.pk)]
add_channel_ids = [graphene.Node.to_global_id("Channel", other_channel_USD.pk)]
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
variables = {
"id": rule_id,
@@ -636,7 +636,7 @@ def test_promotion_rule_update_reward_value_invalid_percentage_value(
add_channel_ids = [graphene.Node.to_global_id("Channel", channel_PLN.pk)]
remove_channel_ids = [graphene.Node.to_global_id("Channel", channel_USD.pk)]
- reward_value = Decimal("101")
+ reward_value = Decimal(101)
variables = {
"id": rule_id,
@@ -690,7 +690,7 @@ def test_promotion_rule_update_clears_old_sale_id(
}
},
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("5"),
+ reward_value=Decimal(5),
)
rule_id = graphene.Node.to_global_id("PromotionRule", rule.id)
@@ -715,7 +715,7 @@ def test_promotion_rule_update_clears_old_sale_id(
]
}
collection.products.add(product_list[2])
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
rules_count = promotion.rules.count()
@@ -782,7 +782,7 @@ def test_promotion_rule_update_events(
},
]
}
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
reward_value_type = RewardValueTypeEnum.PERCENTAGE.name
variables = {
diff --git a/saleor/graphql/discount/tests/queries/test_promotion.py b/saleor/graphql/discount/tests/queries/test_promotion.py
index 0c2d731b9b..89712156e1 100644
--- a/saleor/graphql/discount/tests/queries/test_promotion.py
+++ b/saleor/graphql/discount/tests/queries/test_promotion.py
@@ -161,7 +161,7 @@ def test_query_promotion_with_complex_rule_2(
description=dummy_editorjs("Test description for percentage promotion rule."),
catalogue_predicate=catalogue_predicate,
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("10"),
+ reward_value=Decimal(10),
)
variables = {"id": graphene.Node.to_global_id("Promotion", promotion.id)}
diff --git a/saleor/graphql/discount/tests/queries/test_sales_pagination.py b/saleor/graphql/discount/tests/queries/test_sales_pagination.py
index 7b6149cb9a..aa585ce54c 100644
--- a/saleor/graphql/discount/tests/queries/test_sales_pagination.py
+++ b/saleor/graphql/discount/tests/queries/test_sales_pagination.py
@@ -42,7 +42,7 @@ def sales_for_pagination(channel_USD):
for promotion in promotions:
promotion.assign_old_sale_id()
- values = [Decimal("1"), Decimal("7"), Decimal("5"), Decimal("5"), Decimal("25")]
+ values = [Decimal(1), Decimal(7), Decimal(5), Decimal(5), Decimal(25)]
rules = PromotionRule.objects.bulk_create(
[
PromotionRule(
diff --git a/saleor/graphql/discount/tests/test_utils.py b/saleor/graphql/discount/tests/test_utils.py
index 79ce69f981..012dd5952a 100644
--- a/saleor/graphql/discount/tests/test_utils.py
+++ b/saleor/graphql/discount/tests/test_utils.py
@@ -281,7 +281,7 @@ def test_get_variants_for_promotion(
variant, product_with_two_variants, product_variant_list
):
# given
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
promotion = Promotion.objects.create(
name="Promotion",
)
diff --git a/saleor/graphql/discount/utils.py b/saleor/graphql/discount/utils.py
index 98d5a0e8ee..2ee9d88fbb 100644
--- a/saleor/graphql/discount/utils.py
+++ b/saleor/graphql/discount/utils.py
@@ -220,7 +220,7 @@ def filter_qs_by_predicate(
result_qs, base_qs, predicate, Operators.AND, predicate_type, currency
)
- return result_qs # type: ignore[return-value]
+ return result_qs
def _handle_and_data(
diff --git a/saleor/graphql/meta/mutations/base.py b/saleor/graphql/meta/mutations/base.py
index 51428c766b..7a2568b288 100644
--- a/saleor/graphql/meta/mutations/base.py
+++ b/saleor/graphql/meta/mutations/base.py
@@ -34,7 +34,7 @@ class BaseMetadataMutation(BaseMutation):
abstract = True
@classmethod
- def __init_subclass_with_meta__(
+ def __init_subclass_with_meta__( # type: ignore[override]
cls,
arguments=None,
permission_map=None,
@@ -153,7 +153,7 @@ class BaseMetadataMutation(BaseMutation):
return graphene_type._meta.model
@classmethod
- def check_permissions(cls, context, permissions=None, **data):
+ def check_permissions(cls, context, permissions=None, **data): # type: ignore[override]
is_app = bool(getattr(context, "app", None))
if is_app and permissions and AccountPermissions.MANAGE_STAFF in permissions:
raise PermissionDenied(
diff --git a/saleor/graphql/order/bulk_mutations/order_bulk_create.py b/saleor/graphql/order/bulk_mutations/order_bulk_create.py
index fb375bc396..7641457404 100644
--- a/saleor/graphql/order/bulk_mutations/order_bulk_create.py
+++ b/saleor/graphql/order/bulk_mutations/order_bulk_create.py
@@ -1311,7 +1311,7 @@ class OrderBulkCreate(BaseMutation, I18nMixin):
undiscounted_unit_net=undiscounted_unit_price_net_amount,
unit_discount_amount=unit_discount_amount,
quantity=quantity,
- tax_rate=tax_rate,
+ tax_rate=tax_rate, # type: ignore[arg-type]
)
@classmethod
diff --git a/saleor/graphql/order/mutations/order_grant_refund_create.py b/saleor/graphql/order/mutations/order_grant_refund_create.py
index fdf9e5554b..89044656ad 100644
--- a/saleor/graphql/order/mutations/order_grant_refund_create.py
+++ b/saleor/graphql/order/mutations/order_grant_refund_create.py
@@ -193,7 +193,7 @@ class OrderGrantRefundCreate(BaseMutation):
reason = input.get("reason") or ""
transaction_id = input.get("transaction_id")
input_lines = input.get("lines", [])
- grant_refund_for_shipping = input.get("grant_refund_for_shipping", None)
+ grant_refund_for_shipping = input.get("grant_refund_for_shipping", False)
cls.validate_input(input)
diff --git a/saleor/graphql/order/mutations/order_grant_refund_update.py b/saleor/graphql/order/mutations/order_grant_refund_update.py
index 0a4a1ae0f6..b1330441bc 100644
--- a/saleor/graphql/order/mutations/order_grant_refund_update.py
+++ b/saleor/graphql/order/mutations/order_grant_refund_update.py
@@ -162,8 +162,7 @@ class OrderGrantRefundUpdate(BaseMutation):
and not only_reason_provided
):
fields_from_input = set(input.keys())
- if "reason" in fields_from_input:
- fields_from_input.remove("reason")
+ fields_from_input.discard("reason")
error_msg = (
"Only reason can be updated when `OrderGrantedRefund.status` is PENDING"
" or SUCCESS."
diff --git a/saleor/graphql/order/tests/benchmark/test_order_bulk_create.py b/saleor/graphql/order/tests/benchmark/test_order_bulk_create.py
index c1604365cd..71ce6c564d 100644
--- a/saleor/graphql/order/tests/benchmark/test_order_bulk_create.py
+++ b/saleor/graphql/order/tests/benchmark/test_order_bulk_create.py
@@ -44,7 +44,7 @@ def test_order_bulk_create(
transaction_1 = {
"name": "Authorized for 10$",
"amountAuthorized": {
- "amount": Decimal("20"),
+ "amount": Decimal(20),
"currency": "PLN",
},
}
@@ -52,7 +52,7 @@ def test_order_bulk_create(
transaction_2 = {
"name": "Credit Card",
"amountCharged": {
- "amount": Decimal("100"),
+ "amount": Decimal(100),
"currency": "PLN",
},
}
diff --git a/saleor/graphql/order/tests/deprecated/test_order.py b/saleor/graphql/order/tests/deprecated/test_order.py
index 070578d098..e18c0a506e 100644
--- a/saleor/graphql/order/tests/deprecated/test_order.py
+++ b/saleor/graphql/order/tests/deprecated/test_order.py
@@ -600,7 +600,7 @@ def test_update_order_line_discount_old_id(
line_price_before_discount = line_to_discount.unit_price
- value = Decimal("5")
+ value = Decimal(5)
reason = "New reason for unit discount"
variables = {
"orderLineId": graphene.Node.to_global_id("OrderLine", line_to_discount.old_id),
diff --git a/saleor/graphql/order/tests/integration/test_bulk_order.py b/saleor/graphql/order/tests/integration/test_bulk_order.py
index 7a88586538..2cb1938e8c 100644
--- a/saleor/graphql/order/tests/integration/test_bulk_order.py
+++ b/saleor/graphql/order/tests/integration/test_bulk_order.py
@@ -168,11 +168,11 @@ def test_return_and_refund_imported_order(
order["lines"][0]["isShippingRequired"] = False
order["fulfillments"][0]["lines"][0]["variantId"] = variant_id
order["transactions"][0]["amountAuthorized"] = {
- "amount": Decimal("0"),
+ "amount": Decimal(0),
"currency": "USD",
}
order["transactions"][0]["amountCharged"] = {
- "amount": Decimal("120"),
+ "amount": Decimal(120),
"currency": "USD",
}
order["transactions"][0]["availableActions"] = [TransactionActionEnum.REFUND.name]
@@ -211,7 +211,7 @@ def test_return_and_refund_imported_order(
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
"action_type": TransactionActionEnum.REFUND.name,
- "amount": Decimal("120"),
+ "amount": Decimal(120),
}
staff_api_client.post_graphql(MUTATION_TRANSACTION_REQUEST_ACTION, variables)
diff --git a/saleor/graphql/order/tests/mutations/test_draft_order_create.py b/saleor/graphql/order/tests/mutations/test_draft_order_create.py
index 599baced18..e3b539bdf0 100644
--- a/saleor/graphql/order/tests/mutations/test_draft_order_create.py
+++ b/saleor/graphql/order/tests/mutations/test_draft_order_create.py
@@ -3203,7 +3203,7 @@ def test_draft_order_create_order_promotion_flat_rates(
promotion_id = graphene.Node.to_global_id("Promotion", rule.promotion_id)
assert rule.reward_value_type == RewardValueType.PERCENTAGE
reward_value = rule.reward_value
- assert rule.reward_value == Decimal("25")
+ assert rule.reward_value == Decimal(25)
variant = variant_with_many_stocks
user_id = graphene.Node.to_global_id("User", customer_user.id)
diff --git a/saleor/graphql/order/tests/mutations/test_draft_order_update.py b/saleor/graphql/order/tests/mutations/test_draft_order_update.py
index 91cf89ef34..4f759c140a 100644
--- a/saleor/graphql/order/tests/mutations/test_draft_order_update.py
+++ b/saleor/graphql/order/tests/mutations/test_draft_order_update.py
@@ -2899,7 +2899,7 @@ def test_draft_order_update_with_voucher_specific_product_and_manual_line_discou
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- voucher_discount_value = Decimal("2")
+ voucher_discount_value = Decimal(2)
voucher_listing.discount_value = voucher_discount_value
voucher_listing.save(update_fields=["discount_value"])
@@ -2911,7 +2911,7 @@ def test_draft_order_update_with_voucher_specific_product_and_manual_line_discou
voucher.variants.add(discounted_line.variant)
# create manual order line discount
- manual_line_discount_value = Decimal("3")
+ manual_line_discount_value = Decimal(3)
update_discount_for_order_line(
discounted_line,
order=order,
@@ -3047,7 +3047,7 @@ def test_draft_order_update_with_voucher_apply_once_per_order_and_manual_line_di
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- voucher_discount_value = Decimal("3")
+ voucher_discount_value = Decimal(3)
voucher_listing.discount_value = voucher_discount_value
voucher_listing.save(update_fields=["discount_value"])
@@ -3059,7 +3059,7 @@ def test_draft_order_update_with_voucher_apply_once_per_order_and_manual_line_di
discounted_line, line_1 = lines
# create manual order line discount
- manual_line_discount_value = Decimal("3")
+ manual_line_discount_value = Decimal(3)
update_discount_for_order_line(
discounted_line,
order=order,
diff --git a/saleor/graphql/order/tests/mutations/test_order_bulk_create.py b/saleor/graphql/order/tests/mutations/test_order_bulk_create.py
index bef381d90e..0d277be1b5 100644
--- a/saleor/graphql/order/tests/mutations/test_order_bulk_create.py
+++ b/saleor/graphql/order/tests/mutations/test_order_bulk_create.py
@@ -388,7 +388,7 @@ def order_bulk_input(
TransactionActionEnum.CANCEL.name,
],
"amountAuthorized": {
- "amount": Decimal("10"),
+ "amount": Decimal(10),
"currency": "PLN",
},
"metadata": [{"key": "test-1", "value": "123"}],
@@ -506,8 +506,8 @@ def order_bulk_input_with_multiple_order_lines_and_fulfillments(
@pytest.mark.parametrize(
("discount_type_enum", "discount_type", "discount_value"),
[
- (DiscountValueTypeEnum.FIXED, DiscountValueType.FIXED, Decimal("10")),
- (DiscountValueTypeEnum.PERCENTAGE, DiscountValueType.PERCENTAGE, Decimal("50")),
+ (DiscountValueTypeEnum.FIXED, DiscountValueType.FIXED, Decimal(10)),
+ (DiscountValueTypeEnum.PERCENTAGE, DiscountValueType.PERCENTAGE, Decimal(50)),
],
)
def test_order_bulk_create_unit_discount(
@@ -769,7 +769,7 @@ def test_order_bulk_create(
assert db_order.voucher_code == voucher_code
assert db_order.metadata["md key"] == "md value"
assert db_order.private_metadata["pmd key"] == "pmd value"
- assert db_order.total_authorized_amount == Decimal("10")
+ assert db_order.total_authorized_amount == Decimal(10)
assert db_order.authorize_status == OrderAuthorizeStatus.PARTIAL.lower()
assert db_order.shipping_address.validation_skipped is False
assert db_order.billing_address.validation_skipped is False
@@ -907,10 +907,10 @@ def test_order_bulk_create(
assert transaction["pspReference"] == "PSP reference - 123"
assert transaction["message"] == "Credit Card"
assert transaction["name"] == "Authorized for 10$"
- assert transaction["authorizedAmount"]["amount"] == Decimal("10")
+ assert transaction["authorizedAmount"]["amount"] == Decimal(10)
assert transaction["authorizedAmount"]["currency"] == "PLN"
db_transaction = TransactionItem.objects.get()
- assert db_transaction.authorized_value == Decimal("10")
+ assert db_transaction.authorized_value == Decimal(10)
assert db_transaction.currency == "PLN"
assert db_transaction.psp_reference == "PSP reference - 123"
assert db_transaction.name == "Authorized for 10$"
@@ -920,12 +920,12 @@ def test_order_bulk_create(
assert db_transaction.private_metadata == {"test-2": "321"}
transaction_event = order["transactions"][0]["events"][0]
- assert transaction_event["amount"]["amount"] == Decimal("10")
+ assert transaction_event["amount"]["amount"] == Decimal(10)
assert (
transaction_event["type"] == TransactionEventType.AUTHORIZATION_SUCCESS.upper()
)
db_transaction_event = TransactionEvent.objects.get()
- assert db_transaction_event.amount.amount == Decimal("10")
+ assert db_transaction_event.amount.amount == Decimal(10)
assert db_transaction_event.type == TransactionEventType.AUTHORIZATION_SUCCESS
assert db_transaction_event.transaction_id == db_transaction.id
@@ -1430,7 +1430,7 @@ def test_order_bulk_create_multiple_transactions(
):
# given
transactions_count = TransactionItem.objects.count()
- authorized_amount = Decimal("80")
+ authorized_amount = Decimal(80)
transaction_1 = {
"name": "Authorized for 80$",
"amountAuthorized": {
@@ -1439,7 +1439,7 @@ def test_order_bulk_create_multiple_transactions(
},
}
- charged_amount = Decimal("100")
+ charged_amount = Decimal(100)
transaction_2 = {
"message": "Credit Card",
"amountCharged": {
@@ -1448,7 +1448,7 @@ def test_order_bulk_create_multiple_transactions(
},
}
- refunded_amount = Decimal("15")
+ refunded_amount = Decimal(15)
transaction_3 = {
"pspReference": "PSP reference - 123",
"amountRefunded": {
@@ -1457,7 +1457,7 @@ def test_order_bulk_create_multiple_transactions(
},
}
- canceled_amount = Decimal("20")
+ canceled_amount = Decimal(20)
transaction_4 = {
"amountCanceled": {
"amount": canceled_amount,
@@ -1541,19 +1541,19 @@ def test_order_bulk_create_transactions_with_multiple_amounts(
transaction = {
"amountAuthorized": {
- "amount": Decimal("10"),
+ "amount": Decimal(10),
"currency": "PLN",
},
"amountCharged": {
- "amount": Decimal("100"),
+ "amount": Decimal(100),
"currency": "PLN",
},
"amountRefunded": {
- "amount": Decimal("15"),
+ "amount": Decimal(15),
"currency": "PLN",
},
"amountCanceled": {
- "amount": Decimal("20"),
+ "amount": Decimal(20),
"currency": "PLN",
},
}
@@ -1580,25 +1580,25 @@ def test_order_bulk_create_transactions_with_multiple_amounts(
order = data[0]["order"]
transaction = order["transactions"][0]
- assert transaction["authorizedAmount"]["amount"] == Decimal("10")
+ assert transaction["authorizedAmount"]["amount"] == Decimal(10)
assert transaction["authorizedAmount"]["currency"] == "PLN"
- assert transaction["chargedAmount"]["amount"] == Decimal("100")
+ assert transaction["chargedAmount"]["amount"] == Decimal(100)
assert transaction["chargedAmount"]["currency"] == "PLN"
- assert transaction["refundedAmount"]["amount"] == Decimal("15")
+ assert transaction["refundedAmount"]["amount"] == Decimal(15)
assert transaction["refundedAmount"]["currency"] == "PLN"
- assert transaction["canceledAmount"]["amount"] == Decimal("20")
+ assert transaction["canceledAmount"]["amount"] == Decimal(20)
assert transaction["canceledAmount"]["currency"] == "PLN"
db_order = Order.objects.get()
db_transaction = TransactionItem.objects.get()
- assert db_transaction.authorized_value == Decimal("10")
- assert db_transaction.charged_value == Decimal("100")
- assert db_transaction.refunded_value == Decimal("15")
- assert db_transaction.canceled_value == Decimal("20")
+ assert db_transaction.authorized_value == Decimal(10)
+ assert db_transaction.charged_value == Decimal(100)
+ assert db_transaction.refunded_value == Decimal(15)
+ assert db_transaction.canceled_value == Decimal(20)
assert db_transaction.order_id == db_order.id
- assert db_order.total_authorized_amount == Decimal("10")
- assert db_order.total_charged_amount == Decimal("100")
+ assert db_order.total_authorized_amount == Decimal(10)
+ assert db_order.total_charged_amount == Decimal(100)
assert db_order.authorize_status == OrderAuthorizeStatus.PARTIAL.lower()
assert db_order.charge_status == OrderChargeStatus.PARTIAL.lower()
@@ -3144,7 +3144,7 @@ def test_order_bulk_create_quantize_prices(
assert db_order_line.unit_price.net.amount == Decimal("3.33")
assert db_order_line.undiscounted_unit_price.gross.amount == Decimal("7.67")
assert db_order_line.undiscounted_unit_price.net.amount == Decimal("4.33")
- assert db_order_line.unit_discount_amount == Decimal("1")
+ assert db_order_line.unit_discount_amount == Decimal(1)
def test_order_bulk_create_error_currency_mismatch_between_transaction_and_order(
diff --git a/saleor/graphql/order/tests/mutations/test_order_discount.py b/saleor/graphql/order/tests/mutations/test_order_discount.py
index 326cc147ae..9cb17fb62b 100644
--- a/saleor/graphql/order/tests/mutations/test_order_discount.py
+++ b/saleor/graphql/order/tests/mutations/test_order_discount.py
@@ -41,8 +41,8 @@ mutation OrderDiscountAdd($orderId: ID!, $input: OrderDiscountCommonInput!){
@pytest.mark.parametrize(
("value", "value_type"),
[
- (Decimal("2222222"), DiscountValueTypeEnum.FIXED.name),
- (Decimal("101"), DiscountValueTypeEnum.PERCENTAGE.name),
+ (Decimal(2222222), DiscountValueTypeEnum.FIXED.name),
+ (Decimal(101), DiscountValueTypeEnum.PERCENTAGE.name),
],
)
def test_add_order_discount_incorrect_values(
@@ -72,7 +72,7 @@ def test_add_fixed_order_discount_order_is_not_draft(
order_with_lines, staff_api_client, permission_group_manage_orders
):
# given
- value = Decimal("10")
+ value = Decimal(10)
variables = {
"orderId": graphene.Node.to_global_id("Order", order_with_lines.pk),
"input": {"valueType": DiscountValueTypeEnum.FIXED.name, "value": value},
@@ -308,7 +308,7 @@ def test_add_manual_discount_replaces_entire_voucher(
order.status = OrderStatus.DRAFT
order.save(update_fields=["status", "should_refresh_prices"])
- expected_voucher_discount_amount = Decimal("12")
+ expected_voucher_discount_amount = Decimal(12)
assert voucher.type == VoucherType.ENTIRE_ORDER
assert voucher.discount_value_type == DiscountValueType.FIXED
@@ -398,7 +398,7 @@ def test_add_manual_discount_keeps_shipping_voucher(
assert order.discounts.count() == 2
shipping_discount = order.discounts.get(type=DiscountType.VOUCHER)
- assert shipping_discount.value == Decimal("100")
+ assert shipping_discount.value == Decimal(100)
assert shipping_discount.value_type == DiscountValueType.PERCENTAGE
assert shipping_discount.amount == order.undiscounted_base_shipping_price
@@ -688,7 +688,7 @@ def test_update_order_discount_order_is_not_draft(
order_discount = draft_order_with_fixed_discount_order.discounts.get()
- value = Decimal("50")
+ value = Decimal(50)
variables = {
"discountId": graphene.Node.to_global_id("OrderDiscount", order_discount.pk),
"input": {
@@ -712,8 +712,8 @@ def test_update_order_discount_order_is_not_draft(
@pytest.mark.parametrize(
("value", "value_type"),
[
- (Decimal("2222222"), DiscountValueTypeEnum.FIXED.name),
- (Decimal("101"), DiscountValueTypeEnum.PERCENTAGE.name),
+ (Decimal(2222222), DiscountValueTypeEnum.FIXED.name),
+ (Decimal(101), DiscountValueTypeEnum.PERCENTAGE.name),
],
)
def test_update_order_discount_incorrect_values(
@@ -1213,7 +1213,7 @@ def test_update_order_line_discount(
line_price_before_discount = line_to_discount.unit_price
- value = Decimal("5")
+ value = Decimal(5)
value_type = DiscountValueTypeEnum.FIXED
reason = "New reason for unit discount"
variables = {
@@ -1312,7 +1312,7 @@ def test_update_order_line_discount_by_user_no_channel_access(
order.save(update_fields=["status", "channel"])
line_to_discount = order.lines.first()
- value = Decimal("5")
+ value = Decimal(5)
reason = "New reason for unit discount"
variables = {
"orderLineId": graphene.Node.to_global_id("OrderLine", line_to_discount.pk),
@@ -1349,7 +1349,7 @@ def test_update_order_line_discount_by_app(
order.save(update_fields=["status", "channel"])
line_to_discount = order.lines.first()
- value = Decimal("5")
+ value = Decimal(5)
value_type = DiscountValueTypeEnum.FIXED
reason = "New reason for unit discount"
variables = {
@@ -1447,7 +1447,7 @@ def test_update_order_line_discount_line_with_discount(
line_undiscounted_price = line_to_discount.undiscounted_unit_price
- value = Decimal("50")
+ value = Decimal(50)
value_type = DiscountValueTypeEnum.PERCENTAGE
reason = "New reason for unit discount"
variables = {
@@ -1530,7 +1530,7 @@ def test_update_order_line_discount_line_with_catalogue_promotion(
unidscounted_unit_price = line.undiscounted_base_unit_price.amount
tax_rate = Decimal("1.23")
- manual_discount_value = Decimal("5")
+ manual_discount_value = Decimal(5)
value_type = DiscountValueTypeEnum.FIXED
reason = "Manual fixed line discount"
variables = {
@@ -1603,7 +1603,7 @@ def test_update_order_line_discount_order_is_not_draft(
"orderLineId": graphene.Node.to_global_id("OrderLine", line_to_discount.pk),
"input": {
"valueType": DiscountValueTypeEnum.FIXED.name,
- "value": Decimal("5"),
+ "value": Decimal(5),
"reason": "New reason for unit discount",
},
}
@@ -1621,7 +1621,7 @@ def test_update_order_line_discount_order_is_not_draft(
assert error["field"] == "orderId"
assert error["code"] == OrderErrorCode.CANNOT_DISCOUNT.name
- assert line_to_discount.unit_discount_amount == Decimal("0")
+ assert line_to_discount.unit_discount_amount == Decimal(0)
def test_add_manual_line_discount_order_with_voucher_specific_product(
@@ -1640,7 +1640,7 @@ def test_add_manual_line_discount_order_with_voucher_specific_product(
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- voucher_discount_value = Decimal("2")
+ voucher_discount_value = Decimal(2)
voucher_listing.discount_value = voucher_discount_value
voucher_listing.save(update_fields=["discount_value"])
@@ -1661,7 +1661,7 @@ def test_add_manual_line_discount_order_with_voucher_specific_product(
undiscounted_subtotal += line.undiscounted_base_unit_price * line.quantity
permission_group_manage_orders.user_set.add(staff_api_client.user)
- manual_line_discount_value = Decimal("3")
+ manual_line_discount_value = Decimal(3)
variables = {
"orderLineId": graphene.Node.to_global_id("OrderLine", discounted_line.pk),
"input": {
@@ -1782,7 +1782,7 @@ def test_add_manual_line_discount_order_with_voucher_apply_once_per_order(
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- voucher_discount_value = Decimal("3")
+ voucher_discount_value = Decimal(3)
voucher_listing.discount_value = voucher_discount_value
voucher_listing.save(update_fields=["discount_value"])
@@ -1803,7 +1803,7 @@ def test_add_manual_line_discount_order_with_voucher_apply_once_per_order(
undiscounted_subtotal += line.undiscounted_base_unit_price * line.quantity
permission_group_manage_orders.user_set.add(staff_api_client.user)
- manual_line_discount_value = Decimal("3")
+ manual_line_discount_value = Decimal(3)
variables = {
"orderLineId": graphene.Node.to_global_id("OrderLine", discounted_line.pk),
"input": {
diff --git a/saleor/graphql/order/tests/mutations/test_order_grant_refund_create.py b/saleor/graphql/order/tests/mutations/test_order_grant_refund_create.py
index 38d27ada58..01158a538e 100644
--- a/saleor/graphql/order/tests/mutations/test_order_grant_refund_create.py
+++ b/saleor/graphql/order/tests/mutations/test_order_grant_refund_create.py
@@ -328,7 +328,7 @@ def test_grant_refund_with_only_include_grant_refund_for_shipping(
order = order_with_lines
order_id = to_global_id_or_none(order)
staff_api_client.user.user_permissions.add(permission_manage_orders)
- amount = Decimal("20")
+ amount = Decimal(20)
transaction_item = transaction_item_generator(
charged_value=amount, order_id=order.id
)
diff --git a/saleor/graphql/order/tests/mutations/test_order_line_update.py b/saleor/graphql/order/tests/mutations/test_order_line_update.py
index d7c9be6190..813add8e75 100644
--- a/saleor/graphql/order/tests/mutations/test_order_line_update.py
+++ b/saleor/graphql/order/tests/mutations/test_order_line_update.py
@@ -543,7 +543,7 @@ def test_order_line_update_order_promotion(
rule = order_promotion_rule
promotion_id = graphene.Node.to_global_id("Promotion", rule.promotion_id)
- reward_value = Decimal("25")
+ reward_value = Decimal(25)
assert rule.reward_value == reward_value
assert rule.reward_value_type == RewardValueType.PERCENTAGE
diff --git a/saleor/graphql/order/tests/mutations/test_order_lines_create.py b/saleor/graphql/order/tests/mutations/test_order_lines_create.py
index 18e09349f2..e535543cb0 100644
--- a/saleor/graphql/order/tests/mutations/test_order_lines_create.py
+++ b/saleor/graphql/order/tests/mutations/test_order_lines_create.py
@@ -613,7 +613,7 @@ def test_order_lines_create_variant_on_promotion(
variant = variant_with_many_stocks
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = catalogue_promotion_without_rules.rules.create(
name="Promotion rule",
catalogue_predicate={
@@ -725,7 +725,7 @@ def test_order_lines_create_order_promotion(
rule = order_promotion_rule
promotion_id = graphene.Node.to_global_id("Promotion", rule.promotion_id)
assert rule.reward_value_type == RewardValueType.PERCENTAGE
- assert rule.reward_value == Decimal("25")
+ assert rule.reward_value == Decimal(25)
variant = variant_with_many_stocks
quantity = 5
@@ -2077,7 +2077,7 @@ def test_order_lines_create_dont_set_price_expiration_time_when_price_overridden
variant = variant_with_many_stocks
quantity = 1
- custom_price = Decimal("5")
+ custom_price = Decimal(5)
order_id = graphene.Node.to_global_id("Order", order.id)
variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)
variables = {
@@ -2161,7 +2161,7 @@ def test_order_lines_create_existing_variant_and_custom_price_unset_expiration_d
extra_quantity = 1
order_id = graphene.Node.to_global_id("Order", order.id)
variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)
- custom_price = Decimal("5")
+ custom_price = Decimal(5)
variables = {
"orderId": order_id,
"variantId": variant_id,
diff --git a/saleor/graphql/order/tests/mutations/test_order_update_shipping.py b/saleor/graphql/order/tests/mutations/test_order_update_shipping.py
index 8c44412142..3292ec9e33 100644
--- a/saleor/graphql/order/tests/mutations/test_order_update_shipping.py
+++ b/saleor/graphql/order/tests/mutations/test_order_update_shipping.py
@@ -543,7 +543,7 @@ def test_order_update_shipping_with_voucher_discount(
order.status = OrderStatus.DRAFT
assert order.shipping_method != shipping_method
- new_undiscounted_shipping_price = Money(Decimal("16"), currency)
+ new_undiscounted_shipping_price = Money(Decimal(16), currency)
assert new_undiscounted_shipping_price > order.undiscounted_base_shipping_price
new_shipping_listing = shipping_method.channel_listings.get(
channel_id=order.channel_id
diff --git a/saleor/graphql/order/tests/queries/test_draft_order.py b/saleor/graphql/order/tests/queries/test_draft_order.py
index 55121a2e9e..26e5964ab4 100644
--- a/saleor/graphql/order/tests/queries/test_draft_order.py
+++ b/saleor/graphql/order/tests/queries/test_draft_order.py
@@ -451,15 +451,15 @@ def test_draft_orders_query_with_search(
OrderDiscount(
order=orders[0],
name="Some discount name",
- value=Decimal("1"),
- amount_value=Decimal("1"),
+ value=Decimal(1),
+ amount_value=Decimal(1),
translated_name="translated",
),
OrderDiscount(
order=orders[2],
name="Some other discount name",
- value=Decimal("10"),
- amount_value=Decimal("10"),
+ value=Decimal(10),
+ amount_value=Decimal(10),
translated_name="PL_name",
),
]
diff --git a/saleor/graphql/order/tests/queries/test_draft_order_with_filter.py b/saleor/graphql/order/tests/queries/test_draft_order_with_filter.py
index 0772aca38d..d02cf7bf98 100644
--- a/saleor/graphql/order/tests/queries/test_draft_order_with_filter.py
+++ b/saleor/graphql/order/tests/queries/test_draft_order_with_filter.py
@@ -245,15 +245,15 @@ def test_draft_orders_query_with_filter_search(
OrderDiscount(
order=orders[0],
name="Some discount name",
- value=Decimal("1"),
- amount_value=Decimal("1"),
+ value=Decimal(1),
+ amount_value=Decimal(1),
translated_name="translated",
),
OrderDiscount(
order=orders[2],
name="Some other discount name",
- value=Decimal("10"),
- amount_value=Decimal("10"),
+ value=Decimal(10),
+ amount_value=Decimal(10),
translated_name="PL_name",
),
]
@@ -280,7 +280,7 @@ def test_draft_orders_query_with_filter_base_total_price_range(draft_order, gte,
# given
order = draft_order
currency = order.currency
- order.total_net_amount = Decimal("20")
+ order.total_net_amount = Decimal(20)
order.save(update_fields=["total_net_amount"])
qs = Order.objects.all()
@@ -315,7 +315,7 @@ def test_draft_orders_query_with_filter_base_subtotal_price_range(
# given
order = draft_order
currency = order.currency
- order.subtotal_net_amount = Decimal("20")
+ order.subtotal_net_amount = Decimal(20)
order.save(update_fields=["subtotal_net_amount"])
qs = Order.objects.all()
@@ -352,7 +352,7 @@ def test_draft_orders_query_with_filter_base_total_price_one_of(
# given
order = draft_order
currency = order.currency
- order.total_net_amount = Decimal("20")
+ order.total_net_amount = Decimal(20)
order.save(update_fields=["total_net_amount"])
qs = Order.objects.all()
@@ -385,7 +385,7 @@ def test_draft_orders_query_with_filter_base_subtotal_price_one_of(
# given
order = draft_order
currency = order.currency
- order.subtotal_net_amount = Decimal("20")
+ order.subtotal_net_amount = Decimal(20)
order.save(update_fields=["subtotal_net_amount"])
qs = Order.objects.all()
@@ -412,7 +412,7 @@ def test_draft_orders_query_with_filter_base_subtotal_price_one_of(
def test_draft_orders_query_with_filter_base_total_price_missing_currency(draft_order):
# given
order = draft_order
- order.total_net_amount = Decimal("20")
+ order.total_net_amount = Decimal(20)
order.save(update_fields=["total_net_amount"])
qs = Order.objects.all()
@@ -443,7 +443,7 @@ def test_draft_orders_query_with_filter_base_subtotal_price_missing_currency(
):
# given
order = draft_order
- order.subtotal_net_amount = Decimal("20")
+ order.subtotal_net_amount = Decimal(20)
order.save(update_fields=["subtotal_net_amount"])
qs = Order.objects.all()
@@ -473,7 +473,7 @@ def test_draft_orders_query_with_filter_price_with_and_or(draft_order):
# given
order = draft_order
currency = order.currency
- order.total_net_amount = Decimal("20")
+ order.total_net_amount = Decimal(20)
order.save(update_fields=["total_net_amount"])
qs = Order.objects.all()
diff --git a/saleor/graphql/order/tests/queries/test_fulfillment.py b/saleor/graphql/order/tests/queries/test_fulfillment.py
index 13ee82c4d6..89f9ec9855 100644
--- a/saleor/graphql/order/tests/queries/test_fulfillment.py
+++ b/saleor/graphql/order/tests/queries/test_fulfillment.py
@@ -131,8 +131,8 @@ def test_fulfillment_with_refund_details(
order = fulfilled_order
order_id = graphene.Node.to_global_id("Order", order.pk)
fulfillment = order.fulfillments.first()
- shipping_refund_amount = Decimal("10")
- total_refund_amount = Decimal("15")
+ shipping_refund_amount = Decimal(10)
+ total_refund_amount = Decimal(15)
fulfillment.shipping_refund_amount = shipping_refund_amount
fulfillment.total_refund_amount = total_refund_amount
fulfillment.save()
diff --git a/saleor/graphql/order/tests/queries/test_order.py b/saleor/graphql/order/tests/queries/test_order.py
index 5b5a9380f1..87c57a2f9f 100644
--- a/saleor/graphql/order/tests/queries/test_order.py
+++ b/saleor/graphql/order/tests/queries/test_order.py
@@ -334,7 +334,7 @@ def test_order_query(
):
# given
order = fulfilled_order
- shipping_net = Money(amount=Decimal("10"), currency="USD")
+ shipping_net = Money(amount=Decimal(10), currency="USD")
shipping_gross = Money(
amount=shipping_net.amount * Decimal(1.23), currency="USD"
).quantize()
@@ -608,7 +608,7 @@ def test_order_query_total_price_is_0(
price = zero_taxed_money(order.currency)
order.shipping_price = price
order.total = price
- shipping_tax_rate = Decimal("0")
+ shipping_tax_rate = Decimal(0)
order.shipping_tax_rate = shipping_tax_rate
private_value = "abc123"
public_value = "123abc"
@@ -789,13 +789,13 @@ def test_order_query_customer(api_client):
@pytest.mark.parametrize(
("total_authorized", "total_charged", "expected_status"),
[
- (Decimal("98.40"), Decimal("0"), OrderAuthorizeStatusEnum.FULL.name),
- (Decimal("0"), Decimal("98.40"), OrderAuthorizeStatusEnum.FULL.name),
- (Decimal("10"), Decimal("88.40"), OrderAuthorizeStatusEnum.FULL.name),
- (Decimal("0"), Decimal("0"), OrderAuthorizeStatusEnum.NONE.name),
- (Decimal("11"), Decimal("0"), OrderAuthorizeStatusEnum.PARTIAL.name),
- (Decimal("0"), Decimal("50.00"), OrderAuthorizeStatusEnum.PARTIAL.name),
- (Decimal("10"), Decimal("40.40"), OrderAuthorizeStatusEnum.PARTIAL.name),
+ (Decimal("98.40"), Decimal(0), OrderAuthorizeStatusEnum.FULL.name),
+ (Decimal(0), Decimal("98.40"), OrderAuthorizeStatusEnum.FULL.name),
+ (Decimal(10), Decimal("88.40"), OrderAuthorizeStatusEnum.FULL.name),
+ (Decimal(0), Decimal(0), OrderAuthorizeStatusEnum.NONE.name),
+ (Decimal(11), Decimal(0), OrderAuthorizeStatusEnum.PARTIAL.name),
+ (Decimal(0), Decimal("50.00"), OrderAuthorizeStatusEnum.PARTIAL.name),
+ (Decimal(10), Decimal("40.40"), OrderAuthorizeStatusEnum.PARTIAL.name),
],
)
def test_order_query_authorize_status(
@@ -829,12 +829,12 @@ def test_order_query_authorize_status(
@pytest.mark.parametrize(
("total_authorized", "total_charged", "expected_status"),
[
- (Decimal("10.40"), Decimal("0"), OrderChargeStatusEnum.NONE.name),
- (Decimal("98.40"), Decimal("0"), OrderChargeStatusEnum.NONE.name),
- (Decimal("0"), Decimal("0"), OrderChargeStatusEnum.NONE.name),
- (Decimal("0"), Decimal("11.00"), OrderChargeStatusEnum.PARTIAL.name),
+ (Decimal("10.40"), Decimal(0), OrderChargeStatusEnum.NONE.name),
+ (Decimal("98.40"), Decimal(0), OrderChargeStatusEnum.NONE.name),
+ (Decimal(0), Decimal(0), OrderChargeStatusEnum.NONE.name),
+ (Decimal(0), Decimal("11.00"), OrderChargeStatusEnum.PARTIAL.name),
(Decimal("88.40"), Decimal("10.00"), OrderChargeStatusEnum.PARTIAL.name),
- (Decimal("0"), Decimal("98.40"), OrderChargeStatusEnum.FULL.name),
+ (Decimal(0), Decimal("98.40"), OrderChargeStatusEnum.FULL.name),
],
)
def test_order_query_charge_status(
@@ -897,7 +897,7 @@ def test_order_query_with_transactions_details(
):
# given
order = fulfilled_order
- net = Money(amount=Decimal("100"), currency="USD")
+ net = Money(amount=Decimal(100), currency="USD")
gross = Money(amount=net.amount * Decimal(1.23), currency="USD").quantize()
shipping_price = TaxedMoney(net=net, gross=gross)
order.shipping_price = shipping_price
@@ -924,7 +924,7 @@ def test_order_query_with_transactions_details(
name="Credit card",
psp_reference="123",
currency="USD",
- authorized_value=Decimal("15"),
+ authorized_value=Decimal(15),
available_actions=[TransactionAction.CHARGE, TransactionAction.CANCEL],
),
TransactionItem(
@@ -933,7 +933,7 @@ def test_order_query_with_transactions_details(
name="Credit card",
psp_reference="321",
currency="USD",
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
available_actions=[TransactionAction.CHARGE, TransactionAction.CANCEL],
),
TransactionItem(
@@ -942,7 +942,7 @@ def test_order_query_with_transactions_details(
name="Credit card",
psp_reference="111",
currency="USD",
- charged_value=Decimal("15"),
+ charged_value=Decimal(15),
available_actions=[TransactionAction.REFUND],
),
TransactionItem(
@@ -951,7 +951,7 @@ def test_order_query_with_transactions_details(
name="Credit card",
psp_reference="111",
currency="USD",
- canceled_value=Decimal("19"),
+ canceled_value=Decimal(19),
available_actions=[],
),
]
@@ -991,10 +991,10 @@ def test_order_query_with_transactions_details(
assert order_data["isPaid"] == order.is_fully_paid()
assert len(order_data["payments"]) == order.payments.count()
- assert Decimal(order_data["totalAuthorized"]["amount"]) == Decimal("25")
- assert Decimal(order_data["totalCaptured"]["amount"]) == Decimal("15")
- assert Decimal(order_data["totalCharged"]["amount"]) == Decimal("15")
- assert Decimal(order_data["totalCanceled"]["amount"]) == Decimal("19")
+ assert Decimal(order_data["totalAuthorized"]["amount"]) == Decimal(25)
+ assert Decimal(order_data["totalCaptured"]["amount"]) == Decimal(15)
+ assert Decimal(order_data["totalCharged"]["amount"]) == Decimal(15)
+ assert Decimal(order_data["totalCanceled"]["amount"]) == Decimal(19)
assert Decimal(str(order_data["totalBalance"]["amount"])) == Decimal("-83.4")
diff --git a/saleor/graphql/order/tests/queries/test_order_amounts.py b/saleor/graphql/order/tests/queries/test_order_amounts.py
index 80a28a7a33..bc36c60b22 100644
--- a/saleor/graphql/order/tests/queries/test_order_amounts.py
+++ b/saleor/graphql/order/tests/queries/test_order_amounts.py
@@ -1220,7 +1220,7 @@ def test_order_total_remaining_grant_query_with_transactions_partially_refunded(
currency="USD",
)
order.payment_transactions.create(
- refund_pending_value=Decimal("125"), charged_value=Decimal("75"), currency="USD"
+ refund_pending_value=Decimal(125), charged_value=Decimal(75), currency="USD"
)
permission_group_manage_orders.user_set.add(staff_api_client.user)
diff --git a/saleor/graphql/order/tests/queries/test_order_granted_refunds.py b/saleor/graphql/order/tests/queries/test_order_granted_refunds.py
index 7d3b6c5975..817dbd98c2 100644
--- a/saleor/graphql/order/tests/queries/test_order_granted_refunds.py
+++ b/saleor/graphql/order/tests/queries/test_order_granted_refunds.py
@@ -68,7 +68,7 @@ def test_order_granted_refunds_query_without_lines_by_user(
):
# given
order = fulfilled_order
- net = Money(amount=Decimal("10"), currency="USD")
+ net = Money(amount=Decimal(10), currency="USD")
gross = Money(amount=net.amount * Decimal(1.23), currency="USD").quantize()
shipping_price = TaxedMoney(net=net, gross=gross)
order.shipping_price = shipping_price
@@ -146,7 +146,7 @@ def test_order_granted_refunds_query_without_lines_by_app(
):
# given
order = fulfilled_order
- net = Money(amount=Decimal("10"), currency="USD")
+ net = Money(amount=Decimal(10), currency="USD")
gross = Money(amount=net.amount * Decimal(1.23), currency="USD").quantize()
shipping_price = TaxedMoney(net=net, gross=gross)
order.shipping_price = shipping_price
@@ -224,7 +224,7 @@ def test_order_granted_refunds_query_by_user(
):
# given
order = fulfilled_order
- net = Money(amount=Decimal("10"), currency="USD")
+ net = Money(amount=Decimal(10), currency="USD")
gross = Money(amount=net.amount * Decimal(1.23), currency="USD").quantize()
shipping_price = TaxedMoney(net=net, gross=gross)
order.shipping_price = shipping_price
@@ -293,7 +293,7 @@ def test_order_granted_refunds_query_by_app(
):
# given
order = fulfilled_order
- net = Money(amount=Decimal("10"), currency="USD")
+ net = Money(amount=Decimal(10), currency="USD")
gross = Money(amount=net.amount * Decimal(1.23), currency="USD").quantize()
shipping_price = TaxedMoney(net=net, gross=gross)
order.shipping_price = shipping_price
diff --git a/saleor/graphql/order/tests/queries/test_order_line.py b/saleor/graphql/order/tests/queries/test_order_line.py
index b77a71819f..f944a9f53c 100644
--- a/saleor/graphql/order/tests/queries/test_order_line.py
+++ b/saleor/graphql/order/tests/queries/test_order_line.py
@@ -792,7 +792,7 @@ def test_order_line_returns_discount_object(
staff_api_client, order_with_lines, permission_group_all_perms_all_channels
):
# given
- expected_amount = Decimal("6")
+ expected_amount = Decimal(6)
expected_reason = "test"
line = order_with_lines.lines.first()
@@ -836,7 +836,7 @@ def test_order_line_skips_voucher_discount_object_when_checkout_origin_and_legac
channel_USD.use_legacy_line_discount_propagation_for_order = True
channel_USD.save()
- expected_amount = Decimal("6")
+ expected_amount = Decimal(6)
expected_reason = "test"
order_with_lines.origin = OrderOrigin.CHECKOUT
@@ -877,7 +877,7 @@ def test_order_line_skips_voucher_discount_object_when_checkout_origin(
channel_USD.use_legacy_line_discount_propagation_for_order = False
channel_USD.save()
- expected_amount = Decimal("6")
+ expected_amount = Decimal(6)
expected_reason = "test"
order_with_lines.origin = OrderOrigin.CHECKOUT
diff --git a/saleor/graphql/order/tests/queries/test_order_total_balance.py b/saleor/graphql/order/tests/queries/test_order_total_balance.py
index 6dbe0c48b2..d61b216712 100644
--- a/saleor/graphql/order/tests/queries/test_order_total_balance.py
+++ b/saleor/graphql/order/tests/queries/test_order_total_balance.py
@@ -36,14 +36,14 @@ def test_total_balance_only_charged(
name="Credit card",
psp_reference="111",
currency="USD",
- charged_value=Decimal("15"),
+ charged_value=Decimal(15),
),
TransactionItem(
order_id=order.id,
name="Credit card",
psp_reference="111",
currency="USD",
- charged_value=Decimal("19"),
+ charged_value=Decimal(19),
available_actions=[],
),
]
@@ -83,14 +83,14 @@ def test_total_balance_charged_and_pending_charged(
name="Credit card",
psp_reference="111",
currency="USD",
- charged_value=Decimal("15"),
+ charged_value=Decimal(15),
),
TransactionItem(
order_id=order.id,
name="Credit card",
psp_reference="111",
currency="USD",
- charge_pending_value=Decimal("19"),
+ charge_pending_value=Decimal(19),
available_actions=[],
),
]
@@ -131,14 +131,14 @@ def test_total_balance_only_refunded(
name="Credit card",
psp_reference="111",
currency="USD",
- refunded_value=Decimal("15"),
+ refunded_value=Decimal(15),
),
TransactionItem(
order_id=order.id,
name="Credit card",
psp_reference="111",
currency="USD",
- refunded_value=Decimal("19"),
+ refunded_value=Decimal(19),
available_actions=[],
),
]
@@ -175,14 +175,14 @@ def test_total_balance_refunded_and_pending_refund(
name="Credit card",
psp_reference="111",
currency="USD",
- refunded_value=Decimal("15"),
+ refunded_value=Decimal(15),
),
TransactionItem(
order_id=order.id,
name="Credit card",
psp_reference="111",
currency="USD",
- refund_pending_value=Decimal("19"),
+ refund_pending_value=Decimal(19),
available_actions=[],
),
]
@@ -219,14 +219,14 @@ def test_total_balance_refunded_and_charged(
name="Credit card",
psp_reference="111",
currency="USD",
- refunded_value=Decimal("15"),
+ refunded_value=Decimal(15),
),
TransactionItem(
order_id=order.id,
name="Credit card",
psp_reference="111",
currency="USD",
- charged_value=Decimal("19"),
+ charged_value=Decimal(19),
available_actions=[],
),
]
@@ -299,14 +299,14 @@ def test_total_balance_with_granted_refund_and_transactions(
name="Credit card",
psp_reference="111",
currency="USD",
- refunded_value=Decimal("15"),
+ refunded_value=Decimal(15),
),
TransactionItem(
order_id=order.id,
name="Credit card",
psp_reference="111",
currency="USD",
- refund_pending_value=Decimal("19"),
+ refund_pending_value=Decimal(19),
available_actions=[],
),
TransactionItem(
@@ -314,7 +314,7 @@ def test_total_balance_with_granted_refund_and_transactions(
name="Credit card",
psp_reference="111",
currency="USD",
- charged_value=Decimal("11"),
+ charged_value=Decimal(11),
available_actions=[],
),
TransactionItem(
@@ -322,7 +322,7 @@ def test_total_balance_with_granted_refund_and_transactions(
name="Credit card",
psp_reference="111",
currency="USD",
- charge_pending_value=Decimal("12"),
+ charge_pending_value=Decimal(12),
available_actions=[],
),
]
diff --git a/saleor/graphql/order/tests/queries/test_order_with_filter.py b/saleor/graphql/order/tests/queries/test_order_with_filter.py
index 29eff81d23..a644e20d43 100644
--- a/saleor/graphql/order/tests/queries/test_order_with_filter.py
+++ b/saleor/graphql/order/tests/queries/test_order_with_filter.py
@@ -637,15 +637,15 @@ def test_orders_query_with_filter_search(
OrderDiscount(
order=orders[0],
name="Some discount name",
- value=Decimal("1"),
- amount_value=Decimal("1"),
+ value=Decimal(1),
+ amount_value=Decimal(1),
translated_name="translated",
),
OrderDiscount(
order=orders[2],
name="Some other discount name",
- value=Decimal("10"),
- amount_value=Decimal("10"),
+ value=Decimal(10),
+ amount_value=Decimal(10),
translated_name="PL_name",
),
]
@@ -716,8 +716,8 @@ def test_orders_query_with_filter_search_by_global_payment_id(
OrderDiscount.objects.create(
order=orders[0],
name="test_discount1",
- value=Decimal("1"),
- amount_value=Decimal("1"),
+ value=Decimal(1),
+ amount_value=Decimal(1),
translated_name="translated_discount1_name",
),
)
@@ -1022,32 +1022,32 @@ def test_order_query_with_filter_search_by_product_sku_multi_order_lines(
("transaction_data", "statuses", "expected_count"),
[
(
- {"authorized_value": Decimal("10")},
+ {"authorized_value": Decimal(10)},
[OrderAuthorizeStatusEnum.PARTIAL.name],
1,
),
(
- {"authorized_value": Decimal("0")},
+ {"authorized_value": Decimal(0)},
[OrderAuthorizeStatusEnum.NONE.name],
1,
),
(
- {"authorized_value": Decimal("100")},
+ {"authorized_value": Decimal(100)},
[OrderAuthorizeStatusEnum.FULL.name],
2,
),
(
- {"authorized_value": Decimal("10")},
+ {"authorized_value": Decimal(10)},
[OrderAuthorizeStatusEnum.FULL.name, OrderAuthorizeStatusEnum.PARTIAL.name],
2,
),
(
- {"authorized_value": Decimal("0")},
+ {"authorized_value": Decimal(0)},
[OrderAuthorizeStatusEnum.FULL.name, OrderAuthorizeStatusEnum.NONE.name],
2,
),
(
- {"authorized_value": Decimal("10"), "charged_value": Decimal("80")},
+ {"authorized_value": Decimal(10), "charged_value": Decimal(80)},
[OrderAuthorizeStatusEnum.PARTIAL.name],
1,
),
@@ -1077,7 +1077,7 @@ def test_orders_query_with_filter_authorize_status(
lines_count=0,
)
order.payment_transactions.create(
- currency=order.currency, authorized_value=Decimal("10")
+ currency=order.currency, authorized_value=Decimal(10)
)
update_order_charge_data(order)
update_order_authorize_data(order)
@@ -1103,12 +1103,12 @@ def test_orders_query_with_filter_authorize_status(
("transaction_data", "statuses", "expected_count"),
[
(
- {"charged_value": Decimal("10")},
+ {"charged_value": Decimal(10)},
[OrderChargeStatusEnum.PARTIAL.name],
1,
),
(
- {"charged_value": Decimal("00")},
+ {"charged_value": Decimal(0)},
[OrderChargeStatusEnum.PARTIAL.name],
0,
),
@@ -1118,12 +1118,12 @@ def test_orders_query_with_filter_authorize_status(
1,
),
(
- {"charged_value": Decimal("10")},
+ {"charged_value": Decimal(10)},
[OrderChargeStatusEnum.FULL.name, OrderChargeStatusEnum.PARTIAL.name],
1,
),
(
- {"charged_value": Decimal("0")},
+ {"charged_value": Decimal(0)},
[OrderChargeStatusEnum.FULL.name, OrderChargeStatusEnum.NONE.name],
1,
),
@@ -1158,7 +1158,7 @@ def test_orders_query_with_filter_charge_status(
lines_count=0,
)
order.payment_transactions.create(
- currency=order.currency, charged_value=Decimal("10")
+ currency=order.currency, charged_value=Decimal(10)
)
update_order_charge_data(order)
diff --git a/saleor/graphql/order/tests/queries/test_orders_search.py b/saleor/graphql/order/tests/queries/test_orders_search.py
index fccf9bcec7..1f037d85d4 100644
--- a/saleor/graphql/order/tests/queries/test_orders_search.py
+++ b/saleor/graphql/order/tests/queries/test_orders_search.py
@@ -87,15 +87,15 @@ def test_orders_query_with_search(
OrderDiscount(
order=orders[0],
name="Some discount name",
- value=Decimal("1"),
- amount_value=Decimal("1"),
+ value=Decimal(1),
+ amount_value=Decimal(1),
translated_name="translated",
),
OrderDiscount(
order=orders[2],
name="Some other discount name",
- value=Decimal("10"),
- amount_value=Decimal("10"),
+ value=Decimal(10),
+ amount_value=Decimal(10),
translated_name="PL_name",
),
]
diff --git a/saleor/graphql/order/tests/queries/test_pagination.py b/saleor/graphql/order/tests/queries/test_pagination.py
index 32b4669ce4..377ab9efe7 100644
--- a/saleor/graphql/order/tests/queries/test_pagination.py
+++ b/saleor/graphql/order/tests/queries/test_pagination.py
@@ -535,15 +535,15 @@ def test_orders_query_pagination_with_filter_search(
OrderDiscount(
order=orders[0],
name="Some discount name",
- value=Decimal("1"),
- amount_value=Decimal("1"),
+ value=Decimal(1),
+ amount_value=Decimal(1),
translated_name="translated",
),
OrderDiscount(
order=orders[2],
name="Some other discount name",
- value=Decimal("10"),
- amount_value=Decimal("10"),
+ value=Decimal(10),
+ amount_value=Decimal(10),
translated_name="PL_name",
),
]
@@ -626,15 +626,15 @@ def test_draft_orders_query_pagination_with_filter_search(
OrderDiscount(
order=orders[0],
name="Some discount name",
- value=Decimal("1"),
- amount_value=Decimal("1"),
+ value=Decimal(1),
+ amount_value=Decimal(1),
translated_name="translated",
),
OrderDiscount(
order=orders[2],
name="Some other discount name",
- value=Decimal("10"),
- amount_value=Decimal("10"),
+ value=Decimal(10),
+ amount_value=Decimal(10),
translated_name="PL_name",
),
]
diff --git a/saleor/graphql/payment/mutations/payment/checkout_payment_create.py b/saleor/graphql/payment/mutations/payment/checkout_payment_create.py
index 7a7e6ab65e..5ca530b364 100644
--- a/saleor/graphql/payment/mutations/payment/checkout_payment_create.py
+++ b/saleor/graphql/payment/mutations/payment/checkout_payment_create.py
@@ -320,7 +320,7 @@ class CheckoutPaymentCreate(BaseMutation, I18nMixin):
payment_token=input.get("token", ""),
total=amount,
currency=checkout.currency,
- email=checkout.get_customer_email(),
+ email=checkout.get_customer_email(), # type: ignore[arg-type]
extra_data=extra_data,
# FIXME this is not a customer IP address.
# It is a client storefront ip
diff --git a/saleor/graphql/payment/mutations/stored_payment_methods/payment_gateway_initialize_tokenization.py b/saleor/graphql/payment/mutations/stored_payment_methods/payment_gateway_initialize_tokenization.py
index 9d8c436f18..6b7149131b 100644
--- a/saleor/graphql/payment/mutations/stored_payment_methods/payment_gateway_initialize_tokenization.py
+++ b/saleor/graphql/payment/mutations/stored_payment_methods/payment_gateway_initialize_tokenization.py
@@ -100,7 +100,7 @@ class PaymentGatewayInitializeTokenization(BaseMutation):
return cls(result=response.result, data=response.data, errors=errors)
@classmethod
- def perform_mutation(cls, root, info, id, channel, data=None):
+ def perform_mutation(cls, root, info, id, channel, data=None): # type: ignore[override]
try:
return cls._perform_mutation(root, info, id, channel, data)
except ValidationError as error:
diff --git a/saleor/graphql/payment/mutations/stored_payment_methods/payment_method_intialize_tokenization.py b/saleor/graphql/payment/mutations/stored_payment_methods/payment_method_intialize_tokenization.py
index 4e789e6543..38c2be78d7 100644
--- a/saleor/graphql/payment/mutations/stored_payment_methods/payment_method_intialize_tokenization.py
+++ b/saleor/graphql/payment/mutations/stored_payment_methods/payment_method_intialize_tokenization.py
@@ -89,7 +89,7 @@ class PaymentMethodInitializeTokenization(BaseMutation):
)
@classmethod
- def perform_mutation(
+ def perform_mutation( # type: ignore[override]
cls, root, info, id, channel, payment_flow_to_support, data=None
):
try:
diff --git a/saleor/graphql/payment/mutations/stored_payment_methods/payment_method_process_tokenization.py b/saleor/graphql/payment/mutations/stored_payment_methods/payment_method_process_tokenization.py
index 2e0fa4d7c9..7c0636dbd1 100644
--- a/saleor/graphql/payment/mutations/stored_payment_methods/payment_method_process_tokenization.py
+++ b/saleor/graphql/payment/mutations/stored_payment_methods/payment_method_process_tokenization.py
@@ -72,7 +72,7 @@ class PaymentMethodProcessTokenization(BaseMutation):
)
@classmethod
- def perform_mutation(cls, root, info, id, channel, data=None):
+ def perform_mutation(cls, root, info, id, channel, data=None): # type: ignore[override]
try:
return cls._perform_mutation(root, info, id, channel, data)
except ValidationError as error:
diff --git a/saleor/graphql/payment/mutations/stored_payment_methods/payment_method_request_delete.py b/saleor/graphql/payment/mutations/stored_payment_methods/payment_method_request_delete.py
index b2b5b8f70a..db7d0a381f 100644
--- a/saleor/graphql/payment/mutations/stored_payment_methods/payment_method_request_delete.py
+++ b/saleor/graphql/payment/mutations/stored_payment_methods/payment_method_request_delete.py
@@ -47,7 +47,7 @@ class StoredPaymentMethodRequestDelete(BaseMutation):
]
@classmethod
- def perform_mutation(cls, root, info, id, channel):
+ def perform_mutation(cls, root, info, id, channel): # type: ignore[override]
try:
return cls._perform_mutation(root, info, id, channel)
except ValidationError as error:
diff --git a/saleor/graphql/payment/mutations/transaction/payment_gateway_initialize.py b/saleor/graphql/payment/mutations/transaction/payment_gateway_initialize.py
index 640e7c6a07..27c280f033 100644
--- a/saleor/graphql/payment/mutations/transaction/payment_gateway_initialize.py
+++ b/saleor/graphql/payment/mutations/transaction/payment_gateway_initialize.py
@@ -124,7 +124,7 @@ class PaymentGatewayInitialize(TransactionSessionBase):
return response
@classmethod
- def perform_mutation(cls, root, info, *, id, amount=None, payment_gateways=None):
+ def perform_mutation(cls, root, info, *, id, amount=None, payment_gateways=None): # type: ignore[override]
manager = get_plugin_manager_promise(info.context).get()
source_object = cls.clean_source_object(
info,
diff --git a/saleor/graphql/payment/mutations/transaction/transaction_initialize.py b/saleor/graphql/payment/mutations/transaction/transaction_initialize.py
index 55e0322c67..66e7ed92bc 100644
--- a/saleor/graphql/payment/mutations/transaction/transaction_initialize.py
+++ b/saleor/graphql/payment/mutations/transaction/transaction_initialize.py
@@ -137,7 +137,7 @@ class TransactionInitialize(TransactionSessionBase):
return idempotency_key
@classmethod
- def perform_mutation(
+ def perform_mutation( # type: ignore[override]
cls,
root,
info,
diff --git a/saleor/graphql/payment/tests/mutations/test_transaction_create.py b/saleor/graphql/payment/tests/mutations/test_transaction_create.py
index d40939d135..33c2107b0e 100644
--- a/saleor/graphql/payment/tests/mutations/test_transaction_create.py
+++ b/saleor/graphql/payment/tests/mutations/test_transaction_create.py
@@ -123,7 +123,7 @@ def test_transaction_create_updates_order_authorize_amounts(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "test-2", "value": "321"}
external_url = f"http://{TEST_SERVER_DOMAIN}/external-url"
@@ -167,7 +167,7 @@ def test_transaction_create_for_order_by_app(
TransactionActionEnum.CHARGE.name,
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "test-2", "value": "321"}
external_url = f"http://{TEST_SERVER_DOMAIN}/external-url"
@@ -228,7 +228,7 @@ def test_transaction_create_for_order_by_app_metadata_null_value(
TransactionActionEnum.CHARGE.name,
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
external_url = f"http://{TEST_SERVER_DOMAIN}/external-url"
variables = {
@@ -279,14 +279,14 @@ def test_transaction_create_for_order_updates_order_total_authorized_by_app(
order_with_lines, permission_manage_payments, app_api_client
):
# given
- previously_authorized_value = Decimal("90")
+ previously_authorized_value = Decimal(90)
old_transaction = order_with_lines.payment_transactions.create(
authorized_value=previously_authorized_value, currency=order_with_lines.currency
)
update_order_authorize_data(order_with_lines)
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -325,13 +325,13 @@ def test_transaction_create_for_order_updates_order_total_charged_by_app(
order_with_lines, permission_manage_payments, app_api_client
):
# given
- previously_charged_value = Decimal("90")
+ previously_charged_value = Decimal(90)
old_transaction = order_with_lines.payment_transactions.create(
charged_value=previously_charged_value, currency=order_with_lines.currency
)
update_order_charge_data(order_with_lines)
- charged_value = Decimal("10")
+ charged_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -381,13 +381,13 @@ def test_transaction_create_for_draft_order(
channel.automatically_confirm_all_new_orders = automatically_confirm_all_new_orders
channel.save(update_fields=["automatically_confirm_all_new_orders"])
- previously_charged_value = Decimal("90")
+ previously_charged_value = Decimal(90)
old_transaction = order_with_lines.payment_transactions.create(
charged_value=previously_charged_value, currency=order_with_lines.currency
)
update_order_charge_data(order_with_lines)
- charged_value = Decimal("10")
+ charged_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -433,7 +433,7 @@ def test_transaction_create_for_checkout_by_app(
TransactionActionEnum.CHARGE.name,
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "test-2", "value": "321"}
external_url = f"http://{TEST_SERVER_DOMAIN}/external-url"
@@ -498,7 +498,7 @@ def test_transaction_create_for_checkout_by_app_metadata_null_value(
TransactionActionEnum.CHARGE.name,
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
external_url = f"http://{TEST_SERVER_DOMAIN}/external-url"
variables = {
@@ -568,7 +568,7 @@ def test_transaction_create_calculate_amount_by_app(
# given
name = "Credit Card"
psp_reference = "PSP reference - 123"
- expected_value = Decimal("10")
+ expected_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -604,10 +604,10 @@ def test_transaction_create_multiple_amounts_provided_by_app(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
- charged_value = Decimal("11")
- refunded_value = Decimal("12")
- canceled_value = Decimal("13")
+ authorized_value = Decimal(10)
+ charged_value = Decimal(11)
+ refunded_value = Decimal(12)
+ canceled_value = Decimal(13)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -666,7 +666,7 @@ def test_transaction_create_create_event_for_order_by_app(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
transaction_reference = "transaction reference"
transaction_name = "Processing transaction"
@@ -710,7 +710,7 @@ def test_transaction_create_missing_permission_by_app(order_with_lines, app_api_
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "test-2", "value": "321"}
@@ -755,7 +755,7 @@ def test_transaction_create_incorrect_currency_by_app(
# given
name = "Credit Card"
psp_reference = "PSP reference - 123"
- expected_value = Decimal("10")
+ expected_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -793,7 +793,7 @@ def test_transaction_create_empty_metadata_key_by_app(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
metadata = {"key": "", "value": "123"}
private_metadata = {"key": "test-2", "value": "321"}
variables = {
@@ -834,7 +834,7 @@ def test_transaction_create_empty_private_metadata_key_by_app(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "", "value": "321"}
variables = {
@@ -873,7 +873,7 @@ def test_creates_transaction_event_for_order_by_app(
name = "Credit Card"
psp_reference = "PSP reference - 123"
available_actions = []
- authorized_value = Decimal("0")
+ authorized_value = Decimal(0)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "test-2", "value": "321"}
@@ -935,7 +935,7 @@ def test_creates_transaction_event_for_checkout_by_app(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("0")
+ authorized_value = Decimal(0)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "test-2", "value": "321"}
@@ -997,7 +997,7 @@ def test_transaction_create_for_order_by_staff(
TransactionActionEnum.CHARGE.name,
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "test-2", "value": "321"}
@@ -1049,14 +1049,14 @@ def test_transaction_create_for_order_updates_order_total_authorized_by_staff(
order_with_lines, permission_manage_payments, staff_api_client
):
# given
- previously_authorized_value = Decimal("90")
+ previously_authorized_value = Decimal(90)
old_transaction = order_with_lines.payment_transactions.create(
authorized_value=previously_authorized_value, currency=order_with_lines.currency
)
update_order_authorize_data(order_with_lines)
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -1095,13 +1095,13 @@ def test_transaction_create_for_order_updates_order_total_charged_by_staff(
order_with_lines, permission_manage_payments, staff_api_client
):
# given
- previously_charged_value = Decimal("90")
+ previously_charged_value = Decimal(90)
old_transaction = order_with_lines.payment_transactions.create(
charged_value=previously_charged_value, currency=order_with_lines.currency
)
update_order_charge_data(order_with_lines)
- charged_value = Decimal("10")
+ charged_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -1146,7 +1146,7 @@ def test_transaction_create_for_checkout_by_staff(
TransactionActionEnum.CHARGE.name,
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "test-2", "value": "321"}
@@ -1449,7 +1449,7 @@ def test_transaction_create_calculate_amount_by_staff(
# given
name = "Credit Card"
psp_reference = "PSP reference - 123"
- expected_value = Decimal("10")
+ expected_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -1485,10 +1485,10 @@ def test_transaction_create_multiple_amounts_provided_by_staff(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
- charged_value = Decimal("11")
- refunded_value = Decimal("12")
- canceled_value = Decimal("13")
+ authorized_value = Decimal(10)
+ charged_value = Decimal(11)
+ refunded_value = Decimal(12)
+ canceled_value = Decimal(13)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -1547,7 +1547,7 @@ def test_transaction_create_create_event_for_order_by_staff(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
transaction_reference = "transaction reference"
transaction_name = "Processing transaction"
@@ -1592,7 +1592,7 @@ def test_transaction_create_missing_permission_by_staff(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "test-2", "value": "321"}
@@ -1637,7 +1637,7 @@ def test_transaction_create_incorrect_currency_by_staff(
# given
name = "Credit Card"
psp_reference = "PSP reference - 123"
- expected_value = Decimal("10")
+ expected_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -1675,7 +1675,7 @@ def test_transaction_create_empty_metadata_key_by_staff(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
metadata = {"key": "", "value": "123"}
private_metadata = {"key": "test-2", "value": "321"}
variables = {
@@ -1716,7 +1716,7 @@ def test_transaction_create_empty_private_metadata_key_by_staff(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "", "value": "321"}
variables = {
@@ -1755,7 +1755,7 @@ def test_creates_transaction_event_for_order_by_staff(
name = "Credit Card"
psp_reference = "PSP reference - 123"
available_actions = []
- authorized_value = Decimal("0")
+ authorized_value = Decimal(0)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "test-2", "value": "321"}
@@ -1817,7 +1817,7 @@ def test_creates_transaction_event_for_checkout_by_staff(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "test-2", "value": "321"}
@@ -1887,7 +1887,7 @@ def test_creates_transaction_automatically_confirm(
name = "Credit Card"
reference = "PSP reference - 123"
available_actions = []
- authorized_value = Decimal("0")
+ authorized_value = Decimal(0)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "test-2", "value": "321"}
@@ -1933,7 +1933,7 @@ def test_transaction_create_external_url_incorrect_url_format_by_app(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
metadata = {"key": "test-1", "value": "123"}
private_metadata = {"key": "test", "value": "321"}
external_url = "incorrect"
@@ -1973,10 +1973,10 @@ def test_transaction_create_creates_calculation_events(
# given
psp_reference = "PSP reference - 123"
available_actions = []
- authorized_value = Decimal("10")
- charged_value = Decimal("8")
- refunded_value = Decimal("5")
- canceled_value = Decimal("2")
+ authorized_value = Decimal(10)
+ charged_value = Decimal(8)
+ refunded_value = Decimal(5)
+ canceled_value = Decimal(2)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -2111,7 +2111,7 @@ def test_transaction_create_for_order_triggers_webhook_when_partially_paid(
staff_api_client,
):
# given
- charged_value = Decimal("10")
+ charged_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -2151,7 +2151,7 @@ def test_transaction_create_for_order_triggers_webhook_when_authorized(
staff_api_client,
):
# given
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -2233,7 +2233,7 @@ def test_transaction_create_for_order_triggers_webhook_when_partially_refunded(
staff_api_client,
):
# given
- refunded_value = Decimal("10")
+ refunded_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -2269,7 +2269,7 @@ def test_transaction_create_for_checkout_updates_last_transaction_modified_at(
# given
assert checkout_with_items.last_transaction_modified_at is None
psp_reference = "PSP reference - 123"
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Checkout", checkout_with_items.pk),
@@ -2298,7 +2298,7 @@ def test_transaction_create_null_available_actions(
checkout_with_items, permission_manage_payments, app_api_client
):
# given
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Checkout", checkout_with_items.pk),
"transaction": {
@@ -2396,7 +2396,7 @@ def test_transaction_create_create_event_message_limit_exceeded(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
transaction_reference = "transaction reference"
transaction_msg = "m" * 513
@@ -2447,7 +2447,7 @@ def test_transaction_create_create_event_message_is_empty(
available_actions = [
TransactionActionEnum.CHARGE.name,
]
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
transaction_reference = "transaction reference"
transaction_msg = None
@@ -2519,7 +2519,7 @@ def test_transaction_create_with_card_payment_method_details(
name = "Credit Card"
psp_reference = "PSP reference - 123"
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
card_name = "Payment Method Name"
@@ -2584,7 +2584,7 @@ def test_transaction_create_with_other_payment_method_details(
name = "Credit Card"
psp_reference = "PSP reference - 123"
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
other_name = "Payment Method Name"
@@ -2640,7 +2640,7 @@ def test_transaction_create_with_both_payment_method_details_inputs(
name = "Credit Card"
psp_reference = "PSP reference - 123"
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -2709,7 +2709,7 @@ def test_transaction_create_with_invalid_card_payment_method_details(
name = "Credit Card"
psp_reference = "PSP reference - 123"
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("Order", order_with_lines.pk),
@@ -2757,7 +2757,7 @@ def test_transaction_create_with_invalid_other_payment_method_details(
name = "Credit Card"
psp_reference = "PSP reference - 123"
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
other_name = "Payment Method Name"
diff --git a/saleor/graphql/payment/tests/mutations/test_transaction_event_report.py b/saleor/graphql/payment/tests/mutations/test_transaction_event_report.py
index cecc0a4fd6..a2f3bc9be8 100644
--- a/saleor/graphql/payment/tests/mutations/test_transaction_event_report.py
+++ b/saleor/graphql/payment/tests/mutations/test_transaction_event_report.py
@@ -114,7 +114,7 @@ def test_transaction_event_report_by_app(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
event_time = timezone.now()
external_url = f"http://{TEST_SERVER_DOMAIN}/external-url"
@@ -193,7 +193,7 @@ def test_transaction_event_report_by_app_via_token(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
event_time = timezone.now()
external_url = f"http://{TEST_SERVER_DOMAIN}/external-url"
@@ -420,7 +420,7 @@ def test_transaction_event_report_amount_with_lot_of_decimal_places(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
event_time = timezone.now()
external_url = f"http://{TEST_SERVER_DOMAIN}/external-url"
@@ -1019,7 +1019,7 @@ def test_transaction_event_updates_order_total_charged(
):
# given
order = order_with_lines
- current_charged_value = Decimal("20")
+ current_charged_value = Decimal(20)
psp_reference = "111-abc"
amount = Decimal("11.00")
transaction = transaction_item_generator(app=app_api_client.app, order_id=order.pk)
@@ -1274,7 +1274,7 @@ def test_transaction_event_updates_checkout_payment_statuses(
checkout_info = fetch_checkout_info(checkout, lines, plugins_manager)
fetch_checkout_data(checkout_info, plugins_manager, lines)
- current_charged_value = Decimal("20")
+ current_charged_value = Decimal(20)
psp_reference = "111-abc"
amount = Decimal("11.00")
transaction = transaction_item_generator(
@@ -1901,7 +1901,7 @@ def test_transaction_event_report_with_info_event(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
event_time = timezone.now()
external_url = f"http://{TEST_SERVER_DOMAIN}/external-url"
@@ -1974,7 +1974,7 @@ def test_transaction_event_report_accepts_old_id_for_old_transaction(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10"), use_old_id=True
+ app=app_api_client.app, authorized_value=Decimal(10), use_old_id=True
)
event_time = timezone.now()
external_url = f"http://{TEST_SERVER_DOMAIN}/external-url"
@@ -2538,7 +2538,7 @@ def test_transaction_event_report_by_app_assign_app_owner(
permission_manage_payments,
):
# given
- transaction = transaction_item_generator(authorized_value=Decimal("10"))
+ transaction = transaction_item_generator(authorized_value=Decimal(10))
event_time = timezone.now()
external_url = f"http://{TEST_SERVER_DOMAIN}/external-url"
message = "Sucesfull charge"
@@ -2618,7 +2618,7 @@ def test_transaction_event_report_assign_transaction_psp_reference_if_missing(
):
# given
transaction = transaction_item_generator(
- authorized_value=Decimal("10"), psp_reference=transaction_psp_reference
+ authorized_value=Decimal(10), psp_reference=transaction_psp_reference
)
amount = Decimal("11.00")
transaction_id = graphene.Node.to_global_id("TransactionItem", transaction.token)
@@ -2684,7 +2684,7 @@ def test_transaction_event_report_updates_granted_refund_status_when_needed(
# given
amount = Decimal("11.00")
transaction = transaction_item_generator(
- app=app_api_client.app, charged_value=Decimal("10"), order_id=order.pk
+ app=app_api_client.app, charged_value=Decimal(10), order_id=order.pk
)
granted_refund = order.granted_refunds.create(
amount_value=amount, currency=order.currency, transaction_item=transaction
@@ -2751,7 +2751,7 @@ def test_transaction_event_report_missing_amount(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
psp_reference = "111-abc"
expected_amount = 10
@@ -2814,7 +2814,7 @@ def test_transaction_event_report_missing_amount(
assert event.psp_reference == psp_reference
assert event.type == event_type
expected_amount = (
- expected_amount if event_type != TransactionEventType.INFO else Decimal("0")
+ expected_amount if event_type != TransactionEventType.INFO else Decimal(0)
)
assert event.amount_value == expected_amount
assert event.currency == transaction.currency
@@ -2840,7 +2840,7 @@ def test_transaction_event_report_missing_amount_not_deduced_error_raised(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
psp_reference = "111-abc"
transaction_id = graphene.Node.to_global_id("TransactionItem", transaction.token)
@@ -2899,7 +2899,7 @@ def test_transaction_event_report_missing_amount_error_raised(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
psp_reference = "111-abc"
amount = 10
@@ -2969,7 +2969,7 @@ def test_transaction_event_report_update_transaction_metadata(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
psp_reference = "111-abc"
amount = Decimal("11.00")
@@ -3042,7 +3042,7 @@ def test_transaction_event_report_metadata_not_provided(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
psp_reference = "111-abc"
amount = Decimal("11.00")
@@ -3116,7 +3116,7 @@ def test_transaction_event_report_update_transaction_private_metadata(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
psp_reference = "111-abc"
amount = Decimal("11.00")
@@ -3187,7 +3187,7 @@ def test_transaction_event_report_message_limit_exceeded(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
event_time = timezone.now()
external_url = f"http://{TEST_SERVER_DOMAIN}/external-url"
@@ -3267,7 +3267,7 @@ def test_transaction_event_report_empty_message(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
event_time = timezone.now()
external_url = f"http://{TEST_SERVER_DOMAIN}/external-url"
@@ -3592,7 +3592,7 @@ def test_transaction_event_report_with_card_payment_method_details(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
transaction.payment_method_type = PaymentMethodType.CARD
transaction.payment_method_name = "Payment Method Name"
@@ -3665,7 +3665,7 @@ def test_transaction_event_report_with_other_payment_method_details(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
transaction.payment_method_type = PaymentMethodType.CARD
transaction.payment_method_name = "Payment Method Name"
@@ -3730,7 +3730,7 @@ def test_transaction_event_report_with_both_payment_method_details_inputs(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
psp_reference = "111-abc"
@@ -3799,7 +3799,7 @@ def test_transaction_event_report_with_invalid_card_payment_method_details(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
psp_reference = "111-abc"
@@ -3847,7 +3847,7 @@ def test_transaction_event_report_with_invalid_other_payment_method_details(
):
# given
transaction = transaction_item_generator(
- app=app_api_client.app, authorized_value=Decimal("10")
+ app=app_api_client.app, authorized_value=Decimal(10)
)
psp_reference = "111-abc"
diff --git a/saleor/graphql/payment/tests/mutations/test_transaction_initialize.py b/saleor/graphql/payment/tests/mutations/test_transaction_initialize.py
index ee536d3392..8626bc76d1 100644
--- a/saleor/graphql/payment/tests/mutations/test_transaction_initialize.py
+++ b/saleor/graphql/payment/tests/mutations/test_transaction_initialize.py
@@ -1170,8 +1170,8 @@ def test_order_with_transaction_when_amount_is_not_provided(
):
# given
order = order_with_lines
- expected_charged_amount = Decimal("10")
- expected_authorized_amount = Decimal("3")
+ expected_charged_amount = Decimal(10)
+ expected_authorized_amount = Decimal(3)
transaction_item_generator(
order_id=order.pk,
charged_value=expected_charged_amount,
@@ -1238,8 +1238,8 @@ def test_checkout_with_transaction_when_amount_is_not_provided(
checkout_info, _ = fetch_checkout_data(checkout_info, plugins_manager, lines)
checkout = checkout_info.checkout
- expected_charged_amount = Decimal("10")
- expected_authorized_amount = Decimal("3")
+ expected_charged_amount = Decimal(10)
+ expected_authorized_amount = Decimal(3)
transaction_item_generator(
checkout_id=checkout.pk,
charged_value=expected_charged_amount,
@@ -1641,8 +1641,8 @@ def test_app_with_action_field(
):
# given
checkout = checkout_with_prices
- expected_charged_amount = Decimal("10")
- expected_authorized_amount = Decimal("3")
+ expected_charged_amount = Decimal(10)
+ expected_authorized_amount = Decimal(3)
transaction_item_generator(
checkout_id=checkout.pk,
charged_value=expected_charged_amount,
@@ -1685,8 +1685,8 @@ def test_customer_with_action_field(
):
# given
checkout = checkout_with_prices
- expected_charged_amount = Decimal("10")
- expected_authorized_amount = Decimal("3")
+ expected_charged_amount = Decimal(10)
+ expected_authorized_amount = Decimal(3)
transaction_item_generator(
checkout_id=checkout.pk,
charged_value=expected_charged_amount,
@@ -1719,8 +1719,8 @@ def test_incorrect_source_object_id(
):
# given
checkout = checkout_with_prices
- expected_charged_amount = Decimal("10")
- expected_authorized_amount = Decimal("3")
+ expected_charged_amount = Decimal(10)
+ expected_authorized_amount = Decimal(3)
transaction_item_generator(
checkout_id=checkout.pk,
charged_value=expected_charged_amount,
diff --git a/saleor/graphql/payment/tests/mutations/test_transaction_process.py b/saleor/graphql/payment/tests/mutations/test_transaction_process.py
index f26ade42de..21b84ee135 100644
--- a/saleor/graphql/payment/tests/mutations/test_transaction_process.py
+++ b/saleor/graphql/payment/tests/mutations/test_transaction_process.py
@@ -941,7 +941,7 @@ def test_transaction_already_processed(
webhook_app.save()
transaction_item = transaction_item_generator(
- order_id=order.pk, app=webhook_app, charged_value=Decimal("10")
+ order_id=order.pk, app=webhook_app, charged_value=Decimal(10)
)
transaction_event = transaction_item.events.get()
@@ -1017,7 +1017,7 @@ def test_transaction_doesnt_have_source_object(
)
TransactionEvent.objects.create(
transaction=transaction_item,
- amount_value=Decimal("10"),
+ amount_value=Decimal(10),
currency=transaction_item.currency,
type=TransactionEventType.CHARGE_REQUEST,
)
@@ -1049,7 +1049,7 @@ def test_transaction_doesnt_have_app_identifier(
transaction_item = transaction_item_generator(order_id=order_with_lines.pk)
TransactionEvent.objects.create(
transaction=transaction_item,
- amount_value=Decimal("10"),
+ amount_value=Decimal(10),
currency=transaction_item.currency,
type=TransactionEventType.CHARGE_REQUEST,
)
@@ -1090,7 +1090,7 @@ def test_app_attached_to_transaction_doesnt_exist(
)
TransactionEvent.objects.create(
transaction=transaction_item,
- amount_value=Decimal("10"),
+ amount_value=Decimal(10),
currency=transaction_item.currency,
type=TransactionEventType.CHARGE_REQUEST,
)
@@ -2232,7 +2232,7 @@ def test_for_checkout_with_payments_transaction_process_failure(
response_event_type=TransactionEventType.CHARGE_FAILURE,
app_identifier=webhook_app.identifier,
mocked_process=mocked_process,
- charged_value=Decimal("0"),
+ charged_value=Decimal(0),
data=None,
returned_data=None,
)
diff --git a/saleor/graphql/payment/tests/mutations/test_transaction_request_action.py b/saleor/graphql/payment/tests/mutations/test_transaction_request_action.py
index e14ee3c309..97af70daf0 100644
--- a/saleor/graphql/payment/tests/mutations/test_transaction_request_action.py
+++ b/saleor/graphql/payment/tests/mutations/test_transaction_request_action.py
@@ -104,7 +104,7 @@ def test_transaction_request_action_missing_permission(
available_actions=["charge", "cancel"],
currency="USD",
order_id=order_with_lines.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -133,7 +133,7 @@ def test_transaction_request_action_missing_event(
):
# given
permission_group_manage_orders.user_set.add(staff_api_client.user)
- authorization_value = Decimal("10")
+ authorization_value = Decimal(10)
transaction = TransactionItem.objects.create(
name="Credit card",
psp_reference="PSP ref",
@@ -190,7 +190,7 @@ def test_transaction_request_action_amount_with_lot_of_decimal_places(
available_actions=[],
currency="USD",
order_id=order_with_lines.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
)
charge_amount = Decimal("9.12345678")
@@ -259,7 +259,7 @@ def transaction_request_webhook(permission_manage_payments):
[
(Decimal("8.00"), Decimal("8.00")),
(None, Decimal("10.00")),
- (Decimal("100"), Decimal("10.00")),
+ (Decimal(100), Decimal("10.00")),
],
)
@patch("saleor.plugins.manager.PluginsManager.is_event_active_for_any_plugin")
@@ -287,7 +287,7 @@ def test_transaction_request_charge_for_order(
available_actions=["charge", "cancel"],
currency="USD",
order_id=order_with_lines.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app_identifier=transaction_request_webhook.app.identifier,
app=transaction_request_webhook.app,
)
@@ -342,7 +342,7 @@ def test_transaction_request_charge_for_order(
[
(Decimal("8.00"), Decimal("8.00")),
(None, Decimal("10.00")),
- (Decimal("100"), Decimal("10.00")),
+ (Decimal(100), Decimal("10.00")),
],
)
@patch("saleor.plugins.manager.PluginsManager.is_event_active_for_any_plugin")
@@ -370,7 +370,7 @@ def test_transaction_request_charge_for_order_via_token(
available_actions=["charge", "cancel"],
currency="USD",
order_id=order_with_lines.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app_identifier=transaction_request_webhook.app.identifier,
app=transaction_request_webhook.app,
)
@@ -425,7 +425,7 @@ def test_transaction_request_charge_for_order_via_token(
[
(Decimal("8.00"), Decimal("8.00")),
(None, Decimal("10.00")),
- (Decimal("100"), Decimal("10.00")),
+ (Decimal(100), Decimal("10.00")),
],
)
@patch("saleor.plugins.manager.PluginsManager.is_event_active_for_any_plugin")
@@ -453,7 +453,7 @@ def test_transaction_request_refund_for_order(
available_actions=["refund"],
currency="USD",
order_id=order_with_lines.pk,
- charged_value=Decimal("10"),
+ charged_value=Decimal(10),
app_identifier=transaction_request_webhook.app.identifier,
app=transaction_request_webhook.app,
)
@@ -524,7 +524,7 @@ def test_transaction_request_cancelation_for_order(
available_actions=["charge", "cancel"],
currency="USD",
order_id=order_with_lines.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app_identifier=transaction_request_webhook.app.identifier,
app=transaction_request_webhook.app,
)
@@ -587,7 +587,7 @@ def test_transaction_request_cancelation_for_checkout(
transaction_request_webhook.events.create(
event_type=WebhookEventSyncType.TRANSACTION_CANCELATION_REQUESTED
)
- expected_amount = Decimal("10")
+ expected_amount = Decimal(10)
transaction = TransactionItem.objects.create(
name="Credit card",
psp_reference="PSP ref",
@@ -642,7 +642,7 @@ def test_transaction_request_cancelation_for_checkout(
[
(Decimal("8.00"), Decimal("8.00")),
(None, Decimal("10.00")),
- (Decimal("100"), Decimal("10.00")),
+ (Decimal(100), Decimal("10.00")),
],
)
@patch("saleor.plugins.manager.PluginsManager.is_event_active_for_any_plugin")
@@ -670,7 +670,7 @@ def test_transaction_request_charge_for_checkout(
available_actions=["charge", "cancel"],
currency="USD",
checkout_id=checkout.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app_identifier=transaction_request_webhook.app.identifier,
app=transaction_request_webhook.app,
)
@@ -719,7 +719,7 @@ def test_transaction_request_charge_for_checkout(
[
(Decimal("8.00"), Decimal("8.00")),
(None, Decimal("10.00")),
- (Decimal("100"), Decimal("10.00")),
+ (Decimal(100), Decimal("10.00")),
],
)
@patch("saleor.plugins.manager.PluginsManager.is_event_active_for_any_plugin")
@@ -747,7 +747,7 @@ def test_transaction_request_refund_for_checkout(
available_actions=["refund"],
currency="USD",
checkout_id=checkout.pk,
- charged_value=Decimal("10"),
+ charged_value=Decimal(10),
app_identifier=transaction_request_webhook.app.identifier,
app=transaction_request_webhook.app,
)
@@ -816,7 +816,7 @@ def test_transaction_request_refund_when_app_reinstalled(
available_actions=["refund"],
currency="USD",
checkout_id=checkout.pk,
- charged_value=Decimal("10"),
+ charged_value=Decimal(10),
app_identifier=transaction_request_webhook.app.identifier,
app=None,
)
@@ -883,11 +883,11 @@ def test_transaction_request_uses_handle_payment_permission(
available_actions=["refund"],
currency="USD",
checkout_id=checkout.pk,
- charged_value=Decimal("10"),
+ charged_value=Decimal(10),
app_identifier=transaction_request_webhook.app.identifier,
app=transaction_request_webhook.app,
)
- refund_amount = Decimal("1")
+ refund_amount = Decimal(1)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
"action_type": TransactionActionEnum.REFUND.name,
@@ -937,7 +937,7 @@ def test_transaction_request_missing_permission(
available_actions=["charge", "cancel"],
currency="USD",
order_id=order_with_lines.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app_identifier=transaction_request_webhook.app.identifier,
app=transaction_request_webhook.app,
)
@@ -967,7 +967,7 @@ def test_transaction_request_missing_event(
app,
):
# given
- authorization_value = Decimal("10")
+ authorization_value = Decimal(10)
transaction = TransactionItem.objects.create(
name="Credit card",
psp_reference="PSP ref",
@@ -1039,7 +1039,7 @@ def test_transaction_request_refund_sets_app_to_request_event(
charged_value=Decimal(10),
app=transaction_request_webhook.app,
)
- refund_amount = Decimal("1")
+ refund_amount = Decimal(1)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
"action_type": TransactionActionEnum.REFUND.name,
@@ -1089,7 +1089,7 @@ def test_transaction_request_refund_sets_user_to_request_event(
charged_value=Decimal(10),
app=transaction_request_webhook.app,
)
- refund_amount = Decimal("1")
+ refund_amount = Decimal(1)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
"action_type": TransactionActionEnum.REFUND.name,
@@ -1138,7 +1138,7 @@ def test_transaction_request_charge_sets_app_to_request_event(
authorized_value=Decimal(10),
app=transaction_request_webhook.app,
)
- amount = Decimal("1")
+ amount = Decimal(1)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
"action_type": TransactionActionEnum.CHARGE.name,
@@ -1188,7 +1188,7 @@ def test_transaction_request_charge_sets_user_to_request_event(
authorized_value=Decimal(10),
app=transaction_request_webhook.app,
)
- amount = Decimal("1")
+ amount = Decimal(1)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
"action_type": TransactionActionEnum.CHARGE.name,
diff --git a/saleor/graphql/payment/tests/mutations/test_transaction_request_refund_for_granted_refund.py b/saleor/graphql/payment/tests/mutations/test_transaction_request_refund_for_granted_refund.py
index 3a763f0a03..b48c671f3d 100644
--- a/saleor/graphql/payment/tests/mutations/test_transaction_request_refund_for_granted_refund.py
+++ b/saleor/graphql/payment/tests/mutations/test_transaction_request_refund_for_granted_refund.py
@@ -578,7 +578,7 @@ def test_trigger_refund_request_with_assigned_transaction_item_and_not_enough_ch
app=app,
)
granted_refund = order_with_lines.granted_refunds.create(
- amount_value=available_charged_value + Decimal("1"),
+ amount_value=available_charged_value + Decimal(1),
transaction_item=transaction_item,
)
@@ -644,7 +644,7 @@ def test_trigger_refund_blocked_based_on_status_of_granted_refund(
app=app,
)
granted_refund = order_with_lines.granted_refunds.create(
- amount_value=available_charged_value - Decimal("1"),
+ amount_value=available_charged_value - Decimal(1),
transaction_item=transaction_item,
status=granted_refund_status,
)
diff --git a/saleor/graphql/payment/tests/mutations/test_transaction_update.py b/saleor/graphql/payment/tests/mutations/test_transaction_update.py
index 2154629511..214b3587a2 100644
--- a/saleor/graphql/payment/tests/mutations/test_transaction_update.py
+++ b/saleor/graphql/payment/tests/mutations/test_transaction_update.py
@@ -627,10 +627,10 @@ def test_transaction_update_available_actions_by_app(
@pytest.mark.parametrize(
("field_name", "response_field", "db_field_name", "value"),
[
- ("amountAuthorized", "authorizedAmount", "authorized_value", Decimal("12")),
- ("amountCharged", "chargedAmount", "charged_value", Decimal("13")),
- ("amountCanceled", "canceledAmount", "canceled_value", Decimal("14")),
- ("amountRefunded", "refundedAmount", "refunded_value", Decimal("15")),
+ ("amountAuthorized", "authorizedAmount", "authorized_value", Decimal(12)),
+ ("amountCharged", "chargedAmount", "charged_value", Decimal(13)),
+ ("amountCanceled", "canceledAmount", "canceled_value", Decimal(14)),
+ ("amountRefunded", "refundedAmount", "refunded_value", Decimal(15)),
],
)
def test_transaction_update_amounts_by_app(
@@ -645,10 +645,10 @@ def test_transaction_update_amounts_by_app(
app,
):
# given
- current_authorized_value = Decimal("1")
- current_charged_value = Decimal("2")
- current_refunded_value = Decimal("3")
- current_canceled_value = Decimal("4")
+ current_authorized_value = Decimal(1)
+ current_charged_value = Decimal(2)
+ current_refunded_value = Decimal(3)
+ current_canceled_value = Decimal(4)
transaction = transaction_item_generator(
order_id=order.pk,
@@ -711,16 +711,16 @@ def test_transaction_update_for_order_increases_order_total_authorized_by_app(
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
)
- previously_authorized_value = Decimal("90")
+ previously_authorized_value = Decimal(90)
transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
authorized_value=previously_authorized_value,
)
- authorized_value = transaction.authorized_value + Decimal("10")
+ authorized_value = transaction.authorized_value + Decimal(10)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -762,16 +762,16 @@ def test_transaction_update_for_order_reduces_order_total_authorized_by_app(
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
)
- previously_authorized_value = Decimal("90")
+ previously_authorized_value = Decimal(90)
transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
authorized_value=previously_authorized_value,
)
- authorized_value = transaction.authorized_value - Decimal("5")
+ authorized_value = transaction.authorized_value - Decimal(5)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -813,16 +813,16 @@ def test_transaction_update_for_order_reduces_transaction_authorized_to_zero_by_
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
)
- previously_authorized_value = Decimal("90")
+ previously_authorized_value = Decimal(90)
transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
authorized_value=previously_authorized_value,
)
- authorized_value = Decimal("0")
+ authorized_value = Decimal(0)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -861,16 +861,16 @@ def test_transaction_update_for_order_increases_order_total_charged_by_app(
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
- charged_value=Decimal("10"),
+ charged_value=Decimal(10),
)
- previously_charged_value = Decimal("90")
+ previously_charged_value = Decimal(90)
transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
charged_value=previously_charged_value,
)
- charged_value = transaction.charged_value + Decimal("10")
+ charged_value = transaction.charged_value + Decimal(10)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -911,16 +911,16 @@ def test_transaction_update_for_order_reduces_order_total_charged_by_app(
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
- charged_value=Decimal("30"),
+ charged_value=Decimal(30),
)
- previously_charged_value = Decimal("90")
+ previously_charged_value = Decimal(90)
transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
charged_value=previously_charged_value,
)
- charged_value = transaction.charged_value - Decimal("5")
+ charged_value = transaction.charged_value - Decimal(5)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -961,16 +961,16 @@ def test_transaction_update_for_order_reduces_transaction_charged_to_zero_by_app
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
- charged_value=Decimal("30"),
+ charged_value=Decimal(30),
)
- previously_charged_value = Decimal("90")
+ previously_charged_value = Decimal(90)
transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
charged_value=previously_charged_value,
)
- charged_value = Decimal("0")
+ charged_value = Decimal(0)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -1004,16 +1004,16 @@ def test_transaction_update_multiple_amounts_provided_by_app(
transaction = transaction_item_generator(
order_id=order.pk,
app=app,
- charged_value=Decimal("1"),
- authorized_value=Decimal("2"),
- refunded_value=Decimal("3"),
- canceled_value=Decimal("4"),
+ charged_value=Decimal(1),
+ authorized_value=Decimal(2),
+ refunded_value=Decimal(3),
+ canceled_value=Decimal(4),
)
- authorized_value = Decimal("10")
- charged_value = Decimal("11")
- refunded_value = Decimal("12")
- canceled_value = Decimal("13")
+ authorized_value = Decimal(10)
+ charged_value = Decimal(11)
+ refunded_value = Decimal(12)
+ canceled_value = Decimal(13)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -1099,7 +1099,7 @@ def test_transaction_update_incorrect_currency_by_app(
):
# given
transaction = transaction_item_created_by_app
- expected_value = Decimal("10")
+ expected_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -1534,10 +1534,10 @@ def test_transaction_update_available_actions_by_staff(
@pytest.mark.parametrize(
("field_name", "response_field", "db_field_name", "value"),
[
- ("amountAuthorized", "authorizedAmount", "authorized_value", Decimal("12")),
- ("amountCharged", "chargedAmount", "charged_value", Decimal("13")),
- ("amountCanceled", "canceledAmount", "canceled_value", Decimal("14")),
- ("amountRefunded", "refundedAmount", "refunded_value", Decimal("15")),
+ ("amountAuthorized", "authorizedAmount", "authorized_value", Decimal(12)),
+ ("amountCharged", "chargedAmount", "charged_value", Decimal(13)),
+ ("amountCanceled", "canceledAmount", "canceled_value", Decimal(14)),
+ ("amountRefunded", "refundedAmount", "refunded_value", Decimal(15)),
],
)
def test_transaction_update_amounts_by_staff(
@@ -1578,20 +1578,20 @@ def test_transaction_update_for_order_increases_order_total_authorized_by_staff(
staff_user,
):
# given
- previously_authorized_value = Decimal("90")
+ previously_authorized_value = Decimal(90)
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
user=staff_user,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
)
- previously_authorized_value = Decimal("90")
+ previously_authorized_value = Decimal(90)
transaction_item_generator(
order_id=order_with_lines.pk,
user=staff_user,
authorized_value=previously_authorized_value,
)
- authorized_value = transaction.authorized_value + Decimal("10")
+ authorized_value = transaction.authorized_value + Decimal(10)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -1633,16 +1633,16 @@ def test_transaction_update_for_order_reduces_order_total_authorized_by_staff(
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
user=staff_user,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
)
- previously_authorized_value = Decimal("90")
+ previously_authorized_value = Decimal(90)
transaction_item_generator(
order_id=order_with_lines.pk,
user=staff_user,
authorized_value=previously_authorized_value,
)
- authorized_value = transaction.authorized_value - Decimal("5")
+ authorized_value = transaction.authorized_value - Decimal(5)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -1685,16 +1685,16 @@ def test_transaction_update_for_order_reduces_transaction_authorized_to_zero_by_
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
user=staff_user,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
)
- previously_authorized_value = Decimal("90")
+ previously_authorized_value = Decimal(90)
transaction_item_generator(
order_id=order_with_lines.pk,
user=staff_user,
authorized_value=previously_authorized_value,
)
- authorized_value = Decimal("0")
+ authorized_value = Decimal(0)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -1733,15 +1733,15 @@ def test_transaction_update_for_order_increases_order_total_charged_by_staff(
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
user=staff_user,
- charged_value=Decimal("10"),
+ charged_value=Decimal(10),
)
- previously_charged_value = Decimal("90")
+ previously_charged_value = Decimal(90)
transaction_item_generator(
order_id=order_with_lines.pk,
user=staff_user,
charged_value=previously_charged_value,
)
- charged_value = transaction.charged_value + Decimal("10")
+ charged_value = transaction.charged_value + Decimal(10)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -1783,15 +1783,15 @@ def test_transaction_update_for_order_reduces_order_total_charged_by_staff(
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
user=staff_user,
- charged_value=Decimal("30"),
+ charged_value=Decimal(30),
)
- previously_charged_value = Decimal("90")
+ previously_charged_value = Decimal(90)
transaction_item_generator(
order_id=order_with_lines.pk,
user=staff_user,
charged_value=previously_charged_value,
)
- charged_value = transaction.charged_value - Decimal("5")
+ charged_value = transaction.charged_value - Decimal(5)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -1832,16 +1832,16 @@ def test_transaction_update_for_order_reduces_transaction_charged_to_zero_by_sta
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
user=staff_user,
- charged_value=Decimal("30"),
+ charged_value=Decimal(30),
)
- previously_charged_value = Decimal("90")
+ previously_charged_value = Decimal(90)
transaction_item_generator(
order_id=order_with_lines.pk,
user=staff_user,
charged_value=previously_charged_value,
)
- charged_value = Decimal("0")
+ charged_value = Decimal(0)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -1873,10 +1873,10 @@ def test_transaction_update_multiple_amounts_provided_by_staff(
):
# given
transaction = transaction_item_created_by_user
- authorized_value = Decimal("10")
- charged_value = Decimal("11")
- refunded_value = Decimal("12")
- canceled_value = Decimal("13")
+ authorized_value = Decimal(10)
+ charged_value = Decimal(11)
+ refunded_value = Decimal(12)
+ canceled_value = Decimal(13)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -1962,7 +1962,7 @@ def test_transaction_update_incorrect_currency_by_staff(
):
# given
transaction = transaction_item_created_by_user
- expected_value = Decimal("10")
+ expected_value = Decimal(10)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -2274,10 +2274,10 @@ def test_transaction_update_creates_calculation_event(
app,
):
# given
- current_authorized_value = Decimal("1")
- current_charged_value = Decimal("2")
- current_canceled_value = Decimal("3")
- current_refunded_value = Decimal("4")
+ current_authorized_value = Decimal(1)
+ current_charged_value = Decimal(2)
+ current_canceled_value = Decimal(3)
+ current_refunded_value = Decimal(4)
transaction = transaction_item_generator(
order_id=order.pk,
app=app,
@@ -2286,10 +2286,10 @@ def test_transaction_update_creates_calculation_event(
canceled_value=current_canceled_value,
refunded_value=current_refunded_value,
)
- authorized_value = Decimal("20")
- charged_value = Decimal("17")
- canceled_value = Decimal("14")
- refunded_value = Decimal("15")
+ authorized_value = Decimal(20)
+ charged_value = Decimal(17)
+ canceled_value = Decimal(14)
+ refunded_value = Decimal(15)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -2376,201 +2376,201 @@ def test_transaction_update_creates_calculation_event(
"amountAuthorized",
"authorizedAmount",
"authorized_value",
- Decimal("12"),
- Decimal("1"),
- Decimal("2"),
- Decimal("3"),
- Decimal("4"),
+ Decimal(12),
+ Decimal(1),
+ Decimal(2),
+ Decimal(3),
+ Decimal(4),
),
(
"amountAuthorized",
"authorizedAmount",
"authorized_value",
- Decimal("12"),
- Decimal("0"),
- Decimal("0"),
- Decimal("0"),
- Decimal("0"),
+ Decimal(12),
+ Decimal(0),
+ Decimal(0),
+ Decimal(0),
+ Decimal(0),
),
(
"amountAuthorized",
"authorizedAmount",
"authorized_value",
- Decimal("12"),
- Decimal("0"),
- Decimal("3"),
- Decimal("1"),
- Decimal("0"),
+ Decimal(12),
+ Decimal(0),
+ Decimal(3),
+ Decimal(1),
+ Decimal(0),
),
(
"amountAuthorized",
"authorizedAmount",
"authorized_value",
- Decimal("12"),
- Decimal("100"),
- Decimal("3"),
- Decimal("1"),
- Decimal("0"),
+ Decimal(12),
+ Decimal(100),
+ Decimal(3),
+ Decimal(1),
+ Decimal(0),
),
(
"amountAuthorized",
"authorizedAmount",
"authorized_value",
- Decimal("0"),
- Decimal("1"),
- Decimal("2"),
- Decimal("3"),
- Decimal("4"),
+ Decimal(0),
+ Decimal(1),
+ Decimal(2),
+ Decimal(3),
+ Decimal(4),
),
(
"amountAuthorized",
"authorizedAmount",
"authorized_value",
- Decimal("1"),
- Decimal("3"),
- Decimal("2"),
- Decimal("3"),
- Decimal("4"),
+ Decimal(1),
+ Decimal(3),
+ Decimal(2),
+ Decimal(3),
+ Decimal(4),
),
(
"amountCharged",
"chargedAmount",
"charged_value",
- Decimal("13"),
- Decimal("1"),
- Decimal("2"),
- Decimal("3"),
- Decimal("4"),
+ Decimal(13),
+ Decimal(1),
+ Decimal(2),
+ Decimal(3),
+ Decimal(4),
),
(
"amountCharged",
"chargedAmount",
"charged_value",
- Decimal("13"),
- Decimal("0"),
- Decimal("0"),
- Decimal("0"),
- Decimal("0"),
+ Decimal(13),
+ Decimal(0),
+ Decimal(0),
+ Decimal(0),
+ Decimal(0),
),
(
"amountCharged",
"chargedAmount",
"charged_value",
- Decimal("13"),
- Decimal("0"),
- Decimal("200"),
- Decimal("0"),
- Decimal("0"),
+ Decimal(13),
+ Decimal(0),
+ Decimal(200),
+ Decimal(0),
+ Decimal(0),
),
(
"amountCharged",
"chargedAmount",
"charged_value",
- Decimal("0"),
- Decimal("1"),
- Decimal("2"),
- Decimal("3"),
- Decimal("4"),
+ Decimal(0),
+ Decimal(1),
+ Decimal(2),
+ Decimal(3),
+ Decimal(4),
),
(
"amountCanceled",
"canceledAmount",
"canceled_value",
- Decimal("1"),
- Decimal("1"),
- Decimal("2"),
- Decimal("3"),
- Decimal("4"),
+ Decimal(1),
+ Decimal(1),
+ Decimal(2),
+ Decimal(3),
+ Decimal(4),
),
(
"amountCanceled",
"canceledAmount",
"canceled_value",
- Decimal("14"),
- Decimal("1"),
- Decimal("2"),
- Decimal("3"),
- Decimal("4"),
+ Decimal(14),
+ Decimal(1),
+ Decimal(2),
+ Decimal(3),
+ Decimal(4),
),
(
"amountCanceled",
"canceledAmount",
"canceled_value",
- Decimal("14"),
- Decimal("0"),
- Decimal("0"),
- Decimal("0"),
- Decimal("0"),
+ Decimal(14),
+ Decimal(0),
+ Decimal(0),
+ Decimal(0),
+ Decimal(0),
),
(
"amountCanceled",
"canceledAmount",
"canceled_value",
- Decimal("14"),
- Decimal("0"),
- Decimal("0"),
- Decimal("0"),
- Decimal("100"),
+ Decimal(14),
+ Decimal(0),
+ Decimal(0),
+ Decimal(0),
+ Decimal(100),
),
(
"amountCanceled",
"canceledAmount",
"canceled_value",
- Decimal("0"),
- Decimal("1"),
- Decimal("2"),
- Decimal("3"),
- Decimal("4"),
+ Decimal(0),
+ Decimal(1),
+ Decimal(2),
+ Decimal(3),
+ Decimal(4),
),
(
"amountRefunded",
"refundedAmount",
"refunded_value",
- Decimal("15"),
- Decimal("1"),
- Decimal("2"),
- Decimal("3"),
- Decimal("4"),
+ Decimal(15),
+ Decimal(1),
+ Decimal(2),
+ Decimal(3),
+ Decimal(4),
),
(
"amountRefunded",
"refundedAmount",
"refunded_value",
- Decimal("15"),
- Decimal("0"),
- Decimal("0"),
- Decimal("0"),
- Decimal("0"),
+ Decimal(15),
+ Decimal(0),
+ Decimal(0),
+ Decimal(0),
+ Decimal(0),
),
(
"amountRefunded",
"refundedAmount",
"refunded_value",
- Decimal("15"),
- Decimal("0"),
- Decimal("0"),
- Decimal("0"),
- Decimal("100"),
+ Decimal(15),
+ Decimal(0),
+ Decimal(0),
+ Decimal(0),
+ Decimal(100),
),
(
"amountRefunded",
"refundedAmount",
"refunded_value",
- Decimal("0"),
- Decimal("1"),
- Decimal("2"),
- Decimal("3"),
- Decimal("4"),
+ Decimal(0),
+ Decimal(1),
+ Decimal(2),
+ Decimal(3),
+ Decimal(4),
),
(
"amountRefunded",
"refundedAmount",
"refunded_value",
- Decimal("1"),
- Decimal("1"),
- Decimal("2"),
- Decimal("3"),
- Decimal("4"),
+ Decimal(1),
+ Decimal(1),
+ Decimal(2),
+ Decimal(3),
+ Decimal(4),
),
],
)
@@ -2649,16 +2649,16 @@ def test_transaction_update_for_checkout_updates_payment_statuses(
app,
):
# given
- current_authorized_value = Decimal("1")
- current_charged_value = Decimal("2")
+ current_authorized_value = Decimal(1)
+ current_charged_value = Decimal(2)
transaction = transaction_item_generator(
checkout_id=checkout_with_items.pk,
app=app,
authorized_value=current_authorized_value,
charged_value=current_charged_value,
)
- authorized_value = Decimal("12")
- charged_value = Decimal("13")
+ authorized_value = Decimal(12)
+ charged_value = Decimal(13)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -2698,8 +2698,8 @@ def test_transaction_update_for_checkout_fully_paid(
plugins_manager,
):
# given
- current_authorized_value = Decimal("1")
- current_charged_value = Decimal("2")
+ current_authorized_value = Decimal(1)
+ current_charged_value = Decimal(2)
transaction = transaction_item_generator(
checkout_id=checkout_with_prices.pk,
app=app,
@@ -2749,8 +2749,8 @@ def test_transaction_update_for_checkout_fully_paid_automatic_completion(
plugins_manager,
):
# given
- current_authorized_value = Decimal("1")
- current_charged_value = Decimal("2")
+ current_authorized_value = Decimal(1)
+ current_charged_value = Decimal(2)
transaction = transaction_item_generator(
checkout_id=checkout_with_prices.pk,
app=app,
@@ -2810,8 +2810,8 @@ def test_transaction_update_for_checkout_fully_authorized(
plugins_manager,
):
# given
- current_authorized_value = Decimal("1")
- current_charged_value = Decimal("2")
+ current_authorized_value = Decimal(1)
+ current_charged_value = Decimal(2)
transaction = transaction_item_generator(
checkout_id=checkout_with_prices.pk,
app=app,
@@ -2861,7 +2861,7 @@ def test_transaction_update_for_checkout_fully_authorized_automatic_completion(
plugins_manager,
):
# given
- current_authorized_value = Decimal("1")
+ current_authorized_value = Decimal(1)
transaction = transaction_item_generator(
checkout_id=checkout_with_prices.pk,
app=app,
@@ -2989,8 +2989,8 @@ def test_transaction_update_for_order_triggers_webhooks_when_fully_paid(
order = unconfirmed_order_with_lines
order.channel.automatically_confirm_all_new_orders = auto_order_confirmation
order.channel.save(update_fields=["automatically_confirm_all_new_orders"])
- current_authorized_value = Decimal("1")
- current_charged_value = Decimal("2")
+ current_authorized_value = Decimal(1)
+ current_charged_value = Decimal(2)
transaction = transaction_item_generator(
order_id=order.pk,
app=app,
@@ -3046,8 +3046,8 @@ def test_transaction_update_for_draft_order_triggers_webhooks_when_fully_paid(
order = draft_order
order.channel.automatically_confirm_all_new_orders = auto_order_confirmation
order.channel.save(update_fields=["automatically_confirm_all_new_orders"])
- current_authorized_value = Decimal("1")
- current_charged_value = Decimal("2")
+ current_authorized_value = Decimal(1)
+ current_charged_value = Decimal(2)
transaction = transaction_item_generator(
order_id=order.pk,
app=app,
@@ -3095,8 +3095,8 @@ def test_transaction_update_for_order_triggers_webhook_when_partially_paid(
transaction_item_generator,
):
# given
- current_authorized_value = Decimal("1")
- current_charged_value = Decimal("2")
+ current_authorized_value = Decimal(1)
+ current_charged_value = Decimal(2)
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
@@ -3108,7 +3108,7 @@ def test_transaction_update_for_order_triggers_webhook_when_partially_paid(
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
"transaction": {
"amountCharged": {
- "amount": Decimal("10"),
+ "amount": Decimal(10),
"currency": "USD",
},
},
@@ -3142,8 +3142,8 @@ def test_transaction_update_for_order_triggers_webhook_when_authorized(
transaction_item_generator,
):
# given
- current_authorized_value = Decimal("1")
- current_charged_value = Decimal("2")
+ current_authorized_value = Decimal(1)
+ current_charged_value = Decimal(2)
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
@@ -3155,7 +3155,7 @@ def test_transaction_update_for_order_triggers_webhook_when_authorized(
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
"transaction": {
"amountAuthorized": {
- "amount": Decimal("10"),
+ "amount": Decimal(10),
"currency": "USD",
},
},
@@ -3190,7 +3190,7 @@ def test_transaction_update_for_order_triggers_webhooks_when_fully_refunded(
transaction_item_generator,
):
# given
- current_refunded_value = Decimal("2")
+ current_refunded_value = Decimal(2)
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
@@ -3236,7 +3236,7 @@ def test_transaction_update_for_order_triggers_webhook_when_partially_refunded(
transaction_item_generator,
):
# given
- current_refunded_value = Decimal("2")
+ current_refunded_value = Decimal(2)
transaction = transaction_item_generator(
order_id=order_with_lines.pk,
app=app,
@@ -3247,7 +3247,7 @@ def test_transaction_update_for_order_triggers_webhook_when_partially_refunded(
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
"transaction": {
"amountRefunded": {
- "amount": Decimal("10"),
+ "amount": Decimal(10),
"currency": "USD",
},
},
@@ -3306,8 +3306,8 @@ def test_transaction_update_for_checkout_updates_last_transaction_modified_at(
app,
):
# given
- current_authorized_value = Decimal("1")
- current_charged_value = Decimal("2")
+ current_authorized_value = Decimal(1)
+ current_charged_value = Decimal(2)
transaction = transaction_item_generator(
checkout_id=checkout_with_items.pk,
app=app,
@@ -3320,8 +3320,8 @@ def test_transaction_update_for_checkout_updates_last_transaction_modified_at(
checkout_with_items.last_transaction_modified_at = previous_modified_at
checkout_with_items.save()
- authorized_value = Decimal("12")
- charged_value = Decimal("13")
+ authorized_value = Decimal(12)
+ charged_value = Decimal(13)
variables = {
"id": graphene.Node.to_global_id("TransactionItem", transaction.token),
@@ -3370,10 +3370,10 @@ def test_transaction_update_amounts_with_lot_of_decimal_places(
app,
):
# given
- current_authorized_value = Decimal("1")
- current_charged_value = Decimal("2")
- current_refunded_value = Decimal("3")
- current_canceled_value = Decimal("4")
+ current_authorized_value = Decimal(1)
+ current_charged_value = Decimal(2)
+ current_refunded_value = Decimal(3)
+ current_canceled_value = Decimal(4)
transaction = transaction_item_generator(
order_id=order.pk,
diff --git a/saleor/graphql/product/mutations/channels.py b/saleor/graphql/product/mutations/channels.py
index 8f875f003e..cd56bf458e 100644
--- a/saleor/graphql/product/mutations/channels.py
+++ b/saleor/graphql/product/mutations/channels.py
@@ -275,7 +275,7 @@ class ProductChannelListingUpdate(BaseChannelListingMutation):
errors["addVariants"].append(error)
@classmethod
- def add_variants(cls, channel, add_variants: list[dict]):
+ def add_variants(cls, channel, add_variants: list[dict] | None):
if not add_variants:
return
variants = cls.get_nodes_or_error(add_variants, "id", ProductVariant)
@@ -304,7 +304,7 @@ class ProductChannelListingUpdate(BaseChannelListingMutation):
product_channel_listing,
product,
channel,
- remove_variants: list[dict],
+ remove_variants: list[dict] | None,
):
if not remove_variants:
return
diff --git a/saleor/graphql/shop/mutations/staff_notification_recipient_create.py b/saleor/graphql/shop/mutations/staff_notification_recipient_create.py
index 5522aaa720..2e6418b5b3 100644
--- a/saleor/graphql/shop/mutations/staff_notification_recipient_create.py
+++ b/saleor/graphql/shop/mutations/staff_notification_recipient_create.py
@@ -39,7 +39,7 @@ class StaffNotificationRecipientCreate(DeprecatedModelMutation):
error_type_field = "shop_errors"
@classmethod
- def clean_input(cls, info, instance, data):
+ def clean_input(cls, info, instance, data, *, input_cls=None):
cleaned_input = super().clean_input(info, instance, data)
cls.validate_input(instance, cleaned_input)
email = cleaned_input.pop("email", None)
diff --git a/saleor/graphql/site/dataloaders.py b/saleor/graphql/site/dataloaders.py
index 1fee54ef71..ae1da514e4 100644
--- a/saleor/graphql/site/dataloaders.py
+++ b/saleor/graphql/site/dataloaders.py
@@ -71,7 +71,7 @@ def ensure_that_site_is_not_none(request, host, site):
T = TypeVar("T")
-def load_site_callback(func: Callable[..., T]) -> Callable[..., Promise[T]]:
+def load_site_callback[T](func: Callable[..., T]) -> Callable[..., Promise[T]]:
def _wrapper(root, info, *args, **kwargs):
return get_site_promise(info.context).then(
partial(func, root, info, *args, **kwargs)
diff --git a/saleor/graphql/translations/dataloaders.py b/saleor/graphql/translations/dataloaders.py
index a43e61559d..ac54863f30 100644
--- a/saleor/graphql/translations/dataloaders.py
+++ b/saleor/graphql/translations/dataloaders.py
@@ -1,5 +1,5 @@
from collections import defaultdict
-from typing import Generic, TypeVar
+from typing import TypeVar
from ...attribute import models as attribute_models
from ...discount import models as discount_models
@@ -13,9 +13,7 @@ from ..core.dataloaders import DataLoader
T = TypeVar("T")
-class BaseTranslationByIdAndLanguageCodeLoader(
- DataLoader[tuple[int, str], T], Generic[T]
-):
+class BaseTranslationByIdAndLanguageCodeLoader[T](DataLoader[tuple[int, str], T]):
model = None
relation_name = None
diff --git a/saleor/graphql/translations/mutations/utils.py b/saleor/graphql/translations/mutations/utils.py
index 5afadbf168..23f58a3bf6 100644
--- a/saleor/graphql/translations/mutations/utils.py
+++ b/saleor/graphql/translations/mutations/utils.py
@@ -213,7 +213,7 @@ class BaseBulkTranslateMutation(BaseMutation):
abstract = True
@classmethod
- def __init_subclass_with_meta__(
+ def __init_subclass_with_meta__( # type: ignore[override]
cls,
base_model=None,
translation_model=None,
diff --git a/saleor/order/migrations/0162_order_granted_refund.py b/saleor/order/migrations/0162_order_granted_refund.py
index 1a236ed208..dda36cf792 100644
--- a/saleor/order/migrations/0162_order_granted_refund.py
+++ b/saleor/order/migrations/0162_order_granted_refund.py
@@ -35,7 +35,7 @@ class Migration(migrations.Migration):
(
"amount_value",
models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
("currency", models.CharField(max_length=3)),
diff --git a/saleor/order/migrations/0165_fix_order_charge_status_with_transactions.py b/saleor/order/migrations/0165_fix_order_charge_status_with_transactions.py
index 839b8ac38c..6dab44faa6 100644
--- a/saleor/order/migrations/0165_fix_order_charge_status_with_transactions.py
+++ b/saleor/order/migrations/0165_fix_order_charge_status_with_transactions.py
@@ -22,11 +22,11 @@ def update_order_charge_status(order, granted_refund_amount):
the order.total - order granted refund
We treat the order as not charged when the charged amount is 0.
"""
- total_charged = order.total_charged_amount or Decimal("0")
+ total_charged = order.total_charged_amount or Decimal(0)
total_charged = quantize_price(total_charged, order.currency)
current_total_gross = order.total_gross_amount - granted_refund_amount
- current_total_gross = max(current_total_gross, Decimal("0"))
+ current_total_gross = max(current_total_gross, Decimal(0))
current_total_gross = quantize_price(current_total_gross, order.currency)
if total_charged == current_total_gross:
diff --git a/saleor/order/migrations/0180_auto_20231108_0908.py b/saleor/order/migrations/0180_auto_20231108_0908.py
index e1ba2bbdc7..8cb3e83be6 100644
--- a/saleor/order/migrations/0180_auto_20231108_0908.py
+++ b/saleor/order/migrations/0180_auto_20231108_0908.py
@@ -15,7 +15,7 @@ class Migration(migrations.Migration):
model_name="order",
name="subtotal_gross_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.RunSQL(
@@ -30,7 +30,7 @@ class Migration(migrations.Migration):
model_name="order",
name="subtotal_net_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.RunSQL(
diff --git a/saleor/order/migrations/0193_fix_subtotal_value_for_order_from_bulk.py b/saleor/order/migrations/0193_fix_subtotal_value_for_order_from_bulk.py
index 34a350effb..f86df115bd 100644
--- a/saleor/order/migrations/0193_fix_subtotal_value_for_order_from_bulk.py
+++ b/saleor/order/migrations/0193_fix_subtotal_value_for_order_from_bulk.py
@@ -29,7 +29,7 @@ def update_order_authorize_status(order, granted_refund_amount):
) or Decimal(0)
total_covered = quantize_price(total_covered, order.currency)
current_total_gross = order.total_gross_amount - granted_refund_amount
- current_total_gross = max(current_total_gross, Decimal("0"))
+ current_total_gross = max(current_total_gross, Decimal(0))
current_total_gross = quantize_price(current_total_gross, order.currency)
if total_covered == Decimal(0) and order.total.gross.amount == Decimal(0):
@@ -53,11 +53,11 @@ def update_order_charge_status(order, granted_refund_amount):
the order.total - order granted refund
We treat the order as not charged when the charged amount is 0.
"""
- total_charged = order.total_charged_amount or Decimal("0")
+ total_charged = order.total_charged_amount or Decimal(0)
total_charged = quantize_price(total_charged, order.currency)
current_total_gross = order.total_gross_amount - granted_refund_amount
- current_total_gross = max(current_total_gross, Decimal("0"))
+ current_total_gross = max(current_total_gross, Decimal(0))
current_total_gross = quantize_price(current_total_gross, order.currency)
if total_charged == current_total_gross:
diff --git a/saleor/order/migrations/0196_alter_fulfillment_shipping_refund_amount_and_more.py b/saleor/order/migrations/0196_alter_fulfillment_shipping_refund_amount_and_more.py
index 95f1fa0eaf..0f244fcf8e 100644
--- a/saleor/order/migrations/0196_alter_fulfillment_shipping_refund_amount_and_more.py
+++ b/saleor/order/migrations/0196_alter_fulfillment_shipping_refund_amount_and_more.py
@@ -50,14 +50,14 @@ class Migration(migrations.Migration):
model_name="order",
name="subtotal_gross_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="order",
name="subtotal_net_amount",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
@@ -113,7 +113,7 @@ class Migration(migrations.Migration):
model_name="ordergrantedrefund",
name="amount_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
diff --git a/saleor/order/models.py b/saleor/order/models.py
index 055b7a2e64..3b77bdca81 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -915,7 +915,7 @@ class OrderGrantedRefund(models.Model):
amount_value = models.DecimalField(
max_digits=settings.DEFAULT_MAX_DIGITS,
decimal_places=settings.DEFAULT_DECIMAL_PLACES,
- default=Decimal("0"),
+ default=Decimal(0),
)
amount = MoneyField(amount_field="amount_value", currency_field="currency")
currency = models.CharField(
diff --git a/saleor/order/tests/fixtures/draft_order.py b/saleor/order/tests/fixtures/draft_order.py
index 809b1f28f7..22908f0536 100644
--- a/saleor/order/tests/fixtures/draft_order.py
+++ b/saleor/order/tests/fixtures/draft_order.py
@@ -35,7 +35,7 @@ def draft_order(order_with_lines):
@pytest.fixture
def draft_order_with_fixed_discount_order(draft_order):
- value = Decimal("20")
+ value = Decimal(20)
discount = partial(fixed_discount, discount=Money(value, draft_order.currency))
draft_order.total = discount(draft_order.total)
draft_order.discounts.create(
diff --git a/saleor/order/tests/test_base_order_total.py b/saleor/order/tests/test_base_order_total.py
index b280159e63..e999e8f182 100644
--- a/saleor/order/tests/test_base_order_total.py
+++ b/saleor/order/tests/test_base_order_total.py
@@ -191,7 +191,7 @@ def test_base_order_total_with_fixed_manual_discount_more_then_total(order_with_
order_total = base_calculations.base_order_total(order, lines)
# then
- assert order_total == Money(Decimal("0"), order.currency)
+ assert order_total == Money(Decimal(0), order.currency)
order_discount.refresh_from_db()
assert order_discount.amount == undiscounted_total
diff --git a/saleor/order/tests/test_calculations.py b/saleor/order/tests/test_calculations.py
index 8ad803115e..88a6737061 100644
--- a/saleor/order/tests/test_calculations.py
+++ b/saleor/order/tests/test_calculations.py
@@ -1821,9 +1821,9 @@ def test_fetch_order_prices_flat_rates_with_weighted_shipping_tax(
second_line = lines[-1]
# Set different tax rates for different lines
- first_rate = Decimal("5")
- second_rate = Decimal("60")
- shipping_rate = Decimal("223")
+ first_rate = Decimal(5)
+ second_rate = Decimal(60)
+ shipping_rate = Decimal(223)
first_line.tax_class.country_rates.filter(country=country).update(rate=first_rate)
diff --git a/saleor/order/tests/test_fetch_order_prices.py b/saleor/order/tests/test_fetch_order_prices.py
index 9e5135ec42..8c1e8f20db 100644
--- a/saleor/order/tests/test_fetch_order_prices.py
+++ b/saleor/order/tests/test_fetch_order_prices.py
@@ -841,7 +841,7 @@ def test_fetch_order_prices_manual_discount_and_order_discount_flat_rates(
tax_rate = Decimal("1.23")
- discount_value = Decimal("50")
+ discount_value = Decimal(50)
manual_discount = order.discounts.create(
value_type=DiscountValueType.PERCENTAGE,
value=discount_value,
@@ -978,7 +978,7 @@ def test_fetch_order_prices_manual_discount_and_gift_discount_flat_rates(
tax_rate = Decimal("1.23")
- discount_value = Decimal("50")
+ discount_value = Decimal(50)
manual_discount = order.discounts.create(
value_type=DiscountValueType.PERCENTAGE,
value=discount_value,
@@ -1125,7 +1125,7 @@ def test_fetch_order_prices_manual_discount_and_catalogue_discount_flat_rates(
tax_rate = Decimal("1.23")
- manual_discount_value = Decimal("50")
+ manual_discount_value = Decimal(50)
manual_discount = order.discounts.create(
value_type=DiscountValueType.PERCENTAGE,
value=manual_discount_value,
@@ -1286,7 +1286,7 @@ def test_fetch_order_prices_manual_order_discount_voucher_specific_product(
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- unit_discount_amount = Decimal("2")
+ unit_discount_amount = Decimal(2)
voucher_listing.discount_value = unit_discount_amount
voucher_listing.save(update_fields=["discount_value"])
@@ -1301,7 +1301,7 @@ def test_fetch_order_prices_manual_order_discount_voucher_specific_product(
create_or_update_voucher_discount_objects_for_order(order)
# create manual order discount
- order_discount_amount = Decimal("10")
+ order_discount_amount = Decimal(10)
order_discount = order.discounts.create(
value_type=DiscountValueType.FIXED,
value=order_discount_amount,
@@ -1404,7 +1404,7 @@ def test_fetch_order_prices_manual_order_discount_and_voucher_apply_once_per_ord
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- discount_amount = Decimal("3")
+ discount_amount = Decimal(3)
voucher_listing.discount_value = discount_amount
voucher_listing.save(update_fields=["discount_value"])
@@ -1419,7 +1419,7 @@ def test_fetch_order_prices_manual_order_discount_and_voucher_apply_once_per_ord
create_or_update_voucher_discount_objects_for_order(order)
# create manual order discount
- order_discount_amount = Decimal("8")
+ order_discount_amount = Decimal(8)
order_discount = order.discounts.create(
value_type=DiscountValueType.FIXED,
value=order_discount_amount,
@@ -1553,7 +1553,7 @@ def test_fetch_order_prices_voucher_shipping_and_manual_discount_fixed(
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- voucher_discount_amount = Decimal("4")
+ voucher_discount_amount = Decimal(4)
voucher_listing.discount_value = voucher_discount_amount
voucher_listing.save(update_fields=["discount_value"])
@@ -1571,7 +1571,7 @@ def test_fetch_order_prices_voucher_shipping_and_manual_discount_fixed(
undiscounted_subtotal += line.base_unit_price_amount * line.quantity
# create manual order discount
- manual_discount_amount = Decimal("10")
+ manual_discount_amount = Decimal(10)
manual_discount = order.discounts.create(
value_type=DiscountValueType.FIXED,
value=manual_discount_amount,
@@ -1645,7 +1645,7 @@ def test_fetch_order_prices_voucher_shipping_and_manual_discount_percentage(
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- voucher_discount_amount = Decimal("4")
+ voucher_discount_amount = Decimal(4)
voucher_listing.discount_value = voucher_discount_amount
voucher_listing.save(update_fields=["discount_value"])
@@ -1663,7 +1663,7 @@ def test_fetch_order_prices_voucher_shipping_and_manual_discount_percentage(
undiscounted_subtotal += line.base_unit_price_amount * line.quantity
# create manual order discount
- manual_discount_value = Decimal("10")
+ manual_discount_value = Decimal(10)
manual_discount = order.discounts.create(
value_type=DiscountValueType.PERCENTAGE,
value=manual_discount_value,
@@ -1740,7 +1740,7 @@ def test_fetch_order_prices_voucher_shipping_and_manual_discount_fixed_exceed_to
tax_rate = Decimal("1.23")
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- voucher_discount_amount = Decimal("4")
+ voucher_discount_amount = Decimal(4)
voucher_listing.discount_value = voucher_discount_amount
voucher_listing.save(update_fields=["discount_value"])
@@ -1758,7 +1758,7 @@ def test_fetch_order_prices_voucher_shipping_and_manual_discount_fixed_exceed_to
undiscounted_subtotal += line.base_unit_price_amount * line.quantity
# create manual order discount
- manual_discount_value = Decimal("1000")
+ manual_discount_value = Decimal(1000)
manual_discount = order.discounts.create(
value_type=DiscountValueType.FIXED,
value=manual_discount_value,
diff --git a/saleor/order/tests/test_fetch_order_prices_tax_app.py b/saleor/order/tests/test_fetch_order_prices_tax_app.py
index 8c9881ad0e..8a73a095fb 100644
--- a/saleor/order/tests/test_fetch_order_prices_tax_app.py
+++ b/saleor/order/tests/test_fetch_order_prices_tax_app.py
@@ -942,7 +942,7 @@ def test_fetch_order_prices_manual_order_discount_and_line_level_voucher_tax_app
line_1, line_2 = order.lines.all()
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- voucher_reward = Decimal("4")
+ voucher_reward = Decimal(4)
voucher_listing.discount_value = voucher_reward
voucher_listing.save(update_fields=["discount_value"])
@@ -956,7 +956,7 @@ def test_fetch_order_prices_manual_order_discount_and_line_level_voucher_tax_app
create_or_update_voucher_discount_objects_for_order(order)
# create manual order discount
- manual_reward = Decimal("10")
+ manual_reward = Decimal(10)
manual_discount_reason = "Manual discount reason"
manual_discount = order.discounts.create(
value_type=DiscountValueType.FIXED,
@@ -1152,7 +1152,7 @@ def test_fetch_order_prices_manual_line_discount_and_entire_order_voucher_tax_ap
voucher.discount_value_type = DiscountValueType.PERCENTAGE
voucher.save(update_fields=["discount_value_type"])
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- voucher_reward_value = Decimal("20")
+ voucher_reward_value = Decimal(20)
voucher_listing.discount_value = voucher_reward_value
voucher_listing.save(update_fields=["discount_value"])
@@ -1161,7 +1161,7 @@ def test_fetch_order_prices_manual_line_discount_and_entire_order_voucher_tax_ap
order.voucher_code = code
create_or_update_voucher_discount_objects_for_order(order)
- manual_line_discount_value = Decimal("50")
+ manual_line_discount_value = Decimal(50)
manual_discount_reason = "Manual line discount"
update_discount_for_order_line(
line_1,
@@ -1354,7 +1354,7 @@ def test_fetch_order_prices_shipping_voucher_and_manual_discount_tax_app(
voucher.discount_value_type = DiscountValueType.FIXED
voucher.save(update_fields=["type", "discount_value_type"])
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- voucher_discount_amount = Decimal("4")
+ voucher_discount_amount = Decimal(4)
voucher_listing.discount_value = voucher_discount_amount
voucher_listing.save(update_fields=["discount_value"])
@@ -1363,7 +1363,7 @@ def test_fetch_order_prices_shipping_voucher_and_manual_discount_tax_app(
order.voucher_code = code
create_or_update_voucher_discount_objects_for_order(order)
- manual_discount_value = Decimal("10")
+ manual_discount_value = Decimal(10)
manual_discount_reason = "Manual discount reason"
order.discounts.create(
value_type=DiscountValueType.PERCENTAGE,
@@ -1559,7 +1559,7 @@ def test_fetch_order_prices_entire_order_voucher_no_tax_data_tax_app(
voucher.discount_value_type = DiscountValueType.PERCENTAGE
voucher.save(update_fields=["discount_value_type"])
voucher_listing = voucher.channel_listings.get(channel=order.channel)
- voucher_reward_value = Decimal("20")
+ voucher_reward_value = Decimal(20)
voucher_listing.discount_value = voucher_reward_value
voucher_listing.save(update_fields=["discount_value"])
diff --git a/saleor/order/tests/test_notifications.py b/saleor/order/tests/test_notifications.py
index d7a9e373b3..671af4b6c5 100644
--- a/saleor/order/tests/test_notifications.py
+++ b/saleor/order/tests/test_notifications.py
@@ -234,7 +234,7 @@ def test_get_default_order_payload(order_line):
order.total = subtotal + order.shipping_price
tax = order.total_gross_amount - order.total_net_amount
- value = Decimal("20")
+ value = Decimal(20)
discount = partial(fixed_discount, discount=Money(value, order.currency))
order.undiscounted_total = order.total
order.total = discount(order.total)
diff --git a/saleor/order/tests/test_order.py b/saleor/order/tests/test_order.py
index f33965357a..1b57b74b3a 100644
--- a/saleor/order/tests/test_order.py
+++ b/saleor/order/tests/test_order.py
@@ -125,7 +125,7 @@ def test_add_variant_to_order_adds_line_for_new_variant_on_promotion(
order = order_with_lines
variant = product.variants.first()
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = catalogue_promotion_without_rules.rules.create(
catalogue_predicate={
"productPredicate": {
@@ -1253,7 +1253,7 @@ def test_add_variant_to_order_adds_line_for_new_variant_on_promotion_with_custom
order = order_with_lines
variant = product.variants.first()
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = catalogue_promotion_without_rules.rules.create(
catalogue_predicate={
"productPredicate": {
@@ -1412,18 +1412,18 @@ def test_add_variant_to_order_adds_translations_in_order_language(
("granted_refund_amount", "charged_amount", "expected_charge_status"),
[
# granted refund contains part of the order's total, charge amount is 0
- (Decimal("10.40"), Decimal("0"), OrderChargeStatus.NONE),
+ (Decimal("10.40"), Decimal(0), OrderChargeStatus.NONE),
# granted refund covers the whole order's total, charge amount is 0
# status is FULL, as the order total - granted refund amount is 0.
# It means that a charge amount equal to 0 fully covers the order total (0)
- (Decimal("98.40"), Decimal("0"), OrderChargeStatus.FULL),
- (Decimal("0"), Decimal("0"), OrderChargeStatus.NONE),
- (Decimal("0"), Decimal("11.00"), OrderChargeStatus.PARTIAL),
- (Decimal("4"), Decimal("11.00"), OrderChargeStatus.PARTIAL),
+ (Decimal("98.40"), Decimal(0), OrderChargeStatus.FULL),
+ (Decimal(0), Decimal(0), OrderChargeStatus.NONE),
+ (Decimal(0), Decimal("11.00"), OrderChargeStatus.PARTIAL),
+ (Decimal(4), Decimal("11.00"), OrderChargeStatus.PARTIAL),
# granted refund covers 88.40 of total, which is 98.40. Charge amount is 10.
# status is FULL, as the order total - granted refund amount is 10.
(Decimal("88.40"), Decimal("10.00"), OrderChargeStatus.FULL),
- (Decimal("0"), Decimal("98.40"), OrderChargeStatus.FULL),
+ (Decimal(0), Decimal("98.40"), OrderChargeStatus.FULL),
# granted refund covers 88.40 of total, which is 98.40. Charge amount is 98.40.
# status is OVERCHARGED as the charge amount is greater than the order
# total - granted refund amount
diff --git a/saleor/order/tests/test_order_actions.py b/saleor/order/tests/test_order_actions.py
index 49ddbf7b48..68dae63f0c 100644
--- a/saleor/order/tests/test_order_actions.py
+++ b/saleor/order/tests/test_order_actions.py
@@ -2098,7 +2098,7 @@ def test_order_transaction_updated_order_partially_paid(
# given
order_info = fetch_order_info(order_with_lines)
transaction_item = transaction_item_generator(
- order_id=order_with_lines.pk, charged_value=Decimal("10")
+ order_id=order_with_lines.pk, charged_value=Decimal(10)
)
manager = get_plugins_manager(allow_replica=False)
updates_amounts_for_order(
@@ -2134,11 +2134,9 @@ def test_order_transaction_updated_order_partially_paid_and_multiple_transaction
):
# given
order_info = fetch_order_info(order_with_lines)
- transaction_item_generator(
- order_id=order_with_lines.pk, charged_value=Decimal("10")
- )
+ transaction_item_generator(order_id=order_with_lines.pk, charged_value=Decimal(10))
transaction_item = transaction_item_generator(
- order_id=order_with_lines.pk, charged_value=Decimal("5")
+ order_id=order_with_lines.pk, charged_value=Decimal(5)
)
manager = get_plugins_manager(allow_replica=False)
updates_amounts_for_order(
@@ -2174,7 +2172,7 @@ def test_order_transaction_updated_with_the_same_transaction_charged_amount(
):
# given
order_info = fetch_order_info(order_with_lines)
- charged_value = Decimal("5")
+ charged_value = Decimal(5)
transaction_item = transaction_item_generator(
order_id=order_with_lines.pk, charged_value=charged_value
@@ -2252,10 +2250,10 @@ def test_order_transaction_updated_order_partially_authorized_and_multiple_trans
# given
order_info = fetch_order_info(order_with_lines)
transaction_item_generator(
- order_id=order_with_lines.pk, authorized_value=Decimal("10")
+ order_id=order_with_lines.pk, authorized_value=Decimal(10)
)
transaction_item = transaction_item_generator(
- order_id=order_with_lines.pk, authorized_value=Decimal("5")
+ order_id=order_with_lines.pk, authorized_value=Decimal(5)
)
manager = get_plugins_manager(allow_replica=False)
updates_amounts_for_order(
@@ -2291,7 +2289,7 @@ def test_order_transaction_updated_with_the_same_transaction_authorized_amount(
):
# given
order_info = fetch_order_info(order_with_lines)
- authorized_value = Decimal("5")
+ authorized_value = Decimal(5)
transaction_item = transaction_item_generator(
order_id=order_with_lines.pk, authorized_value=authorized_value
@@ -2404,12 +2402,10 @@ def test_order_transaction_updated_order_fully_refunded_and_multiple_transaction
):
# given
order_info = fetch_order_info(order_with_lines)
- transaction_item_generator(
- order_id=order_with_lines.pk, refunded_value=Decimal("10")
- )
+ transaction_item_generator(order_id=order_with_lines.pk, refunded_value=Decimal(10))
transaction_item = transaction_item_generator(
order_id=order_with_lines.pk,
- refunded_value=order_with_lines.total.gross.amount - Decimal("10"),
+ refunded_value=order_with_lines.total.gross.amount - Decimal(10),
)
manager = get_plugins_manager(allow_replica=False)
updates_amounts_for_order(
@@ -2452,7 +2448,7 @@ def test_order_transaction_updated_order_fully_refunded_with_transaction_and_pay
payment.save()
payment.transactions.create(
- amount=Decimal("10"),
+ amount=Decimal(10),
currency=payment.currency,
kind=TransactionKind.REFUND,
gateway_response={},
@@ -2462,7 +2458,7 @@ def test_order_transaction_updated_order_fully_refunded_with_transaction_and_pay
order_info = fetch_order_info(order_with_lines)
transaction_item = transaction_item_generator(
order_id=order_with_lines.pk,
- refunded_value=order_with_lines.total.gross.amount - Decimal("10"),
+ refunded_value=order_with_lines.total.gross.amount - Decimal(10),
)
manager = get_plugins_manager(allow_replica=False)
diff --git a/saleor/order/tests/test_order_search.py b/saleor/order/tests/test_order_search.py
index 2ffe8ddb04..145f656acc 100644
--- a/saleor/order/tests/test_order_search.py
+++ b/saleor/order/tests/test_order_search.py
@@ -45,7 +45,7 @@ def test_prepare_order_search_vector_value(
value_type=DiscountValueType.FIXED,
name="discount",
translated_name="discount translated",
- value=Decimal("20"),
+ value=Decimal(20),
reason="Discount reason",
amount=(order.undiscounted_total - order.total).gross,
)
@@ -74,7 +74,7 @@ def test_prepare_order_search_vector_value_empty_relation_fields(
order.save(update_fields=["shipping_address", "billing_address"])
order.discounts.create(
value_type=DiscountValueType.FIXED,
- value=Decimal("20"),
+ value=Decimal(20),
reason="Discount reason",
amount=(order.undiscounted_total - order.total).gross,
)
diff --git a/saleor/order/utils.py b/saleor/order/utils.py
index f917321949..8a579babd3 100644
--- a/saleor/order/utils.py
+++ b/saleor/order/utils.py
@@ -1045,11 +1045,11 @@ def update_order_charge_status(order: Order, granted_refund_amount: Decimal):
the order.total - order granted refund
We treat the order as not charged when the charged amount is 0.
"""
- total_charged = order.total_charged_amount or Decimal("0")
+ total_charged = order.total_charged_amount or Decimal(0)
total_charged = quantize_price(total_charged, order.currency)
current_total_gross = order.total_gross_amount - granted_refund_amount
- current_total_gross = max(current_total_gross, Decimal("0"))
+ current_total_gross = max(current_total_gross, Decimal(0))
current_total_gross = quantize_price(current_total_gross, order.currency)
if total_charged == current_total_gross:
@@ -1126,7 +1126,7 @@ def update_order_authorize_status(order: Order, granted_refund_amount: Decimal):
) or Decimal(0)
total_covered = quantize_price(total_covered, order.currency)
current_total_gross = order.total_gross_amount - granted_refund_amount
- current_total_gross = max(current_total_gross, Decimal("0"))
+ current_total_gross = max(current_total_gross, Decimal(0))
current_total_gross = quantize_price(current_total_gross, order.currency)
if total_covered == Decimal(0) and order.total.gross.amount == Decimal(0):
diff --git a/saleor/payment/gateways/adyen/tests/webhooks/test_handle_notifications.py b/saleor/payment/gateways/adyen/tests/webhooks/test_handle_notifications.py
index 029872f9d1..a345eda750 100644
--- a/saleor/payment/gateways/adyen/tests/webhooks/test_handle_notifications.py
+++ b/saleor/payment/gateways/adyen/tests/webhooks/test_handle_notifications.py
@@ -507,7 +507,7 @@ def test_handle_authorization_calls_refund_for_inactive_payment(
payment.refresh_from_db()
assert not payment.order
assert payment.checkout
- assert payment.captured_amount == Decimal("0")
+ assert payment.captured_amount == Decimal(0)
assert payment.transactions.count() == 3
diff --git a/saleor/payment/gateways/braintree/__init__.py b/saleor/payment/gateways/braintree/__init__.py
index 63facadf3a..2b5f41617c 100644
--- a/saleor/payment/gateways/braintree/__init__.py
+++ b/saleor/payment/gateways/braintree/__init__.py
@@ -148,6 +148,7 @@ def authorize(
credit_card = gateway_response.get("credit_card", {})
brand = credit_card.get("card_type", "")
brand = brand.lower() if brand is not None else ""
+ transaction_id = gateway_response.get("transaction_id", payment_information.token)
return GatewayResponse(
is_success=result.is_success,
@@ -156,9 +157,7 @@ def authorize(
amount=gateway_response.get("amount", payment_information.amount),
currency=gateway_response.get("currency", payment_information.currency),
customer_id=gateway_response.get("customer_id"),
- transaction_id=gateway_response.get(
- "transaction_id", payment_information.token
- ),
+ transaction_id=transaction_id, # type: ignore[arg-type]
error=error,
payment_method_info=PaymentMethodInfo(
last_4=credit_card.get("last_4"),
@@ -251,7 +250,7 @@ def capture(payment_information: PaymentData, config: GatewayConfig) -> GatewayR
currency=gateway_response.get("currency", payment_information.currency),
transaction_id=gateway_response.get(
"transaction_id", payment_information.token
- ),
+ ), # type: ignore[arg-type]
error=error,
raw_response=gateway_response,
)
@@ -278,7 +277,7 @@ def void(payment_information: PaymentData, config: GatewayConfig) -> GatewayResp
currency=gateway_response.get("currency", payment_information.currency),
transaction_id=gateway_response.get(
"transaction_id", payment_information.token
- ),
+ ), # type: ignore[arg-type]
error=error,
raw_response=gateway_response,
)
@@ -308,7 +307,7 @@ def refund(payment_information: PaymentData, config: GatewayConfig) -> GatewayRe
currency=gateway_response.get("currency", payment_information.currency),
transaction_id=gateway_response.get(
"transaction_id", payment_information.token
- ),
+ ), # type: ignore[arg-type]
error=error,
raw_response=gateway_response,
)
diff --git a/saleor/payment/gateways/razorpay/__init__.py b/saleor/payment/gateways/razorpay/__init__.py
index bd1fa6bc97..9218c0df18 100644
--- a/saleor/payment/gateways/razorpay/__init__.py
+++ b/saleor/payment/gateways/razorpay/__init__.py
@@ -32,7 +32,7 @@ def _generate_response(
) -> GatewayResponse:
"""Generate Saleor transaction information from the payload or from passed data."""
return GatewayResponse(
- transaction_id=data.get("id", payment_information.token),
+ transaction_id=data.get("id", payment_information.token), # type: ignore[arg-type]
action_required=False,
kind=kind,
amount=data.get("amount", payment_information.amount),
diff --git a/saleor/payment/gateways/stripe/tests/test_webhooks.py b/saleor/payment/gateways/stripe/tests/test_webhooks.py
index 4f8a0e6bb1..f7de361432 100644
--- a/saleor/payment/gateways/stripe/tests/test_webhooks.py
+++ b/saleor/payment/gateways/stripe/tests/test_webhooks.py
@@ -1185,7 +1185,7 @@ def test_handle_fully_refund(stripe_plugin, payment_stripe_for_order, channel_US
assert payment.charge_status == ChargeStatus.FULLY_REFUNDED
assert payment.is_active is False
- assert payment.captured_amount == Decimal("0")
+ assert payment.captured_amount == Decimal(0)
def test_handle_partial_refund(stripe_plugin, payment_stripe_for_order, channel_USD):
@@ -1204,7 +1204,7 @@ def test_handle_partial_refund(stripe_plugin, payment_stripe_for_order, channel_
plugin = stripe_plugin()
refund = StripeObject(id="refund_id")
- refund["amount"] = price_to_minor_unit(Decimal("10"), payment.currency)
+ refund["amount"] = price_to_minor_unit(Decimal(10), payment.currency)
refund["currency"] = payment.currency
refund["last_response"] = None
@@ -1219,7 +1219,7 @@ def test_handle_partial_refund(stripe_plugin, payment_stripe_for_order, channel_
assert payment.charge_status == ChargeStatus.PARTIALLY_REFUNDED
assert payment.is_active is True
- assert payment.captured_amount == payment.total - Decimal("10")
+ assert payment.captured_amount == payment.total - Decimal(10)
def test_handle_refund_already_processed(
@@ -1227,7 +1227,7 @@ def test_handle_refund_already_processed(
):
payment = payment_stripe_for_order
payment.charge_status = ChargeStatus.PARTIALLY_REFUNDED
- payment.captured_amount = payment.total - Decimal("10")
+ payment.captured_amount = payment.total - Decimal(10)
payment.save()
refund_id = "refund_abc"
@@ -1243,7 +1243,7 @@ def test_handle_refund_already_processed(
plugin = stripe_plugin()
refund = StripeObject(id=refund_id)
- refund["amount"] = price_to_minor_unit(Decimal("10"), payment.currency)
+ refund["amount"] = price_to_minor_unit(Decimal(10), payment.currency)
refund["currency"] = payment.currency
refund["last_response"] = None
@@ -1258,7 +1258,7 @@ def test_handle_refund_already_processed(
assert payment.charge_status == ChargeStatus.PARTIALLY_REFUNDED
assert payment.is_active is True
- assert payment.captured_amount == payment.total - Decimal("10")
+ assert payment.captured_amount == payment.total - Decimal(10)
@patch("saleor.payment.gateways.stripe.webhooks.stripe.Charge.retrieve")
@@ -1302,7 +1302,7 @@ def test_handle_refund_missing_refunds(
assert payment.charge_status == ChargeStatus.FULLY_REFUNDED
assert payment.is_active is False
- assert payment.captured_amount == Decimal("0")
+ assert payment.captured_amount == Decimal(0)
@pytest.mark.parametrize("called", [True, False])
diff --git a/saleor/payment/migrations/0035_auto_20220421_0615.py b/saleor/payment/migrations/0035_auto_20220421_0615.py
index c7e6520cf2..b36b1e380b 100644
--- a/saleor/payment/migrations/0035_auto_20220421_0615.py
+++ b/saleor/payment/migrations/0035_auto_20220421_0615.py
@@ -72,25 +72,25 @@ class Migration(migrations.Migration):
(
"captured_value",
models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
(
"authorized_value",
models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
(
"refunded_value",
models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
(
"voided_value",
models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
(
diff --git a/saleor/payment/migrations/0038_auto_20230223_0926.py b/saleor/payment/migrations/0038_auto_20230223_0926.py
index 44707b7062..88fd707093 100644
--- a/saleor/payment/migrations/0038_auto_20230223_0926.py
+++ b/saleor/payment/migrations/0038_auto_20230223_0926.py
@@ -17,7 +17,7 @@ class Migration(migrations.Migration):
model_name="transactionevent",
name="amount_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.RunSQL(
@@ -142,7 +142,7 @@ class Migration(migrations.Migration):
model_name="transactionitem",
name="authorize_pending_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.RunSQL(
@@ -157,7 +157,7 @@ class Migration(migrations.Migration):
model_name="transactionitem",
name="cancel_pending_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.RunSQL(
@@ -172,7 +172,7 @@ class Migration(migrations.Migration):
model_name="transactionitem",
name="canceled_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.RunSQL(
@@ -187,7 +187,7 @@ class Migration(migrations.Migration):
model_name="transactionitem",
name="charge_pending_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.RunSQL(
@@ -222,7 +222,7 @@ class Migration(migrations.Migration):
model_name="transactionitem",
name="refund_pending_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12
+ decimal_places=3, default=Decimal(0), max_digits=12
),
),
migrations.RunSQL(
diff --git a/saleor/payment/migrations/0043_drop_from_state_renamed_fields.py b/saleor/payment/migrations/0043_drop_from_state_renamed_fields.py
index ed724aa36a..296682e828 100644
--- a/saleor/payment/migrations/0043_drop_from_state_renamed_fields.py
+++ b/saleor/payment/migrations/0043_drop_from_state_renamed_fields.py
@@ -43,7 +43,7 @@ class Migration(migrations.Migration):
model_name="transactionitem",
name="voided_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=12, null=True
+ decimal_places=3, default=Decimal(0), max_digits=12, null=True
),
),
],
diff --git a/saleor/payment/migrations/0060_alter_payment_captured_amount_alter_payment_total_and_more.py b/saleor/payment/migrations/0060_alter_payment_captured_amount_alter_payment_total_and_more.py
index e02681cda6..0359525842 100644
--- a/saleor/payment/migrations/0060_alter_payment_captured_amount_alter_payment_total_and_more.py
+++ b/saleor/payment/migrations/0060_alter_payment_captured_amount_alter_payment_total_and_more.py
@@ -36,63 +36,63 @@ class Migration(migrations.Migration):
model_name="transactionevent",
name="amount_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="transactionitem",
name="authorize_pending_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="transactionitem",
name="authorized_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="transactionitem",
name="cancel_pending_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="transactionitem",
name="canceled_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="transactionitem",
name="charge_pending_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="transactionitem",
name="charged_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="transactionitem",
name="refund_pending_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
migrations.AlterField(
model_name="transactionitem",
name="refunded_value",
field=models.DecimalField(
- decimal_places=3, default=Decimal("0"), max_digits=20
+ decimal_places=3, default=Decimal(0), max_digits=20
),
),
]
diff --git a/saleor/payment/models.py b/saleor/payment/models.py
index 10a0a66ade..adc19ba487 100644
--- a/saleor/payment/models.py
+++ b/saleor/payment/models.py
@@ -48,7 +48,7 @@ class TransactionItem(ModelWithMetadata):
charged_value = models.DecimalField(
max_digits=settings.DEFAULT_MAX_DIGITS,
decimal_places=settings.DEFAULT_DECIMAL_PLACES,
- default=Decimal("0"),
+ default=Decimal(0),
)
amount_authorized = MoneyField(
amount_field="authorized_value", currency_field="currency"
@@ -56,7 +56,7 @@ class TransactionItem(ModelWithMetadata):
authorized_value = models.DecimalField(
max_digits=settings.DEFAULT_MAX_DIGITS,
decimal_places=settings.DEFAULT_DECIMAL_PLACES,
- default=Decimal("0"),
+ default=Decimal(0),
)
amount_refunded = MoneyField(
amount_field="refunded_value", currency_field="currency"
@@ -64,7 +64,7 @@ class TransactionItem(ModelWithMetadata):
refunded_value = models.DecimalField(
max_digits=settings.DEFAULT_MAX_DIGITS,
decimal_places=settings.DEFAULT_DECIMAL_PLACES,
- default=Decimal("0"),
+ default=Decimal(0),
)
amount_canceled = MoneyField(
amount_field="canceled_value", currency_field="currency"
@@ -72,7 +72,7 @@ class TransactionItem(ModelWithMetadata):
canceled_value = models.DecimalField(
max_digits=settings.DEFAULT_MAX_DIGITS,
decimal_places=settings.DEFAULT_DECIMAL_PLACES,
- default=Decimal("0"),
+ default=Decimal(0),
)
amount_refund_pending = MoneyField(
amount_field="refund_pending_value", currency_field="currency"
@@ -80,7 +80,7 @@ class TransactionItem(ModelWithMetadata):
refund_pending_value = models.DecimalField(
max_digits=settings.DEFAULT_MAX_DIGITS,
decimal_places=settings.DEFAULT_DECIMAL_PLACES,
- default=Decimal("0"),
+ default=Decimal(0),
)
amount_charge_pending = MoneyField(
@@ -89,7 +89,7 @@ class TransactionItem(ModelWithMetadata):
charge_pending_value = models.DecimalField(
max_digits=settings.DEFAULT_MAX_DIGITS,
decimal_places=settings.DEFAULT_DECIMAL_PLACES,
- default=Decimal("0"),
+ default=Decimal(0),
)
amount_authorize_pending = MoneyField(
@@ -98,13 +98,13 @@ class TransactionItem(ModelWithMetadata):
authorize_pending_value = models.DecimalField(
max_digits=settings.DEFAULT_MAX_DIGITS,
decimal_places=settings.DEFAULT_DECIMAL_PLACES,
- default=Decimal("0"),
+ default=Decimal(0),
)
cancel_pending_value = models.DecimalField(
max_digits=settings.DEFAULT_MAX_DIGITS,
decimal_places=settings.DEFAULT_DECIMAL_PLACES,
- default=Decimal("0"),
+ default=Decimal(0),
)
amount_cancel_pending = MoneyField(
amount_field="cancel_pending_value", currency_field="currency"
@@ -210,7 +210,7 @@ class TransactionEvent(models.Model):
amount_value = models.DecimalField(
max_digits=settings.DEFAULT_MAX_DIGITS,
decimal_places=settings.DEFAULT_DECIMAL_PLACES,
- default=Decimal("0"),
+ default=Decimal(0),
)
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
diff --git a/saleor/payment/tasks.py b/saleor/payment/tasks.py
index 3390bb6ea9..2913df3945 100644
--- a/saleor/payment/tasks.py
+++ b/saleor/payment/tasks.py
@@ -135,7 +135,7 @@ def transaction_release_funds_for_checkout_task():
manager = get_plugins_manager(allow_replica=True)
for transaction_item, event in transactions_with_cancel_request_events:
- channel = checkout_id_to_channel[transaction_item.checkout_id]
+ channel = checkout_id_to_channel[transaction_item.checkout_id] # type: ignore[index]
logger.info(
"Releasing funds for transaction %s - canceling",
transaction_item.token,
@@ -163,7 +163,7 @@ def transaction_release_funds_for_checkout_task():
str(e),
)
for transaction_item, event in transactions_with_charge_request_events:
- channel = checkout_id_to_channel[transaction_item.checkout_id]
+ channel = checkout_id_to_channel[transaction_item.checkout_id] # type: ignore[index]
logger.info(
"Releasing funds for transaction %s - refunding",
transaction_item.token,
diff --git a/saleor/payment/tests/test_gateway.py b/saleor/payment/tests/test_gateway.py
index 834e89e04d..d2f3a160eb 100644
--- a/saleor/payment/tests/test_gateway.py
+++ b/saleor/payment/tests/test_gateway.py
@@ -345,7 +345,7 @@ def test_request_charge_action_missing_active_event(
available_actions=["capture", "cancel"],
currency="USD",
order_id=order.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
)
action_value = Decimal("5.00")
requested_event = transaction.events.create(
@@ -391,7 +391,7 @@ def test_request_charge_action_on_order(
available_actions=["capture", "cancel"],
currency="USD",
order_id=order.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app=app,
)
action_value = Decimal("5.00")
@@ -455,7 +455,7 @@ def test_request_charge_action_by_app(
available_actions=["capture", "cancel"],
currency="USD",
order_id=order.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app=webhook_app,
)
action_value = Decimal("5.00")
@@ -509,7 +509,7 @@ def test_request_action_by_removed_app(mocked_transaction_request, order, remove
available_actions=["capture", "void"],
currency="USD",
order_id=order.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app_identifier=app_identifier,
)
action_value = Decimal("5.00")
@@ -546,7 +546,7 @@ def test_request_action_by_disabled_app(mocked_transaction_request, order, app):
available_actions=["capture", "void"],
currency="USD",
order_id=order.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app_identifier=app_identifier,
)
action_value = Decimal("5.00")
@@ -600,7 +600,7 @@ def test_request_action_by_removed_app_and_second_active(
available_actions=["capture", "void"],
currency="USD",
order_id=order.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app_identifier=app_identifier,
app=removed_app,
)
@@ -662,7 +662,7 @@ def test_request_action_by_disabled_app_and_second_active(
available_actions=["capture", "void"],
currency="USD",
order_id=order.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app_identifier=app_identifier,
app=app,
)
@@ -720,7 +720,7 @@ def test_request_charge_action_on_checkout(
available_actions=["capture", "cancel"],
currency="USD",
checkout_id=checkout.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app=app,
)
action_value = Decimal("5.00")
@@ -767,7 +767,7 @@ def test_request_refund_action_missing_active_event(
available_actions=["refund"],
currency="USD",
order_id=order.pk,
- charged_value=Decimal("10"),
+ charged_value=Decimal(10),
)
action_value = Decimal("5.00")
requested_event = transaction.events.create(
@@ -850,7 +850,7 @@ def test_request_refund_action_on_order(
available_actions=["refund"],
currency="USD",
order_id=order.pk,
- charged_value=Decimal("10"),
+ charged_value=Decimal(10),
app=app,
)
action_value = Decimal("5.00")
@@ -924,7 +924,7 @@ def test_request_refund_action_with_granted_refund(
available_actions=["refund"],
currency="USD",
order_id=order_with_lines.pk,
- charged_value=Decimal("10"),
+ charged_value=Decimal(10),
app=app,
)
action_value = order_line.unit_price_gross_amount
@@ -991,7 +991,7 @@ def test_request_refund_action_by_app(
available_actions=["refund"],
currency="USD",
order_id=order.pk,
- charged_value=Decimal("10"),
+ charged_value=Decimal(10),
app=webhook_app,
)
action_value = Decimal("5.00")
@@ -1057,7 +1057,7 @@ def test_request_refund_action_on_checkout(
available_actions=["refund"],
currency="USD",
checkout_id=checkout.pk,
- charged_value=Decimal("10"),
+ charged_value=Decimal(10),
app=app,
)
action_value = Decimal("5.00")
@@ -1104,7 +1104,7 @@ def test_request_cancelation_action_missing_active_event(
available_actions=["capture", "cancel"],
currency="USD",
order_id=order.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
)
requested_event = transaction.events.create(
currency=transaction.currency,
@@ -1190,7 +1190,7 @@ def test_request_cancelation_action_on_order(
available_actions=["capture", "cancel"],
currency="USD",
order_id=order.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app=app,
)
requested_event = transaction.events.create(
@@ -1255,7 +1255,7 @@ def test_request_cancelation_action_by_app(
available_actions=["capture", "cancel"],
currency="USD",
order_id=order.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app=webhook_app,
)
requested_event = transaction.events.create(
@@ -1322,7 +1322,7 @@ def test_request_cancelation_action_on_checkout(
available_actions=["capture", "cancel"],
currency="USD",
checkout_id=checkout.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app=app,
)
requested_event = transaction.events.create(
diff --git a/saleor/payment/tests/test_payment.py b/saleor/payment/tests/test_payment.py
index 6264865649..8824358934 100644
--- a/saleor/payment/tests/test_payment.py
+++ b/saleor/payment/tests/test_payment.py
@@ -461,7 +461,7 @@ def test_gateway_charge_errors(payment_dummy, transaction_token, settings):
gateway.capture(
payment,
get_plugins_manager(allow_replica=False),
- amount=Decimal("0"),
+ amount=Decimal(0),
channel_slug=payment_dummy.order.channel.slug,
)
assert exc.value.message == "Amount should be a positive number."
@@ -472,7 +472,7 @@ def test_gateway_charge_errors(payment_dummy, transaction_token, settings):
gateway.capture(
payment,
get_plugins_manager(allow_replica=False),
- amount=Decimal("10"),
+ amount=Decimal(10),
channel_slug=payment_dummy.order.channel.slug,
)
assert exc.value.message == "This payment cannot be captured."
@@ -483,7 +483,7 @@ def test_gateway_charge_errors(payment_dummy, transaction_token, settings):
gateway.capture(
payment,
get_plugins_manager(allow_replica=False),
- amount=Decimal("1000000"),
+ amount=Decimal(1000000),
channel_slug=payment_dummy.order.channel.slug,
)
assert exc.value.message == ("Unable to charge more than un-captured amount.")
@@ -495,7 +495,7 @@ def test_gateway_refund_errors(payment_txn_captured):
gateway.refund(
payment,
get_plugins_manager(allow_replica=False),
- amount=Decimal("1000000"),
+ amount=Decimal(1000000),
channel_slug=payment_txn_captured.order.channel.slug,
)
assert exc.value.message == "Cannot refund more than captured."
@@ -504,7 +504,7 @@ def test_gateway_refund_errors(payment_txn_captured):
gateway.refund(
payment,
get_plugins_manager(allow_replica=False),
- amount=Decimal("0"),
+ amount=Decimal(0),
channel_slug=payment_txn_captured.order.channel.slug,
)
assert exc.value.message == "Amount should be a positive number."
@@ -515,7 +515,7 @@ def test_gateway_refund_errors(payment_txn_captured):
gateway.refund(
payment,
get_plugins_manager(allow_replica=False),
- amount=Decimal("1"),
+ amount=Decimal(1),
channel_slug=payment_txn_captured.order.channel.slug,
)
assert exc.value.message == "This payment cannot be refunded."
diff --git a/saleor/payment/tests/test_transaction_item_calculations.py b/saleor/payment/tests/test_transaction_item_calculations.py
index 012d3efe10..75d79d8d24 100644
--- a/saleor/payment/tests/test_transaction_item_calculations.py
+++ b/saleor/payment/tests/test_transaction_item_calculations.py
@@ -11,14 +11,14 @@ from ..transaction_item_calculations import recalculate_transaction_amounts
def _assert_amounts(
transaction: TransactionItem,
- authorized_value=Decimal("0"),
- charged_value=Decimal("0"),
- refunded_value=Decimal("0"),
- canceled_value=Decimal("0"),
- authorize_pending_value=Decimal("0"),
- charge_pending_value=Decimal("0"),
- refund_pending_value=Decimal("0"),
- cancel_pending_value=Decimal("0"),
+ authorized_value=Decimal(0),
+ charged_value=Decimal(0),
+ refunded_value=Decimal(0),
+ canceled_value=Decimal(0),
+ authorize_pending_value=Decimal(0),
+ charge_pending_value=Decimal(0),
+ refund_pending_value=Decimal(0),
+ cancel_pending_value=Decimal(0),
):
assert sum(
[
@@ -132,7 +132,7 @@ def test_with_only_authorize_failure_event(
# then
transaction.refresh_from_db()
_assert_amounts(
- transaction, authorize_pending_value=Decimal("0"), authorized_value=Decimal("0")
+ transaction, authorize_pending_value=Decimal(0), authorized_value=Decimal(0)
)
@@ -159,7 +159,7 @@ def test_with_authorize_request_and_success_events(
transaction.refresh_from_db()
_assert_amounts(
transaction,
- authorize_pending_value=Decimal("0"),
+ authorize_pending_value=Decimal(0),
authorized_value=authorize_value,
)
@@ -186,7 +186,7 @@ def test_with_authorize_request_and_failure_events(
# then
transaction.refresh_from_db()
_assert_amounts(
- transaction, authorize_pending_value=Decimal("0"), authorized_value=Decimal("0")
+ transaction, authorize_pending_value=Decimal(0), authorized_value=Decimal(0)
)
@@ -212,7 +212,7 @@ def test_with_authorize_success_and_failure_events(
# then
transaction.refresh_from_db()
_assert_amounts(
- transaction, authorize_pending_value=Decimal("0"), authorized_value=Decimal("0")
+ transaction, authorize_pending_value=Decimal(0), authorized_value=Decimal(0)
)
@@ -243,7 +243,7 @@ def test_with_authorize_success_and_older_failure_events(
transaction.refresh_from_db()
_assert_amounts(
transaction,
- authorize_pending_value=Decimal("0"),
+ authorize_pending_value=Decimal(0),
authorized_value=authorize_value,
)
@@ -254,7 +254,7 @@ def test_with_authorize_adjustment(
# given
transaction = transaction_item_generator()
authorize_value = Decimal("11.00")
- authorize_adjustment_value = Decimal("100")
+ authorize_adjustment_value = Decimal(100)
events = transaction_events_generator(
transaction=transaction,
psp_references=["1", "2", "3", "4"],
@@ -285,7 +285,7 @@ def test_with_authorize_adjustment(
transaction.refresh_from_db()
_assert_amounts(
transaction,
- authorize_pending_value=Decimal("0"),
+ authorize_pending_value=Decimal(0),
authorized_value=authorize_adjustment_value,
)
@@ -399,7 +399,7 @@ def test_with_only_charge_failure_event(
# then
transaction.refresh_from_db()
_assert_amounts(
- transaction, charge_pending_value=Decimal("0"), charged_value=Decimal("0")
+ transaction, charge_pending_value=Decimal(0), charged_value=Decimal(0)
)
@@ -426,7 +426,7 @@ def test_with_charge_request_and_success_events(
transaction.refresh_from_db()
_assert_amounts(
transaction,
- charge_pending_value=Decimal("0"),
+ charge_pending_value=Decimal(0),
charged_value=charge_value,
)
@@ -453,7 +453,7 @@ def test_with_charge_request_and_failure_events(
# then
transaction.refresh_from_db()
_assert_amounts(
- transaction, charge_pending_value=Decimal("0"), charged_value=Decimal("0")
+ transaction, charge_pending_value=Decimal(0), charged_value=Decimal(0)
)
@@ -479,7 +479,7 @@ def test_with_charge_success_and_failure_events(
# then
transaction.refresh_from_db()
_assert_amounts(
- transaction, charge_pending_value=Decimal("0"), charged_value=Decimal("0")
+ transaction, charge_pending_value=Decimal(0), charged_value=Decimal(0)
)
@@ -510,7 +510,7 @@ def test_with_charge_success_and_older_failure_events(
transaction.refresh_from_db()
_assert_amounts(
transaction,
- charge_pending_value=Decimal("0"),
+ charge_pending_value=Decimal(0),
charged_value=charge_value,
)
@@ -569,7 +569,7 @@ def test_with_charge_back(transaction_item_generator, transaction_events_generat
transaction.refresh_from_db()
_assert_amounts(
transaction,
- charge_pending_value=Decimal("0"),
+ charge_pending_value=Decimal(0),
charged_value=first_charge_value + second_charge_value - charge_back_value,
)
@@ -659,7 +659,7 @@ def test_with_only_refund_failure_event(
# then
transaction.refresh_from_db()
_assert_amounts(
- transaction, refund_pending_value=Decimal("0"), refunded_value=Decimal("0")
+ transaction, refund_pending_value=Decimal(0), refunded_value=Decimal(0)
)
@@ -686,7 +686,7 @@ def test_with_refund_request_and_success_events(
transaction.refresh_from_db()
_assert_amounts(
transaction,
- refund_pending_value=Decimal("0"),
+ refund_pending_value=Decimal(0),
refunded_value=refund_value,
charged_value=-refund_value,
)
@@ -714,7 +714,7 @@ def test_with_refund_request_and_failure_events(
# then
transaction.refresh_from_db()
_assert_amounts(
- transaction, refund_pending_value=Decimal("0"), refunded_value=Decimal("0")
+ transaction, refund_pending_value=Decimal(0), refunded_value=Decimal(0)
)
@@ -740,7 +740,7 @@ def test_with_refund_success_and_failure_events(
# then
transaction.refresh_from_db()
_assert_amounts(
- transaction, refund_pending_value=Decimal("0"), refunded_value=Decimal("0")
+ transaction, refund_pending_value=Decimal(0), refunded_value=Decimal(0)
)
@@ -771,7 +771,7 @@ def test_with_refund_success_and_older_failure_events(
transaction.refresh_from_db()
_assert_amounts(
transaction,
- refund_pending_value=Decimal("0"),
+ refund_pending_value=Decimal(0),
refunded_value=refund_value,
charged_value=-refund_value,
)
@@ -814,7 +814,7 @@ def test_with_refund_reverse(transaction_item_generator, transaction_events_gene
first_refund_value = Decimal("11.00")
second_refund_value = Decimal("12.00")
reverse_refund = Decimal("10.00")
- charged_value = Decimal("40")
+ charged_value = Decimal(40)
transaction_events_generator(
transaction=transaction,
psp_references=["1", "2", "3", "4"],
@@ -839,7 +839,7 @@ def test_with_refund_reverse(transaction_item_generator, transaction_events_gene
transaction.refresh_from_db()
_assert_amounts(
transaction,
- refund_pending_value=Decimal("0"),
+ refund_pending_value=Decimal(0),
charged_value=charged_value
- first_refund_value
- second_refund_value
@@ -927,7 +927,7 @@ def test_with_only_cancel_failure_event(
# then
transaction.refresh_from_db()
_assert_amounts(
- transaction, cancel_pending_value=Decimal("0"), canceled_value=Decimal("0")
+ transaction, cancel_pending_value=Decimal(0), canceled_value=Decimal(0)
)
@@ -954,7 +954,7 @@ def test_with_cancel_request_and_success_events(
transaction.refresh_from_db()
_assert_amounts(
transaction,
- cancel_pending_value=Decimal("0"),
+ cancel_pending_value=Decimal(0),
canceled_value=cancel_value,
)
@@ -981,7 +981,7 @@ def test_with_cancel_request_and_failure_events(
# then
transaction.refresh_from_db()
_assert_amounts(
- transaction, cancel_pending_value=Decimal("0"), canceled_value=Decimal("0")
+ transaction, cancel_pending_value=Decimal(0), canceled_value=Decimal(0)
)
@@ -1007,7 +1007,7 @@ def test_with_cancel_success_and_failure_events(
# then
transaction.refresh_from_db()
_assert_amounts(
- transaction, cancel_pending_value=Decimal("0"), canceled_value=Decimal("0")
+ transaction, cancel_pending_value=Decimal(0), canceled_value=Decimal(0)
)
@@ -1038,7 +1038,7 @@ def test_with_cancel_success_and_older_failure_events(
transaction.refresh_from_db()
_assert_amounts(
transaction,
- cancel_pending_value=Decimal("0"),
+ cancel_pending_value=Decimal(0),
canceled_value=cancel_value,
)
@@ -1261,10 +1261,10 @@ def test_event_multiple_events_with_auth_charge_and_refund(
authorize_value = Decimal("250.00")
- charged_value = Decimal("200")
- charged_pending_value = Decimal("50")
- refunded_value = Decimal("30")
- ongoing_pending_refund_value = Decimal("15")
+ charged_value = Decimal(200)
+ charged_pending_value = Decimal(50)
+ refunded_value = Decimal(30)
+ ongoing_pending_refund_value = Decimal(15)
transaction_events_generator(
transaction=transaction,
@@ -1327,10 +1327,10 @@ def test_event_multiple_events_with_auth_charge_and_refund_without_psp_reference
authorize_value = Decimal("250.00")
- charged_value = Decimal("200")
- charged_pending_value = Decimal("50")
- refunded_value = Decimal("30")
- ongoing_pending_refund_value = Decimal("15")
+ charged_value = Decimal(200)
+ charged_pending_value = Decimal(50)
+ refunded_value = Decimal(30)
+ ongoing_pending_refund_value = Decimal(15)
transaction_events_generator(
transaction=transaction,
@@ -1389,8 +1389,8 @@ def test_event_multiple_events_with_auth_and_cancel(
authorize_adjustment_value = Decimal("250.00")
canceled_value = Decimal("11.00")
- cancel_pending_value = Decimal("11")
- ongoing_pending_value = Decimal("3")
+ cancel_pending_value = Decimal(11)
+ ongoing_pending_value = Decimal(3)
transaction_events_generator(
transaction=transaction,
@@ -1447,8 +1447,8 @@ def test_event_multiple_events_with_charge_and_refund(
charged_value = Decimal("250.00")
refunded_value = Decimal("11.00")
- refund_pending_value = Decimal("15")
- ongoing_refund_pending_value = Decimal("3")
+ refund_pending_value = Decimal(15)
+ ongoing_refund_pending_value = Decimal(3)
transaction_events_generator(
transaction=transaction,
@@ -1500,8 +1500,8 @@ def test_event_multiple_events_with_charge_and_failure_refund(
charged_value = Decimal("250.00")
refunded_value = Decimal("11.00")
- refund_pending_value = Decimal("15")
- ongoing_refund_pending_value = Decimal("3")
+ refund_pending_value = Decimal(15)
+ ongoing_refund_pending_value = Decimal(3)
transaction_events_generator(
transaction=transaction,
@@ -1548,8 +1548,8 @@ def test_event_multiple_events_and_transaction_with_amounts(
transaction_item_generator, transaction_events_generator
):
# given
- currently_authorized = Decimal("30")
- currently_charged = Decimal("200")
+ currently_authorized = Decimal(30)
+ currently_charged = Decimal(200)
transaction = transaction_item_generator(
authorized_value=currently_authorized,
charged_value=currently_charged,
@@ -1557,8 +1557,8 @@ def test_event_multiple_events_and_transaction_with_amounts(
charged_value = Decimal("20.00")
refunded_value = Decimal("11.00")
- refund_pending_value = Decimal("15")
- ongoing_refund_pending_value = Decimal("3")
+ refund_pending_value = Decimal(15)
+ ongoing_refund_pending_value = Decimal(3)
transaction_events_generator(
transaction=transaction,
@@ -1592,7 +1592,7 @@ def test_event_multiple_events_and_transaction_with_amounts(
total_charged = max(
(currently_charged + charged_value - total_refuned - total_pending_refund),
- Decimal("0"),
+ Decimal(0),
)
transaction.refresh_from_db()
diff --git a/saleor/payment/tests/test_utils/test_create_transaction_event_for_transaction_session.py b/saleor/payment/tests/test_utils/test_create_transaction_event_for_transaction_session.py
index f974e07fc6..f0ccd1871e 100644
--- a/saleor/payment/tests/test_utils/test_create_transaction_event_for_transaction_session.py
+++ b/saleor/payment/tests/test_utils/test_create_transaction_event_for_transaction_session.py
@@ -117,7 +117,7 @@ def test_create_transaction_event_for_transaction_session_success_response(
plugins_manager,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["result"] = response_result.upper()
response["amount"] = expected_amount
@@ -158,7 +158,7 @@ def test_create_transaction_event_for_transaction_session_success_response_with_
plugins_manager,
):
# given
- request_event_amount = Decimal("12")
+ request_event_amount = Decimal(12)
response = transaction_session_response.copy()
response["result"] = response_result.upper()
@@ -204,7 +204,7 @@ def test_create_transaction_event_for_transaction_session_success_response_with_
plugins_manager,
):
# given
- expected_amount = Decimal("0")
+ expected_amount = Decimal(0)
response = transaction_session_response.copy()
response["result"] = response_result.upper()
response["amount"] = expected_amount
@@ -246,7 +246,7 @@ def test_create_transaction_event_for_transaction_session_not_success_events(
plugins_manager,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["result"] = response_result.upper()
response["amount"] = expected_amount
@@ -269,10 +269,10 @@ def test_create_transaction_event_for_transaction_session_not_success_events(
assert response_event.amount_value == expected_amount
assert response_event.type in [response_result, TransactionEventType.CHARGE_FAILURE]
transaction.refresh_from_db()
- assert transaction.authorized_value == Decimal("0")
- assert transaction.charged_value == Decimal("0")
- assert transaction.authorize_pending_value == Decimal("0")
- assert transaction.charge_pending_value == Decimal("0")
+ assert transaction.authorized_value == Decimal(0)
+ assert transaction.charged_value == Decimal(0)
+ assert transaction.authorize_pending_value == Decimal(0)
+ assert transaction.charge_pending_value == Decimal(0)
@pytest.mark.parametrize(
@@ -294,7 +294,7 @@ def test_create_transaction_event_for_transaction_session_not_success_events_wit
plugins_manager,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["result"] = response_result.upper()
response["amount"] = None
@@ -318,10 +318,10 @@ def test_create_transaction_event_for_transaction_session_not_success_events_wit
assert response_event.amount_value == expected_amount
assert response_event.type in [response_result, TransactionEventType.CHARGE_FAILURE]
transaction.refresh_from_db()
- assert transaction.authorized_value == Decimal("0")
- assert transaction.charged_value == Decimal("0")
- assert transaction.authorize_pending_value == Decimal("0")
- assert transaction.charge_pending_value == Decimal("0")
+ assert transaction.authorized_value == Decimal(0)
+ assert transaction.charged_value == Decimal(0)
+ assert transaction.authorize_pending_value == Decimal(0)
+ assert transaction.charge_pending_value == Decimal(0)
@pytest.mark.parametrize(
@@ -358,7 +358,7 @@ def test_create_transaction_event_for_transaction_session_missing_psp_reference(
plugins_manager,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["result"] = response_result.upper()
response["amount"] = expected_amount
@@ -383,10 +383,10 @@ def test_create_transaction_event_for_transaction_session_missing_psp_reference(
assert response_event.type == TransactionEventType.CHARGE_FAILURE
assert message in response_event.message
transaction.refresh_from_db()
- assert transaction.authorized_value == Decimal("0")
- assert transaction.charged_value == Decimal("0")
- assert transaction.authorize_pending_value == Decimal("0")
- assert transaction.charge_pending_value == Decimal("0")
+ assert transaction.authorized_value == Decimal(0)
+ assert transaction.charged_value == Decimal(0)
+ assert transaction.authorize_pending_value == Decimal(0)
+ assert transaction.charge_pending_value == Decimal(0)
@pytest.mark.parametrize(
@@ -404,7 +404,7 @@ def test_create_transaction_event_for_transaction_session_missing_reference_with
plugins_manager,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["result"] = response_result.upper()
response["amount"] = expected_amount
@@ -428,10 +428,10 @@ def test_create_transaction_event_for_transaction_session_missing_reference_with
assert response_event.amount_value == expected_amount
assert response_event.type == response_result
transaction.refresh_from_db()
- assert transaction.authorized_value == Decimal("0")
- assert transaction.charged_value == Decimal("0")
- assert transaction.authorize_pending_value == Decimal("0")
- assert transaction.charge_pending_value == Decimal("0")
+ assert transaction.authorized_value == Decimal(0)
+ assert transaction.charged_value == Decimal(0)
+ assert transaction.authorize_pending_value == Decimal(0)
+ assert transaction.charge_pending_value == Decimal(0)
@pytest.mark.parametrize(
@@ -455,7 +455,7 @@ def test_create_transaction_event_for_transaction_session_call_webhook_order_upd
django_capture_on_commit_callbacks,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["result"] = response_result.upper()
response["amount"] = expected_amount
@@ -531,7 +531,7 @@ def test_create_transaction_event_for_transaction_session_success_sets_actions(
plugins_manager,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["result"] = response_result.upper()
response["amount"] = expected_amount
@@ -575,7 +575,7 @@ def test_create_transaction_event_for_transaction_session_failure_doesnt_set_act
plugins_manager,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["result"] = response_result.upper()
response["amount"] = expected_amount
@@ -616,7 +616,7 @@ def test_create_transaction_event_for_transaction_session_request_events_as_resp
plugins_manager,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["result"] = response_result.upper()
response["amount"] = expected_amount
@@ -656,7 +656,7 @@ def test_create_transaction_event_updates_transaction_modified_at(
checkout,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["amount"] = expected_amount
@@ -690,7 +690,7 @@ def test_create_transaction_event_for_transaction_session_failure_set_psp_refere
):
# given
expected_psp_reference = "ABC"
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["result"] = TransactionEventType.CHARGE_FAILURE.upper()
response["amount"] = expected_amount
@@ -728,7 +728,7 @@ def test_create_transaction_event_for_transaction_session_when_psp_ref_missing(
plugins_manager,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["result"] = TransactionEventType.CHARGE_ACTION_REQUIRED.upper()
response["amount"] = expected_amount
@@ -766,7 +766,7 @@ def test_create_transaction_event_updates_transaction_modified_at_for_failure(
checkout,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["amount"] = expected_amount
response["result"] = TransactionEventType.CHARGE_FAILURE.upper()
@@ -802,7 +802,7 @@ def test_create_transaction_event_message_limit_exceeded(
caplog,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
message = "m" * 1000
response = transaction_session_response.copy()
response["amount"] = expected_amount
@@ -848,7 +848,7 @@ def test_create_transaction_event_with_message(
checkout,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["amount"] = expected_amount
response["message"] = input_message
@@ -886,7 +886,7 @@ def test_create_transaction_event_with_invalid_message(
def __str__(self):
raise "こんにちは".encode("ascii")
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["amount"] = expected_amount
response["message"] = NonParsableObject()
@@ -1096,7 +1096,7 @@ def test_create_transaction_event_for_transaction_session_sets_payment_method_de
plugins_manager,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["result"] = response_result.upper()
response["amount"] = expected_amount
@@ -1166,7 +1166,7 @@ def test_create_transaction_event_for_transaction_session_invalid_payment_method
plugins_manager,
):
# given
- expected_amount = Decimal("15")
+ expected_amount = Decimal(15)
response = transaction_session_response.copy()
response["result"] = response_result.upper()
response["amount"] = expected_amount
diff --git a/saleor/payment/tests/test_utils/test_utils.py b/saleor/payment/tests/test_utils/test_utils.py
index 4ef07bc3e5..1e17bc972f 100644
--- a/saleor/payment/tests/test_utils/test_utils.py
+++ b/saleor/payment/tests/test_utils/test_utils.py
@@ -1611,10 +1611,10 @@ def test_create_transaction_event_from_request_and_webhook_invalid_message(
@pytest.mark.parametrize(
("db_field_name", "value", "event_type"),
[
- ("authorized_value", Decimal("12"), TransactionEventType.AUTHORIZATION_SUCCESS),
- ("charged_value", Decimal("13"), TransactionEventType.CHARGE_SUCCESS),
- ("canceled_value", Decimal("14"), TransactionEventType.CANCEL_SUCCESS),
- ("refunded_value", Decimal("15"), TransactionEventType.REFUND_SUCCESS),
+ ("authorized_value", Decimal(12), TransactionEventType.AUTHORIZATION_SUCCESS),
+ ("charged_value", Decimal(13), TransactionEventType.CHARGE_SUCCESS),
+ ("canceled_value", Decimal(14), TransactionEventType.CANCEL_SUCCESS),
+ ("refunded_value", Decimal(15), TransactionEventType.REFUND_SUCCESS),
],
)
def test_create_manual_adjustment_events_creates_calculation_events(
@@ -1639,8 +1639,8 @@ def test_create_manual_adjustment_events_additional_authorization(
transaction_item_generator, app
):
# given
- authorized_value = Decimal("10")
- transaction = transaction_item_generator(app=app, authorized_value=Decimal("2"))
+ authorized_value = Decimal(10)
+ transaction = transaction_item_generator(app=app, authorized_value=Decimal(2))
money_data = {"authorized_value": authorized_value}
# when
@@ -1660,8 +1660,8 @@ def test_create_manual_adjustment_events_additional_charge(
transaction_item_generator, app
):
# given
- charged_value = Decimal("10")
- current_charge_value = Decimal("2")
+ charged_value = Decimal(10)
+ current_charge_value = Decimal(2)
transaction = transaction_item_generator(
app=app, charged_value=current_charge_value
)
@@ -1682,8 +1682,8 @@ def test_create_manual_adjustment_events_additional_refund(
transaction_item_generator, app
):
# given
- refunded_value = Decimal("10")
- current_refunded_value = Decimal("2")
+ refunded_value = Decimal(10)
+ current_refunded_value = Decimal(2)
transaction = transaction_item_generator(
app=app, refunded_value=current_refunded_value
)
@@ -1704,8 +1704,8 @@ def test_create_manual_adjustment_events_additional_cancel(
transaction_item_generator, app
):
# given
- canceled_value = Decimal("10")
- current_canceled_value = Decimal("2")
+ canceled_value = Decimal(10)
+ current_canceled_value = Decimal(2)
transaction = transaction_item_generator(
app=app, canceled_value=current_canceled_value
)
@@ -2369,7 +2369,7 @@ def test_deduplicate_event(transaction_events_generator, transaction_item, app):
event = TransactionEvent(
psp_reference="psp:123",
type=TransactionEventType.CHARGE_SUCCESS,
- amount_value=Decimal("10"),
+ amount_value=Decimal(10),
transaction=transaction_item,
currency=transaction_item.currency,
)
@@ -2389,13 +2389,13 @@ def test_deduplicate_event_different_amount(
events = transaction_events_generator(
psp_references=["psp:123"],
types=[TransactionEventType.CHARGE_SUCCESS],
- amounts=[Decimal("10")],
+ amounts=[Decimal(10)],
transaction=transaction_item,
)
event = TransactionEvent(
psp_reference="psp:123",
type=TransactionEventType.CHARGE_SUCCESS,
- amount_value=Decimal("12"),
+ amount_value=Decimal(12),
transaction=transaction_item,
currency=transaction_item.currency,
)
@@ -2420,13 +2420,13 @@ def test_deduplicate_event_authorization_already_exists(
transaction_events_generator(
psp_references=["psp:123"],
types=[TransactionEventType.AUTHORIZATION_SUCCESS],
- amounts=[Decimal("10")],
+ amounts=[Decimal(10)],
transaction=transaction_item,
)
event = TransactionEvent(
psp_reference="psp:111",
type=TransactionEventType.AUTHORIZATION_SUCCESS,
- amount_value=Decimal("10"),
+ amount_value=Decimal(10),
transaction=transaction_item,
currency=transaction_item.currency,
)
diff --git a/saleor/payment/transaction_item_calculations.py b/saleor/payment/transaction_item_calculations.py
index c5cd2a8954..397deb7f2a 100644
--- a/saleor/payment/transaction_item_calculations.py
+++ b/saleor/payment/transaction_item_calculations.py
@@ -315,15 +315,15 @@ def _initilize_action_map(events: Iterable[TransactionEvent]) -> ActionEventMap:
def _set_transaction_amounts_to_zero(transaction: TransactionItem):
- transaction.authorized_value = Decimal("0")
- transaction.charged_value = Decimal("0")
- transaction.refunded_value = Decimal("0")
- transaction.canceled_value = Decimal("0")
+ transaction.authorized_value = Decimal(0)
+ transaction.charged_value = Decimal(0)
+ transaction.refunded_value = Decimal(0)
+ transaction.canceled_value = Decimal(0)
- transaction.authorize_pending_value = Decimal("0")
- transaction.charge_pending_value = Decimal("0")
- transaction.refund_pending_value = Decimal("0")
- transaction.cancel_pending_value = Decimal("0")
+ transaction.authorize_pending_value = Decimal(0)
+ transaction.charge_pending_value = Decimal(0)
+ transaction.refund_pending_value = Decimal(0)
+ transaction.cancel_pending_value = Decimal(0)
def calculate_transaction_amount_based_on_events(transaction: TransactionItem):
@@ -378,9 +378,9 @@ def recalculate_transaction_amounts(transaction: TransactionItem, save: bool = T
"""
calculate_transaction_amount_based_on_events(transaction)
- transaction.authorized_value = max(transaction.authorized_value, Decimal("0"))
+ transaction.authorized_value = max(transaction.authorized_value, Decimal(0))
transaction.authorize_pending_value = max(
- transaction.authorize_pending_value, Decimal("0")
+ transaction.authorize_pending_value, Decimal(0)
)
if save:
diff --git a/saleor/payment/utils.py b/saleor/payment/utils.py
index 98fc03ad1f..30bca3dad9 100644
--- a/saleor/payment/utils.py
+++ b/saleor/payment/utils.py
@@ -723,7 +723,7 @@ def price_to_minor_unit(value: Decimal, currency: str):
precision = get_currency_precision(currency)
number_places = Decimal("10.0") ** precision
value_without_comma = value * number_places
- return str(value_without_comma.quantize(Decimal("1")))
+ return str(value_without_comma.quantize(Decimal(1)))
def get_channel_slug_from_payment(payment: Payment) -> str | None:
diff --git a/saleor/plugins/avatax/__init__.py b/saleor/plugins/avatax/__init__.py
index 230cd06441..8e9ae14f20 100644
--- a/saleor/plugins/avatax/__init__.py
+++ b/saleor/plugins/avatax/__init__.py
@@ -344,7 +344,7 @@ def generate_request_data_from_checkout_lines(
}
append_line_to_data(
- **append_line_to_data_kwargs,
+ **append_line_to_data_kwargs, # type: ignore[arg-type]
amount=checkout_line_total.amount,
ref1=line_info.variant.sku,
)
@@ -533,7 +533,7 @@ def _get_checkout_discount_amount(checkout_info, lines):
Return the discount amount from the entire order or shipping voucher, or from
order promotion discount if there is no voucher and any promotion is eligible.
"""
- discount_amount = Decimal("0")
+ discount_amount = Decimal(0)
if (voucher := checkout_info.voucher) or checkout_info.discounts:
# for apply_once_per_order vouchers the discount is already applied on lines
applicable_discount = True
@@ -553,7 +553,7 @@ def _get_checkout_discount_amount(checkout_info, lines):
discount_amount = (
checkout_info.checkout.discount_amount
if applicable_discount
- else Decimal("0")
+ else Decimal(0)
)
return discount_amount
@@ -614,7 +614,7 @@ def get_order_request_data(order: "Order", config: AvataxConfiguration):
else TransactionType.ORDER
)
discount_amount = get_total_order_discount_excluding_shipping(order).amount
- discounted_lines = discount_amount != Decimal("0")
+ discounted_lines = discount_amount != Decimal(0)
lines = get_order_lines_data(order, config, discounted=discounted_lines)
# if there is no lines to sent we do not want to send the request to avalara
if not lines:
diff --git a/saleor/plugins/avatax/tests/test_avatax.py b/saleor/plugins/avatax/tests/test_avatax.py
index 794cf3545d..5d7a9573f6 100644
--- a/saleor/plugins/avatax/tests/test_avatax.py
+++ b/saleor/plugins/avatax/tests/test_avatax.py
@@ -1727,7 +1727,7 @@ def test_calculate_checkout_total_for_JPY_with_promotion(
channel = checkout.channel
promotion = Promotion.objects.create(name="Checkout promotion")
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = promotion.rules.create(
catalogue_predicate={
"productPredicate": {
@@ -2644,7 +2644,7 @@ def test_calculate_order_shipping_voucher_on_shipping(
method = shipping_zone.shipping_methods.get()
shipping_channel_listings = method.channel_listings.get(channel=channel)
- discount_amount = shipping_channel_listings.price.amount - Decimal("5")
+ discount_amount = shipping_channel_listings.price.amount - Decimal(5)
order.discounts.create(
type=DiscountType.VOUCHER,
value_type=DiscountValueType.FIXED,
@@ -4226,7 +4226,7 @@ def test__get_item_tax_rate_handles_tax_zero_and_rate_value(
plugin = manager.get_plugin(AvataxPlugin.PLUGIN_ID, channel_USD.slug)
# 0.36 == sum of two tax districts
- assert Decimal("0") == plugin._get_item_tax_rate(
+ assert Decimal(0) == plugin._get_item_tax_rate(
avalara_response_with_line_details_and_zero_tax_with_returned_rate,
"123",
Decimal(0.0),
@@ -5298,7 +5298,7 @@ def test_get_order_request_data_draft_order_with_voucher(
assert line_data["discounted"] is True
# shipping line shouldn't be discounted
assert lines_data[-1]["discounted"] is False
- assert Decimal(lines_data[-1]["amount"]) != Decimal("0")
+ assert Decimal(lines_data[-1]["amount"]) != Decimal(0)
def test_get_order_request_data_draft_order_with_shipping_voucher(
@@ -5788,7 +5788,7 @@ def test_generate_request_data_from_checkout_lines_sets_different_tax_code_for_z
line = checkout_with_item.lines.first()
variant = line.variant
- variant.channel_listings.all().update(price_amount=Decimal("0"))
+ variant.channel_listings.all().update(price_amount=Decimal(0))
variant.product.tax_class.store_value_in_metadata(
{META_CODE_KEY: "taxcode", META_DESCRIPTION_KEY: "tax_description"}
)
@@ -5821,7 +5821,7 @@ def test_generate_request_data_from_checkout_lines_sets_different_tax_code_only_
line.save()
variant = line.variant
- variant.channel_listings.all().update(price_amount=Decimal("11"))
+ variant.channel_listings.all().update(price_amount=Decimal(11))
variant.product.tax_class.store_value_in_metadata(
{META_CODE_KEY: "taxcode", META_DESCRIPTION_KEY: "tax_description"}
)
@@ -5859,7 +5859,7 @@ def test_generate_request_data_from_checkout_lines_with_collection_point(
line.save()
variant = line.variant
- variant.channel_listings.all().update(price_amount=Decimal("11"))
+ variant.channel_listings.all().update(price_amount=Decimal(11))
variant.product.tax_class.store_value_in_metadata(
{META_CODE_KEY: "taxcode", META_DESCRIPTION_KEY: "tax_description"}
)
@@ -5899,7 +5899,7 @@ def test_generate_request_data_from_checkout_lines_with_shipping_method(
line.save()
variant = line.variant
- variant.channel_listings.all().update(price_amount=Decimal("11"))
+ variant.channel_listings.all().update(price_amount=Decimal(11))
variant.product.tax_class.store_value_in_metadata(
{META_CODE_KEY: "taxcode", META_DESCRIPTION_KEY: "tax_description"}
)
@@ -6012,8 +6012,8 @@ def test_get_order_lines_data_sets_different_tax_code_for_zero_amount(
plugin_configuration(channel=channel_USD)
line = order_with_lines.lines.first()
- line.base_unit_price_amount = Decimal("0")
- line.undiscounted_base_unit_price_amount = Decimal("0")
+ line.base_unit_price_amount = Decimal(0)
+ line.undiscounted_base_unit_price_amount = Decimal(0)
line.save(
update_fields=[
"base_unit_price_amount",
@@ -6041,8 +6041,8 @@ def test_get_order_lines_data_with_discounted(
settings.PLUGINS = ["saleor.plugins.avatax.plugin.AvataxPlugin"]
plugin_configuration(channel=channel_USD)
- order_line.unit_price_gross_amount = Decimal("10")
- order_line.undiscounted_unit_price_gross_amount = Decimal("20")
+ order_line.unit_price_gross_amount = Decimal(10)
+ order_line.undiscounted_unit_price_gross_amount = Decimal(20)
order_line.quantity = 1
order_line.save(
update_fields=[
@@ -6113,7 +6113,7 @@ def test_get_order_lines_data_adds_lines_with_taxes_disabled_for_line(
settings.PLUGINS = ["saleor.plugins.avatax.plugin.AvataxPlugin"]
plugin_configuration(channel=channel_USD)
- order_with_lines.base_shipping_price_amount = Decimal("0")
+ order_with_lines.base_shipping_price_amount = Decimal(0)
order_with_lines.save(update_fields=["base_shipping_price_amount"])
line = order_with_lines.lines.first()
diff --git a/saleor/plugins/openid_connect/plugin.py b/saleor/plugins/openid_connect/plugin.py
index 05943acec9..248ed7918f 100644
--- a/saleor/plugins/openid_connect/plugin.py
+++ b/saleor/plugins/openid_connect/plugin.py
@@ -508,7 +508,7 @@ class OpenIDConnectPlugin(BasePlugin):
user = get_user_from_access_payload(payload, request)
except (InvalidTokenError, DecodeError):
return previous_value
- if user.is_staff:
+ if user and user.is_staff:
assign_staff_to_default_group_and_update_permissions(
user, self.config.default_group_name
)
diff --git a/saleor/plugins/tests/sample_plugins.py b/saleor/plugins/tests/sample_plugins.py
index a18ba21784..d7c9115f5f 100644
--- a/saleor/plugins/tests/sample_plugins.py
+++ b/saleor/plugins/tests/sample_plugins.py
@@ -34,7 +34,7 @@ def sample_tax_data(obj_with_lines: Union["Order", "Checkout"]) -> TaxData:
TaxLineData(
total_net_amount=unit * 3,
total_gross_amount=unit_gross * 3,
- tax_rate=Decimal("23"),
+ tax_rate=Decimal(23),
)
for _ in obj_with_lines.lines.all()
]
@@ -45,7 +45,7 @@ def sample_tax_data(obj_with_lines: Union["Order", "Checkout"]) -> TaxData:
return TaxData(
shipping_price_net_amount=shipping,
shipping_price_gross_amount=shipping_gross,
- shipping_tax_rate=Decimal("23"),
+ shipping_tax_rate=Decimal(23),
lines=lines,
)
diff --git a/saleor/plugins/tests/test_manager.py b/saleor/plugins/tests/test_manager.py
index 1c392bc0d9..f30d46682c 100644
--- a/saleor/plugins/tests/test_manager.py
+++ b/saleor/plugins/tests/test_manager.py
@@ -1196,7 +1196,7 @@ def test_manager_transaction_initialize_session(
transaction=transaction,
source_object=checkout,
action=TransactionProcessActionData(
- amount=Decimal("10"),
+ amount=Decimal(10),
currency=transaction.currency,
action_type=action_type,
),
@@ -1238,7 +1238,7 @@ def test_manager_transaction_process_session(
transaction=transaction,
source_object=checkout,
action=TransactionProcessActionData(
- amount=Decimal("10"),
+ amount=Decimal(10),
currency=transaction.currency,
action_type=action_type,
),
diff --git a/saleor/plugins/webhook/tests/conftest.py b/saleor/plugins/webhook/tests/conftest.py
index 1edbd8341c..c5ad4e161a 100644
--- a/saleor/plugins/webhook/tests/conftest.py
+++ b/saleor/plugins/webhook/tests/conftest.py
@@ -32,7 +32,7 @@ def available_shipping_methods_factory():
methods.append(
ShippingMethodData(
id=str(i),
- price=Money(Decimal("10"), "usd"),
+ price=Money(Decimal(10), "usd"),
name=uuid.uuid4().hex,
maximum_order_weight=Weight(kg=0),
minimum_order_weight=Weight(kg=0),
diff --git a/saleor/plugins/webhook/tests/test_webhook.py b/saleor/plugins/webhook/tests/test_webhook.py
index 6de82aa123..d1d67b8748 100644
--- a/saleor/plugins/webhook/tests/test_webhook.py
+++ b/saleor/plugins/webhook/tests/test_webhook.py
@@ -1101,7 +1101,7 @@ def test_checkout_payload_includes_promotions(
variant = checkout_lines[0].variant
channel_listing = variant.channel_listings.first()
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = catalogue_promotion_without_rules.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
@@ -1166,7 +1166,7 @@ def test_checkout_payload_includes_order_promotion_discount(
variant = checkout_lines[0].variant
channel_listing = variant.channel_listings.first()
- reward_value = Decimal("5")
+ reward_value = Decimal(5)
rule = catalogue_promotion_without_rules.rules.create(
name="Fixed promotion rule",
order_predicate={
@@ -2092,7 +2092,7 @@ def test_transaction_charge_requested(
available_actions=["capture", "void"],
currency="USD",
order_id=order.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app_identifier=app.identifier,
app=app,
)
@@ -2145,7 +2145,7 @@ def test_transaction_refund_requested(
],
currency="USD",
order_id=order.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app_identifier=app.identifier,
app=app,
)
@@ -2200,7 +2200,7 @@ def test_transaction_refund_requested_missing_app_owner_updated_refundable_for_c
],
currency="USD",
checkout_id=checkout.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app_identifier=app.identifier,
app=app,
)
@@ -2252,7 +2252,7 @@ def test_transaction_cancel_requested_missing_app_owner_updated_refundable_for_c
],
currency="USD",
checkout_id=checkout.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app_identifier=app.identifier,
app=app,
)
@@ -2302,7 +2302,7 @@ def test_transaction_cancelation_requested(
],
currency="USD",
order_id=order.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
app_identifier=app.identifier,
app=app,
)
@@ -2451,8 +2451,8 @@ def test_trigger_webhook_sync_with_subscription_within_mutation_use_default_db(
order_discount = draft_order.discounts.create(
value_type=DiscountValueType.FIXED,
- value=Decimal("10"),
- amount_value=Decimal("10"),
+ value=Decimal(10),
+ amount_value=Decimal(10),
currency=draft_order.currency,
type=DiscountType.MANUAL,
)
@@ -2461,7 +2461,7 @@ def test_trigger_webhook_sync_with_subscription_within_mutation_use_default_db(
"discountId": graphene.Node.to_global_id("OrderDiscount", order_discount.pk),
"input": {
"valueType": DiscountValueTypeEnum.PERCENTAGE.name,
- "value": Decimal("50"),
+ "value": Decimal(50),
},
}
diff --git a/saleor/product/migrations/0001_initial.py b/saleor/product/migrations/0001_initial.py
index 7b32417745..a905ab0051 100644
--- a/saleor/product/migrations/0001_initial.py
+++ b/saleor/product/migrations/0001_initial.py
@@ -270,7 +270,7 @@ class Migration(migrations.Migration):
(
"quantity",
models.IntegerField(
- default=Decimal("1"),
+ default=Decimal(1),
verbose_name="quantity",
validators=[django.core.validators.MinValueValidator(0)],
),
diff --git a/saleor/product/migrations/0011_stock_quantity_allocated.py b/saleor/product/migrations/0011_stock_quantity_allocated.py
index 37220506c2..485c022a3a 100644
--- a/saleor/product/migrations/0011_stock_quantity_allocated.py
+++ b/saleor/product/migrations/0011_stock_quantity_allocated.py
@@ -14,7 +14,7 @@ class Migration(migrations.Migration):
model_name="stock",
name="quantity_allocated",
field=models.IntegerField(
- default=Decimal("0"),
+ default=Decimal(0),
validators=[django.core.validators.MinValueValidator(0)],
verbose_name="allocated quantity",
),
diff --git a/saleor/product/migrations/0044_auto_20180108_0814.py b/saleor/product/migrations/0044_auto_20180108_0814.py
index 7cc909f60e..01c01e80f3 100644
--- a/saleor/product/migrations/0044_auto_20180108_0814.py
+++ b/saleor/product/migrations/0044_auto_20180108_0814.py
@@ -219,7 +219,7 @@ class Migration(migrations.Migration):
model_name="stock",
name="quantity",
field=models.IntegerField(
- default=Decimal("1"),
+ default=Decimal(1),
validators=[django.core.validators.MinValueValidator(0)],
),
),
@@ -227,7 +227,7 @@ class Migration(migrations.Migration):
model_name="stock",
name="quantity_allocated",
field=models.IntegerField(
- default=Decimal("0"),
+ default=Decimal(0),
validators=[django.core.validators.MinValueValidator(0)],
),
),
diff --git a/saleor/product/migrations/0058_auto_20180329_0142.py b/saleor/product/migrations/0058_auto_20180329_0142.py
index e8d450a04a..b653f8ccde 100644
--- a/saleor/product/migrations/0058_auto_20180329_0142.py
+++ b/saleor/product/migrations/0058_auto_20180329_0142.py
@@ -27,7 +27,7 @@ class Migration(migrations.Migration):
model_name="productvariant",
name="quantity",
field=models.IntegerField(
- default=Decimal("1"),
+ default=Decimal(1),
validators=[django.core.validators.MinValueValidator(0)],
),
),
@@ -35,7 +35,7 @@ class Migration(migrations.Migration):
model_name="productvariant",
name="quantity_allocated",
field=models.IntegerField(
- default=Decimal("0"),
+ default=Decimal(0),
validators=[django.core.validators.MinValueValidator(0)],
),
),
diff --git a/saleor/product/models.py b/saleor/product/models.py
index 12aff54aa6..ac114e37bf 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -621,7 +621,12 @@ class DigitalContentUrl(models.Model):
):
if not self.token:
self.token = str(uuid4()).replace("-", "")
- super().save(force_insert, force_update, using, update_fields)
+ super().save(
+ force_insert=force_insert,
+ force_update=force_update,
+ using=using,
+ update_fields=update_fields,
+ )
def get_absolute_url(self) -> str | None:
url = reverse("digital-product", kwargs={"token": str(self.token)})
diff --git a/saleor/product/tests/test_fetch_variants_for_promotion_rules.py b/saleor/product/tests/test_fetch_variants_for_promotion_rules.py
index a73ea1f3ed..2449cb07dd 100644
--- a/saleor/product/tests/test_fetch_variants_for_promotion_rules.py
+++ b/saleor/product/tests/test_fetch_variants_for_promotion_rules.py
@@ -20,8 +20,8 @@ def test_fetch_variants_for_promotion_rules_discount(
variant = product.variants.first()
promotion = catalogue_promotion_without_rules
- percentage_reward_value = Decimal("10")
- reward_value = Decimal("2")
+ percentage_reward_value = Decimal(10)
+ reward_value = Decimal(2)
rule_1 = promotion.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
@@ -79,7 +79,7 @@ def test_fetch_variants_for_promotion_rules_empty_catalogue_predicate(
# given
promotion = catalogue_promotion_without_rules
- percentage_reward_value = Decimal("10")
+ percentage_reward_value = Decimal(10)
rule_1 = promotion.rules.create(
name="Percentage promotion rule",
catalogue_predicate={},
@@ -102,7 +102,7 @@ def test_fetch_variants_for_promotion_rules_no_applicable_variants(
# given
category.products.clear()
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
rule = catalogue_promotion_without_rules.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
@@ -149,7 +149,7 @@ def test_fetch_variants_for_promotion_rules_discount_race_condition(
existing_variant = product_variant_list[0]
new_variant = product_variant_list[1]
- percentage_reward_value = Decimal("10")
+ percentage_reward_value = Decimal(10)
rule = promotion.rules.create(
name="Percentage promotion rule",
catalogue_predicate={
diff --git a/saleor/product/tests/test_product.py b/saleor/product/tests/test_product.py
index 759b3722a3..ac458b189f 100644
--- a/saleor/product/tests/test_product.py
+++ b/saleor/product/tests/test_product.py
@@ -333,10 +333,10 @@ def test_get_price_overridden_price_with_discount(
price_amount=price_amount,
currency=channel_USD.currency_code,
)
- price_override = Decimal("20")
+ price_override = Decimal(20)
- reward_value_1 = Decimal("10")
- reward_value_2 = Decimal("5")
+ reward_value_1 = Decimal(10)
+ reward_value_2 = Decimal(5)
rule_1, rule_2 = PromotionRule.objects.bulk_create(
[
PromotionRule(
diff --git a/saleor/product/tests/test_product_minimal_variant_price.py b/saleor/product/tests/test_product_minimal_variant_price.py
index 9448c4a8a7..27e19a1d43 100644
--- a/saleor/product/tests/test_product_minimal_variant_price.py
+++ b/saleor/product/tests/test_product_minimal_variant_price.py
@@ -49,7 +49,7 @@ def test_update_discounted_price_for_promotion_discount_on_variant(
variant_channel_listing.save()
product_channel_listing.refresh_from_db()
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
promotion = Promotion.objects.create(
name="Promotion",
)
@@ -97,7 +97,7 @@ def test_update_discounted_price_for_promotion_discount_on_product(
variant_channel_listing.save()
product_channel_listing.refresh_from_db()
- reward_value = Decimal("10")
+ reward_value = Decimal(10)
promotion = Promotion.objects.create(
name="Promotion",
)
@@ -146,8 +146,8 @@ def test_update_discounted_price_for_promotion_discount_multiple_applicable_rule
variant_channel_listing.save()
product_channel_listing.refresh_from_db()
- percentage_reward_value = Decimal("10")
- reward_value = Decimal("2")
+ percentage_reward_value = Decimal(10)
+ reward_value = Decimal(2)
promotion = Promotion.objects.create(
name="Promotion",
)
@@ -260,7 +260,7 @@ def test_update_discounted_price_for_promotion_promotion_not_applicable_for_chan
variant_channel_listing.save()
product_channel_listing.refresh_from_db()
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
promotion = Promotion.objects.create(
name="Promotion",
)
@@ -301,7 +301,7 @@ def test_update_discounted_price_for_promotion_discount_updated(product, channel
variant_channel_listing.save()
product_channel_listing.refresh_from_db()
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
promotion = Promotion.objects.create(
name="Promotion",
)
@@ -322,7 +322,7 @@ def test_update_discounted_price_for_promotion_discount_updated(product, channel
listing_promotion_rule = VariantChannelListingPromotionRule.objects.create(
variant_channel_listing=variant_channel_listing,
promotion_rule=rule,
- discount_amount=Decimal("1"),
+ discount_amount=Decimal(1),
currency=channel_USD.currency_code,
)
@@ -355,7 +355,7 @@ def test_update_discounted_price_for_promotion_discount_not_valid_anymore(
variant_channel_listing.save()
product_channel_listing.refresh_from_db()
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
promotion = Promotion.objects.create(
name="Promotion",
)
@@ -371,7 +371,7 @@ def test_update_discounted_price_for_promotion_discount_not_valid_anymore(
listing_promotion_rule = VariantChannelListingPromotionRule.objects.create(
variant_channel_listing=variant_channel_listing,
promotion_rule=rule,
- discount_amount=Decimal("1"),
+ discount_amount=Decimal(1),
currency=channel_USD.currency_code,
)
@@ -402,8 +402,8 @@ def test_update_discounted_price_for_promotion_discount_one_rule_not_valid_anymo
variant_channel_listing.save()
product_channel_listing.refresh_from_db()
- percentage_reward_value = Decimal("10")
- reward_value = Decimal("2")
+ percentage_reward_value = Decimal(10)
+ reward_value = Decimal(2)
promotion = Promotion.objects.create(
name="Promotion",
)
@@ -434,13 +434,13 @@ def test_update_discounted_price_for_promotion_discount_one_rule_not_valid_anymo
VariantChannelListingPromotionRule(
variant_channel_listing=variant_channel_listing,
promotion_rule=rule_1,
- discount_amount=Decimal("1"),
+ discount_amount=Decimal(1),
currency=channel_USD.currency_code,
),
VariantChannelListingPromotionRule(
variant_channel_listing=variant_channel_listing,
promotion_rule=rule_2,
- discount_amount=Decimal("1"),
+ discount_amount=Decimal(1),
currency=channel_USD.currency_code,
),
]
@@ -499,7 +499,7 @@ def test_update_discounted_price_for_promotion_promotion_rule_deleted_in_meantim
variant_channel_listing.save()
product_channel_listing.refresh_from_db()
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
promotion = Promotion.objects.create(
name="Promotion",
)
@@ -553,7 +553,7 @@ def test_update_discounted_price_rule_deleted_in_meantime_promotion_listing_exis
variant_channel_listing.save()
product_channel_listing.refresh_from_db()
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
promotion = Promotion.objects.create(
name="Promotion",
)
@@ -574,7 +574,7 @@ def test_update_discounted_price_rule_deleted_in_meantime_promotion_listing_exis
listing_promotion_rule = VariantChannelListingPromotionRule.objects.create(
variant_channel_listing=variant_channel_listing,
promotion_rule=rule,
- discount_amount=Decimal("1"),
+ discount_amount=Decimal(1),
currency=channel_USD.currency_code,
)
@@ -626,7 +626,7 @@ def test_update_discounted_prices_for_promotion_only_dirty_products(
variant_channel_listing.save()
product_channel_listing.refresh_from_db()
- reward_value = Decimal("2")
+ reward_value = Decimal(2)
promotion = Promotion.objects.create(
name="Promotion",
)
diff --git a/saleor/product/tests/test_tasks.py b/saleor/product/tests/test_tasks.py
index 4634080e53..697ddd1176 100644
--- a/saleor/product/tests/test_tasks.py
+++ b/saleor/product/tests/test_tasks.py
@@ -78,7 +78,7 @@ def test_update_variant_relations_for_active_promotion_rules_task_when_not_valid
rule = promotion.rules.create(
name="Percentage promotion rule",
reward_value_type=RewardValueType.PERCENTAGE,
- reward_value=Decimal("10"),
+ reward_value=Decimal(10),
catalogue_predicate={
"categoryPredicate": {"metadata": [{"key": "test", "value": "test"}]}
},
diff --git a/saleor/tax/tests/test_checkout_calculations.py b/saleor/tax/tests/test_checkout_calculations.py
index bdc4d14698..6bffaa4a5f 100644
--- a/saleor/tax/tests/test_checkout_calculations.py
+++ b/saleor/tax/tests/test_checkout_calculations.py
@@ -879,7 +879,7 @@ def test_calculate_checkout_line_total_with_voucher_multiple_lines(
checkout.shipping_address = address
checkout.shipping_method_name = method.name
checkout.shipping_method = method
- discount_amount = Decimal("5")
+ discount_amount = Decimal(5)
checkout.discount_amount = discount_amount
checkout.voucher_code = voucher.code
checkout.save()
@@ -951,7 +951,7 @@ def test_calculate_checkout_line_total_with_voucher_multiple_lines_last_line(
checkout.shipping_address = address
checkout.shipping_method_name = method.name
checkout.shipping_method = method
- discount_amount = Decimal("5")
+ discount_amount = Decimal(5)
checkout.discount_amount = discount_amount
checkout.voucher_code = voucher.code
checkout.save()
@@ -1048,7 +1048,7 @@ def test_calculate_checkout_line_total_with_voucher_for_multiple_lines(
checkout.shipping_address = address
checkout.shipping_method_name = method.name
checkout.shipping_method = method
- discount_amount = Decimal("3")
+ discount_amount = Decimal(3)
checkout.discount_amount = discount_amount
checkout.voucher_code = voucher.code
checkout.save()
@@ -1123,7 +1123,7 @@ def test_calculate_checkout_line_total_with_shipping_voucher(
checkout.shipping_address = address
checkout.shipping_method_name = method.name
checkout.shipping_method = method
- checkout.discount_amount = Decimal("5")
+ checkout.discount_amount = Decimal(5)
checkout.voucher_code = voucher_shipping_type.code
checkout.save()
diff --git a/saleor/tax/tests/test_order_calculations.py b/saleor/tax/tests/test_order_calculations.py
index d333269662..8ecc0f47f8 100644
--- a/saleor/tax/tests/test_order_calculations.py
+++ b/saleor/tax/tests/test_order_calculations.py
@@ -861,7 +861,7 @@ def test_use_default_country_rate_when_no_tax_class_was_set_before(
# drop tax classes from lines and shipping, so that default country rate is used
for line in lines:
line.tax_class = None
- line.tax_rate = Decimal("0")
+ line.tax_rate = Decimal(0)
line.tax_class_name = None
line.save(
update_fields=[
@@ -874,7 +874,7 @@ def test_use_default_country_rate_when_no_tax_class_was_set_before(
order.shipping_method.tax_class.delete()
order.shipping_tax_class = None
order.shipping_tax_class_name = None
- order.shipping_tax_rate = Decimal("0")
+ order.shipping_tax_rate = Decimal(0)
order.status = OrderStatus.DRAFT
order.save(
update_fields=[
diff --git a/saleor/tax/tests/test_utils.py b/saleor/tax/tests/test_utils.py
index 6fa3103e15..c99975b2e7 100644
--- a/saleor/tax/tests/test_utils.py
+++ b/saleor/tax/tests/test_utils.py
@@ -144,11 +144,11 @@ def test_get_shipping_tax_rate_for_checkout_weighted_tax(
for line_info in checkout_lines_info:
line_info.line.tax_rate = expected_tax_rate
line_info.line.total_price = TaxedMoney(
- net=Money(Decimal("100"), checkout.currency),
- gross=Money(Decimal("110"), checkout.currency),
+ net=Money(Decimal(100), checkout.currency),
+ gross=Money(Decimal(110), checkout.currency),
)
- default_tax_rate = Decimal("20")
+ default_tax_rate = Decimal(20)
# when
shipping_tax_rate = get_shipping_tax_rate_for_checkout(
@@ -177,38 +177,38 @@ def test_get_shipping_tax_rate_for_checkout_weighted_tax_with_multiple_tax_rates
assert len(checkout_lines_info) == 4
- default_tax_rate = Decimal("20")
+ default_tax_rate = Decimal(20)
# Set different tax rates for lines
# First line: 10% tax rate with $10 tax amount
first_line = checkout_lines_info[0].line
first_line.tax_rate = Decimal("0.1") # 10%
first_line.total_price = TaxedMoney(
- net=Money(Decimal("100"), checkout.currency),
- gross=Money(Decimal("110"), checkout.currency),
+ net=Money(Decimal(100), checkout.currency),
+ gross=Money(Decimal(110), checkout.currency),
)
# Second line: 5% tax rate with $5 tax amount
second_line = checkout_lines_info[1].line
second_line.tax_rate = Decimal("0.05") # 5%
second_line.total_price = TaxedMoney(
- net=Money(Decimal("100"), checkout.currency),
- gross=Money(Decimal("105"), checkout.currency),
+ net=Money(Decimal(100), checkout.currency),
+ gross=Money(Decimal(105), checkout.currency),
)
# Third line: 0% tax rate with $0 tax amount
third_line = checkout_lines_info[2].line
- third_line.tax_rate = Decimal("0") # 0%
+ third_line.tax_rate = Decimal(0) # 0%
third_line.total_price = TaxedMoney(
- net=Money(Decimal("100"), checkout.currency),
- gross=Money(Decimal("100"), checkout.currency),
+ net=Money(Decimal(100), checkout.currency),
+ gross=Money(Decimal(100), checkout.currency),
)
fourth_line = checkout_lines_info[3].line
fourth_line.tax_rate = Decimal("0.2") # 20%
fourth_line.total_price = TaxedMoney(
- net=Money(Decimal("100"), checkout.currency),
- gross=Money(Decimal("120"), checkout.currency),
+ net=Money(Decimal(100), checkout.currency),
+ gross=Money(Decimal(120), checkout.currency),
)
# when
@@ -254,14 +254,14 @@ def test_get_shipping_tax_rate_for_checkout_when_weighted_tax_is_disabled(
first_line = checkout_lines_info[0].line
first_line.tax_rate = Decimal("0.1") # 10%
first_line.total_price = TaxedMoney(
- net=Money(Decimal("100"), checkout.currency),
- gross=Money(Decimal("110"), checkout.currency),
+ net=Money(Decimal(100), checkout.currency),
+ gross=Money(Decimal(110), checkout.currency),
)
first_line.save(
update_fields=["tax_rate", "total_price_net_amount", "total_price_gross_amount"]
)
- default_tax_rate = Decimal("20") # 20%
+ default_tax_rate = Decimal(20) # 20%
# when
shipping_tax_rate = get_shipping_tax_rate_for_checkout(
@@ -288,7 +288,7 @@ def test_get_shipping_tax_rate_for_order_weighted_tax(
update_fields=["use_weighted_tax_for_shipping", "tax_calculation_strategy"]
)
- default_tax_rate = Decimal("20")
+ default_tax_rate = Decimal(20)
lines = list(order.lines.all())
country = get_order_country(order)
@@ -297,8 +297,8 @@ def test_get_shipping_tax_rate_for_order_weighted_tax(
for line in lines:
line.tax_rate = expected_tax_rate
line.total_price = TaxedMoney(
- net=Money(Decimal("100"), order.currency),
- gross=Money(Decimal("110"), order.currency),
+ net=Money(Decimal(100), order.currency),
+ gross=Money(Decimal(110), order.currency),
)
# when
@@ -329,7 +329,7 @@ def test_get_shipping_tax_rate_for_order_weighted_tax_with_multiple_tax_rates(
lines = list(order.lines.all())
assert len(lines) == 2
- default_tax_rate = Decimal("20")
+ default_tax_rate = Decimal(20)
country = get_order_country(order)
# Set different tax rates for lines
@@ -337,8 +337,8 @@ def test_get_shipping_tax_rate_for_order_weighted_tax_with_multiple_tax_rates(
first_line = lines[0]
first_line.tax_rate = Decimal("0.1") # 10%
first_line.total_price = TaxedMoney(
- net=Money(Decimal("100"), order.currency),
- gross=Money(Decimal("110"), order.currency),
+ net=Money(Decimal(100), order.currency),
+ gross=Money(Decimal(110), order.currency),
)
first_line.save(
update_fields=["tax_rate", "total_price_net_amount", "total_price_gross_amount"]
@@ -348,8 +348,8 @@ def test_get_shipping_tax_rate_for_order_weighted_tax_with_multiple_tax_rates(
second_line = lines[1]
second_line.tax_rate = Decimal("0.05") # 5%
second_line.total_price = TaxedMoney(
- net=Money(Decimal("100"), order.currency),
- gross=Money(Decimal("105"), order.currency),
+ net=Money(Decimal(100), order.currency),
+ gross=Money(Decimal(105), order.currency),
)
second_line.save(
update_fields=["tax_rate", "total_price_net_amount", "total_price_gross_amount"]
@@ -391,14 +391,14 @@ def test_get_shipping_tax_rate_for_order_when_weighted_tax_is_disabled(
first_line = lines[0]
first_line.tax_rate = Decimal("0.1") # 10%
first_line.total_price = TaxedMoney(
- net=Money(Decimal("100"), order.currency),
- gross=Money(Decimal("110"), order.currency),
+ net=Money(Decimal(100), order.currency),
+ gross=Money(Decimal(110), order.currency),
)
first_line.save(
update_fields=["tax_rate", "total_price_net_amount", "total_price_gross_amount"]
)
- default_tax_rate = Decimal("20") # 20%
+ default_tax_rate = Decimal(20) # 20%
order.shipping_tax_class = default_tax_class
# when
diff --git a/saleor/warehouse/availability.py b/saleor/warehouse/availability.py
index 4456efd435..7cb8a62ac1 100644
--- a/saleor/warehouse/availability.py
+++ b/saleor/warehouse/availability.py
@@ -295,7 +295,7 @@ def check_stock_quantity_bulk(
quantity += variants_quantities.get(variant.pk, 0)
stocks = variant_stocks.get(variant.pk, [])
- available_quantity = sum([stock.available_quantity for stock in stocks])
+ available_quantity = sum([stock.available_quantity for stock in stocks]) # type: ignore[attr-defined]
available_quantity = max(
available_quantity - variant_reservations[variant.pk], 0
)
diff --git a/saleor/webhook/payloads.py b/saleor/webhook/payloads.py
index a28a7ab22f..1a8f6ddd18 100644
--- a/saleor/webhook/payloads.py
+++ b/saleor/webhook/payloads.py
@@ -713,7 +713,7 @@ def _get_charge_taxes_for_product(product: "Product") -> bool:
if tax_class_id:
charge_taxes = (
TaxClassCountryRate.objects.filter(tax_class_id=tax_class_id)
- .exclude(rate=Decimal("0"))
+ .exclude(rate=Decimal(0))
.exists()
)
return charge_taxes
diff --git a/saleor/webhook/response_schemas/shipping.py b/saleor/webhook/response_schemas/shipping.py
index e68c297a75..0d07a7a14d 100644
--- a/saleor/webhook/response_schemas/shipping.py
+++ b/saleor/webhook/response_schemas/shipping.py
@@ -37,7 +37,7 @@ class ShippingMethodSchema(BaseModel):
amount: Annotated[
Decimal,
Field(
- ge=Decimal("0"),
+ ge=Decimal(0),
description="Non-negative price the customer pays for delivery using this shipping method.",
examples=[Decimal("10.00")],
),
diff --git a/saleor/webhook/response_schemas/utils/annotations.py b/saleor/webhook/response_schemas/utils/annotations.py
index 4b1c6c2eed..26ecce249b 100644
--- a/saleor/webhook/response_schemas/utils/annotations.py
+++ b/saleor/webhook/response_schemas/utils/annotations.py
@@ -26,7 +26,7 @@ logger = logging.getLogger(__name__)
logger = logging.getLogger(__name__)
-def skip_invalid_metadata(value: M) -> M:
+def skip_invalid_metadata[M](value: M) -> M:
if not metadata_is_valid(value):
raise PydanticUseDefault()
return value
@@ -94,7 +94,7 @@ OnErrorDefault = Annotated[T, WrapValidator(default_if_invalid)]
DatetimeUTC = Annotated[datetime, AfterValidator(lambda v: v.astimezone(UTC))]
-def skip_invalid_literal(value: T, handler: ValidatorFunctionWrapHandler) -> T:
+def skip_invalid_literal[T](value: T, handler: ValidatorFunctionWrapHandler) -> T:
try:
return handler(value)
except ValidationError as err:
diff --git a/saleor/webhook/serializers.py b/saleor/webhook/serializers.py
index 536b561160..c5334042a6 100644
--- a/saleor/webhook/serializers.py
+++ b/saleor/webhook/serializers.py
@@ -31,7 +31,7 @@ def serialize_checkout_lines(checkout: "Checkout") -> list[dict]:
base_price = line_info.undiscounted_unit_price
total_discount_amount_for_line = sum(
[discount.amount_value for discount in line_info.get_promotion_discounts()],
- Decimal("0"),
+ Decimal(0),
)
if total_discount_amount_for_line:
unit_discount_amount = (
diff --git a/saleor/webhook/tests/response_schemas/test_taxes.py b/saleor/webhook/tests/response_schemas/test_taxes.py
index 0018b7e129..97d5a55573 100644
--- a/saleor/webhook/tests/response_schemas/test_taxes.py
+++ b/saleor/webhook/tests/response_schemas/test_taxes.py
@@ -89,7 +89,7 @@ def test_line_calculate_taxes_schema_valid(data):
{
"tax_rate": Decimal("20.00"),
"total_gross_amount": Decimal("100.00"),
- "total_net_amount": Decimal("100000000000000000000"),
+ "total_net_amount": Decimal(100000000000000000000),
},
],
)
diff --git a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_payment_gateway_initialize_session.py b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_payment_gateway_initialize_session.py
index a51cee9421..7a2e2b4fb8 100644
--- a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_payment_gateway_initialize_session.py
+++ b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_payment_gateway_initialize_session.py
@@ -45,7 +45,7 @@ def test_payment_gateway_initialize_session_checkout_with_data(
event_type = WebhookEventSyncType.PAYMENT_GATEWAY_INITIALIZE_SESSION
webhook.events.create(event_type=event_type)
payload_data = {"some": "json data"}
- amount = Decimal("10")
+ amount = Decimal(10)
# when
delivery = create_deliveries_for_subscriptions(
@@ -80,7 +80,7 @@ def test_payment_gateway_initialize_session_checkout_without_data(
event_type = WebhookEventSyncType.PAYMENT_GATEWAY_INITIALIZE_SESSION
webhook.events.create(event_type=event_type)
payload_data = None
- amount = Decimal("10")
+ amount = Decimal(10)
# when
delivery = create_deliveries_for_subscriptions(
event_type, (checkout, payload_data, amount), [webhook]
@@ -113,7 +113,7 @@ def test_payment_gateway_initialize_session_order_with_data(
event_type = WebhookEventSyncType.PAYMENT_GATEWAY_INITIALIZE_SESSION
webhook.events.create(event_type=event_type)
payload_data = {"some": "json data"}
- amount = Decimal("10")
+ amount = Decimal(10)
# when
delivery = create_deliveries_for_subscriptions(
@@ -144,7 +144,7 @@ def test_payment_gateway_initialize_session_order_without_data(
event_type = WebhookEventSyncType.PAYMENT_GATEWAY_INITIALIZE_SESSION
webhook.events.create(event_type=event_type)
payload_data = None
- amount = Decimal("10")
+ amount = Decimal(10)
# when
delivery = create_deliveries_for_subscriptions(
diff --git a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_subscription.py b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_subscription.py
index a95bc1aa11..b0d084a14e 100644
--- a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_subscription.py
+++ b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_subscription.py
@@ -1885,8 +1885,8 @@ def test_fulfillment_with_refund_amounts(
fulfillment, subscription_fulfillment_created_webhook
):
# given
- shipping_refund = Decimal("10")
- total_refund = Decimal("15")
+ shipping_refund = Decimal(10)
+ total_refund = Decimal(15)
fulfillment.shipping_refund_amount = shipping_refund
fulfillment.total_refund_amount = total_refund
fulfillment.save()
diff --git a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_taxes.py b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_taxes.py
index 4c1244b6bd..66bbb561a0 100644
--- a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_taxes.py
+++ b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_taxes.py
@@ -643,7 +643,7 @@ def test_draft_order_calculate_taxes_line_discount(
]
)
- discount_value = Decimal("5")
+ discount_value = Decimal(5)
update_discount_for_order_line(
order_line, order, "test discount", DiscountValueType.FIXED, discount_value
)
@@ -718,7 +718,7 @@ def test_draft_order_calculate_taxes_entire_order_voucher(
voucher.type = VoucherType.ENTIRE_ORDER
voucher.save(update_fields=["type"])
- discount_amount = Decimal("10")
+ discount_amount = Decimal(10)
channel_listing = voucher.channel_listings.get()
channel_listing.discount_value = discount_amount
channel_listing.save(update_fields=["discount_value"])
@@ -810,7 +810,7 @@ def test_draft_order_calculate_taxes_apply_once_per_order_voucher(
voucher.apply_once_per_order = True
voucher.save(update_fields=["type", "apply_once_per_order"])
- discount_amount = Decimal("10")
+ discount_amount = Decimal(10)
order_discount = order.discounts.first()
order_discount.value = discount_amount
order_discount.save(update_fields=["value"])
@@ -920,7 +920,7 @@ def test_order_calculate_taxes_specific_product_voucher(
voucher_listing = voucher_specific_product_type.channel_listings.get(
channel=order.channel
)
- unit_discount_amount = Decimal("2")
+ unit_discount_amount = Decimal(2)
voucher_listing.discount_value = unit_discount_amount
voucher_listing.save(update_fields=["discount_value"])
voucher_specific_product_type.variants.add(order_line.variant)
@@ -1031,7 +1031,7 @@ def test_order_calculate_taxes_with_manual_discount(
order = order_with_lines
shipping_price_amount = order.base_shipping_price_amount
- discount_value = Decimal("20")
+ discount_value = Decimal(20)
order.discounts.create(
value_type=DiscountValueType.FIXED,
value=discount_value,
diff --git a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_cancelation_requested.py b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_cancelation_requested.py
index 2a5e04d16e..09bbc2dbb1 100644
--- a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_cancelation_requested.py
+++ b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_cancelation_requested.py
@@ -40,7 +40,7 @@ def test_order_transaction_cancel_request(
order, webhook_app, permission_manage_payments
):
# given
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
webhook_app.permissions.add(permission_manage_payments)
transaction = TransactionItem.objects.create(
name="Credit card",
@@ -116,7 +116,7 @@ def test_checkout_transaction_cancel_request(
# given
checkout_with_items.price_expiration = timezone.now() - timezone.timedelta(hours=10)
checkout_with_items.save()
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
webhook_app.permissions.add(permission_manage_payments)
transaction = TransactionItem.objects.create(
name="Credit card",
diff --git a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_charge_requested.py b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_charge_requested.py
index 9f823ca50b..ae5a3726ef 100644
--- a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_charge_requested.py
+++ b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_charge_requested.py
@@ -40,7 +40,7 @@ def test_order_transaction_charge_request(
order, webhook_app, permission_manage_payments
):
# given
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
webhook_app.permissions.add(permission_manage_payments)
transaction = TransactionItem.objects.create(
name="Credit card",
@@ -117,7 +117,7 @@ def test_checkout_transaction_charge_request(
# given
checkout_with_items.price_expiration = timezone.now() - timezone.timedelta(hours=10)
checkout_with_items.save()
- authorized_value = Decimal("10")
+ authorized_value = Decimal(10)
webhook_app.permissions.add(permission_manage_payments)
transaction = TransactionItem.objects.create(
name="Credit card",
diff --git a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_initialize_session.py b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_initialize_session.py
index f45fee69a1..f82d4b25f8 100644
--- a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_initialize_session.py
+++ b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_initialize_session.py
@@ -73,7 +73,7 @@ def test_transaction_initialize_session_checkout_with_data(
event_type = WebhookEventSyncType.TRANSACTION_INITIALIZE_SESSION
webhook.events.create(event_type=event_type)
payload_data = {"some": "json data"}
- amount = Decimal("10")
+ amount = Decimal(10)
transaction = transaction_item_generator(
checkout_id=checkout.pk,
app=webhook_app,
@@ -143,7 +143,7 @@ def test_transaction_initialize_session_checkout_without_data(
event_type = WebhookEventSyncType.TRANSACTION_INITIALIZE_SESSION
webhook.events.create(event_type=event_type)
payload_data = None
- amount = Decimal("10")
+ amount = Decimal(10)
transaction = transaction_item_generator(
checkout_id=checkout.pk,
@@ -213,7 +213,7 @@ def test_transaction_initialize_session_order_with_data(
event_type = WebhookEventSyncType.TRANSACTION_INITIALIZE_SESSION
webhook.events.create(event_type=event_type)
payload_data = {"some": "json data"}
- amount = Decimal("10")
+ amount = Decimal(10)
transaction = transaction_item_generator(
order_id=order.pk,
@@ -283,7 +283,7 @@ def test_transaction_initialize_session_order_without_data(
event_type = WebhookEventSyncType.TRANSACTION_INITIALIZE_SESSION
webhook.events.create(event_type=event_type)
payload_data = None
- amount = Decimal("10")
+ amount = Decimal(10)
transaction = transaction_item_generator(
order_id=order.pk,
@@ -352,7 +352,7 @@ def test_transaction_initialize_session_empty_customer_ip_addess(
event_type = WebhookEventSyncType.TRANSACTION_INITIALIZE_SESSION
webhook.events.create(event_type=event_type)
payload_data = None
- amount = Decimal("10")
+ amount = Decimal(10)
transaction = transaction_item_generator(
order_id=order.pk,
diff --git a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_process_session.py b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_process_session.py
index 63f9c957ea..9a3e70531e 100644
--- a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_process_session.py
+++ b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_process_session.py
@@ -70,7 +70,7 @@ def test_transaction_process_session_checkout_with_data(
event_type = WebhookEventSyncType.TRANSACTION_PROCESS_SESSION
webhook.events.create(event_type=event_type)
payload_data = {"some": "json data"}
- amount = Decimal("10")
+ amount = Decimal(10)
transaction = transaction_item_generator(
checkout_id=checkout.pk,
app=webhook_app,
@@ -137,7 +137,7 @@ def test_transaction_process_session_checkout_without_data(
event_type = WebhookEventSyncType.TRANSACTION_PROCESS_SESSION
webhook.events.create(event_type=event_type)
payload_data = None
- amount = Decimal("10")
+ amount = Decimal(10)
transaction = transaction_item_generator(
checkout_id=checkout.pk,
@@ -211,7 +211,7 @@ def test_transaction_process_session_order_with_data(
event_type = WebhookEventSyncType.TRANSACTION_PROCESS_SESSION
webhook.events.create(event_type=event_type)
payload_data = {"some": "json data"}
- amount = Decimal("10")
+ amount = Decimal(10)
transaction = transaction_item_generator(
order_id=order.pk,
@@ -278,7 +278,7 @@ def test_transaction_process_session_order_without_data(
event_type = WebhookEventSyncType.TRANSACTION_PROCESS_SESSION
webhook.events.create(event_type=event_type)
payload_data = None
- amount = Decimal("10")
+ amount = Decimal(10)
transaction = transaction_item_generator(
order_id=order.pk,
@@ -344,7 +344,7 @@ def test_transaction_process_session_empty_customer_ip_address(
event_type = WebhookEventSyncType.TRANSACTION_PROCESS_SESSION
webhook.events.create(event_type=event_type)
payload_data = None
- amount = Decimal("10")
+ amount = Decimal(10)
transaction = transaction_item_generator(
order_id=order.pk,
diff --git a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_refund_requested.py b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_refund_requested.py
index fa9b30e29d..b91d449a6e 100644
--- a/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_refund_requested.py
+++ b/saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_refund_requested.py
@@ -76,7 +76,7 @@ def test_order_transaction_refund_request(
order, webhook_app, permission_manage_payments
):
# given
- charged_value = Decimal("10")
+ charged_value = Decimal(10)
webhook_app.permissions.add(permission_manage_payments)
transaction = TransactionItem.objects.create(
name="Credit card",
@@ -153,7 +153,7 @@ def test_checkout_transaction_refund_request(
# given
checkout_with_items.price_expiration = timezone.now() - timezone.timedelta(hours=10)
checkout_with_items.save()
- charged_value = Decimal("10")
+ charged_value = Decimal(10)
webhook_app.permissions.add(permission_manage_payments)
transaction = TransactionItem.objects.create(
name="Credit card",
@@ -239,7 +239,7 @@ def test_transaction_refund_request_with_granted_refund(
order_with_lines, webhook_app, permission_manage_payments
):
# given
- charged_value = Decimal("10")
+ charged_value = Decimal(10)
webhook_app.permissions.add(permission_manage_payments)
transaction = TransactionItem.objects.create(
name="Credit card",
diff --git a/saleor/webhook/tests/test_tasks.py b/saleor/webhook/tests/test_tasks.py
index 8e623f3bdb..d3ccb657d2 100644
--- a/saleor/webhook/tests/test_tasks.py
+++ b/saleor/webhook/tests/test_tasks.py
@@ -1093,7 +1093,7 @@ def test_handle_transaction_request_task_request_event_included_in_calculations(
app,
):
# given
- transaction = transaction_item_generator(charged_value=Decimal("100"))
+ transaction = transaction_item_generator(charged_value=Decimal(100))
expected_psp_reference = "psp:ref:123"
mocked_webhook_response.text = json.dumps({"pspReference": expected_psp_reference})
mocked_webhook_response.content = json.dumps(
diff --git a/saleor/webhook/tests/test_webhook_payloads.py b/saleor/webhook/tests/test_webhook_payloads.py
index 2feab2ca3c..4418e94e00 100644
--- a/saleor/webhook/tests/test_webhook_payloads.py
+++ b/saleor/webhook/tests/test_webhook_payloads.py
@@ -87,14 +87,14 @@ def order_for_payload(fulfilled_order, voucher_percentage):
order.discounts.create(
type=DiscountType.MANUAL,
value_type=DiscountValueType.PERCENTAGE,
- value=Decimal("20"),
+ value=Decimal(20),
amount_value=Decimal("33.0"),
reason="Discount from staff",
)
discount = order.discounts.create(
type=DiscountType.VOUCHER,
value_type=DiscountValueType.PERCENTAGE,
- value=Decimal("10"),
+ value=Decimal(10),
amount_value=Decimal("16.5"),
name="Voucher",
voucher=voucher_percentage,
@@ -2683,7 +2683,7 @@ def test_generate_transaction_action_request_payload_for_order(
available_actions=["capture", "cancel"],
currency="USD",
order_id=order.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
)
requested_event = transaction.events.create(
currency=transaction.currency,
@@ -2771,7 +2771,7 @@ def test_generate_transaction_action_request_payload_for_checkout(
available_actions=["capture", "cancel"],
currency="USD",
checkout_id=checkout.pk,
- authorized_value=Decimal("10"),
+ authorized_value=Decimal(10),
)
requested_event = transaction.events.create(
currency=transaction.currency,