Price adjustment config (#54)
This commit is contained in:
+14
-2
@@ -1,10 +1,15 @@
|
|||||||
# coding=UTF-8
|
# coding=UTF-8
|
||||||
""" Price formulas """
|
""" Price formulas """
|
||||||
|
import yaml
|
||||||
from api.lib.utils import round_half_up
|
from api.lib.utils import lru_with_ttl, round_half_up
|
||||||
from api.models.external_print_product import get_external_print_product
|
from api.models.external_print_product import get_external_print_product
|
||||||
|
|
||||||
|
|
||||||
|
@lru_with_ttl(ttl_seconds=3600)
|
||||||
|
def get_adjustment_config():
|
||||||
|
with open("api/resources/price-adjustments.yaml") as f:
|
||||||
|
return yaml.load(f, Loader=yaml.FullLoader)
|
||||||
|
|
||||||
def wallpaper_m2_price(
|
def wallpaper_m2_price(
|
||||||
material,
|
material,
|
||||||
market,
|
market,
|
||||||
@@ -29,6 +34,13 @@ def wallpaper_m2_price(
|
|||||||
price *= market.exchange_rate
|
price *= market.exchange_rate
|
||||||
price *= market.price_adjustments
|
price *= market.price_adjustments
|
||||||
|
|
||||||
|
adjustment_config = get_adjustment_config()
|
||||||
|
|
||||||
|
inquiry_or_product_key = "product" if inquiry is None else "inquiry"
|
||||||
|
|
||||||
|
adj_value = adjustment_config.get(material.name).get(inquiry_or_product_key).get(market.name, 1.0)
|
||||||
|
price *= adj_value
|
||||||
|
|
||||||
if inc_vat:
|
if inc_vat:
|
||||||
price *= market.vat
|
price *= market.vat
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
standard-wallpaper:
|
||||||
|
inquiry:
|
||||||
|
IT: 1.1034
|
||||||
|
GB: 1.1154
|
||||||
|
DE: 1.0625
|
||||||
|
product:
|
||||||
|
GB: 1.1154
|
||||||
|
DE: 1.0625
|
||||||
|
premium-wallpaper:
|
||||||
|
inquiry:
|
||||||
|
IT: 1.1250
|
||||||
|
SE: 1.0462
|
||||||
|
GB: 1.1034
|
||||||
|
DE: 1.1143
|
||||||
|
NL: 1.0833
|
||||||
|
product:
|
||||||
|
GB: 1.1034
|
||||||
|
DE: 1.1143
|
||||||
|
SE: 1.0462
|
||||||
|
NL: 1.0833
|
||||||
@@ -22,3 +22,4 @@ python-dateutil==2.8.1
|
|||||||
s3transfer==0.3.3
|
s3transfer==0.3.3
|
||||||
six==1.14.0
|
six==1.14.0
|
||||||
urllib3==1.25.8
|
urllib3==1.25.8
|
||||||
|
PyYAML==6.0
|
||||||
|
|||||||
Reference in New Issue
Block a user