|
5 | 5 | from viur import toolkit |
6 | 6 | from viur.core import current, db, utils |
7 | 7 | from viur.core.skeleton import SkeletonInstance |
8 | | - |
9 | 8 | from .enums import ApplicationDomain, ConditionOperator, DiscountType |
| 9 | +from .exceptions import InvalidStateError |
10 | 10 | from ..globals import SHOP_INSTANCE, SHOP_LOGGER |
11 | 11 | from ..types import ConfigurationError, DiscountValidationContext |
12 | 12 |
|
@@ -51,6 +51,9 @@ def __init__(self, src_object): |
51 | 51 | raise TypeError(f"Unsupported type {type(src_object)}") |
52 | 52 |
|
53 | 53 | # 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") |
54 | 57 |
|
55 | 58 | if (best_discount := self.shop_current_discount(self.article_skel)) is not None: |
56 | 59 | price, skel = best_discount |
@@ -179,8 +182,11 @@ def vat_rate_percentage(self) -> float: |
179 | 182 | :returns: value as float (0.0 <= value <= 1.0) |
180 | 183 | """ |
181 | 184 | 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? |
182 | 188 | 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"], |
184 | 190 | ) |
185 | 191 | except ConfigurationError as e: # TODO(discussion): Or re-raise or implement fallback? |
186 | 192 | logger.warning(f"No vat rate for article :: {e}") |
|
0 commit comments