Skip to content

Commit 403a364

Browse files
committed
anaother call
1 parent ac0d839 commit 403a364

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/viur/shop/types/price.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from viur import toolkit
66
from viur.core import current, db, utils
77
from viur.core.skeleton import SkeletonInstance
8-
98
from .enums import ApplicationDomain, ConditionOperator, DiscountType
9+
from .exceptions import InvalidStateError
1010
from ..globals import SHOP_INSTANCE, SHOP_LOGGER
1111
from ..types import ConfigurationError, DiscountValidationContext
1212

@@ -51,6 +51,9 @@ def __init__(self, src_object):
5151
raise TypeError(f"Unsupported type {type(src_object)}")
5252

5353
# logger.debug(f"{self.article_skel = }")
54+
# logger.debug(f"{self.article_skel.renderPreparation=} | {hex(id(self.article_skel))}")
55+
if self.article_skel.renderPreparation is not None:
56+
raise InvalidStateError("ArticleSkel must not have renderPreparation")
5457

5558
if (best_discount := self.shop_current_discount(self.article_skel)) is not None:
5659
price, skel = best_discount
@@ -179,8 +182,11 @@ def vat_rate_percentage(self) -> float:
179182
:returns: value as float (0.0 <= value <= 1.0)
180183
"""
181184
try:
185+
# FIXME: self.article_skel has here sometimes renderPreparation set,
186+
# but toolkit.without_render_preparation is already called in __init__
187+
# What's going on here?
182188
vat_rate = SHOP_INSTANCE.get().vat_rate.get_vat_rate_for_country(
183-
category=self.article_skel["shop_vat_rate_category"],
189+
category=toolkit.without_render_preparation(self.article_skel)["shop_vat_rate_category"],
184190
)
185191
except ConfigurationError as e: # TODO(discussion): Or re-raise or implement fallback?
186192
logger.warning(f"No vat rate for article :: {e}")

0 commit comments

Comments
 (0)