make pricedb currency mandatory
now, if there is a price entry for an ingredient, it either has to have a currency specified or default_currency has to be set in settings.yaml
This commit is contained in:
parent
70432d867e
commit
7a9a39f2fb
1 changed files with 3 additions and 1 deletions
|
@ -564,7 +564,7 @@ class PriceDB(Element):
|
|||
price: float,
|
||||
amount: float,
|
||||
unit: Unit,
|
||||
currency: Optional[str],
|
||||
currency: str,
|
||||
) -> None:
|
||||
super().__init__(ctx)
|
||||
self.price = price
|
||||
|
@ -591,4 +591,6 @@ class PriceDB(Element):
|
|||
currency = ctx.settings.default_currency
|
||||
if "currency" in dct:
|
||||
currency = dct["currency"]
|
||||
if currency is None:
|
||||
raise RuntimeError("currency not specified and default_currency is also not set")
|
||||
return cls(ctx=ctx, price=price, amount=amount, unit=unit, currency=currency)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue