P5-4783 add different designer pricepremium for each product group

This commit is contained in:
Martin Carlsson
2020-02-24 10:07:43 +01:00
committed by GitHub
parent b6437b3d25
commit fcf79ca75a
5 changed files with 63 additions and 63 deletions
+6 -6
View File
@@ -6,7 +6,7 @@ from api.lib.limits import calculate_canvas_limits
from api.lib import pwinty
def m2_price(
def wallpaper_m2_price(
material,
market,
designer=None,
@@ -19,7 +19,7 @@ def m2_price(
price = material.price / 100.0
if designer:
price *= (float(designer.pricepremium) / 100) + 1
price *= (float(designer.pricepremium_wallpaper) / 100) + 1
if reseller:
price *= (float(reseller.pricepremium) / 100) + 1
@@ -50,7 +50,7 @@ def wallpaper_price(
rounded=True,
inc_vat=True,
):
price = m2_price(
price = wallpaper_m2_price(
material, market, designer, reseller, inquiry, rounded=False, inc_vat=False
)
@@ -135,7 +135,7 @@ def canvas_price(
price *= market.price_adjustments
if designer:
price *= (float(designer.pricepremium) / 100) + 1
price *= (float(designer.pricepremium_canvas) / 100) + 1
if reseller:
price *= (float(reseller.pricepremium) / 100) + 1
@@ -232,7 +232,7 @@ def poster_price(
price *= market.price_adjustments
if designer:
price *= (float(designer.pricepremium) / 100) + 1
price *= (float(designer.pricepremium_poster) / 100) + 1
if reseller:
price *= (float(reseller.pricepremium) / 100) + 1
@@ -416,7 +416,7 @@ def framed_print_price(
price *= market.price_adjustments
if designer:
price *= (float(designer.pricepremium) / 100) + 1
price *= (float(designer.pricepremium_framed_print) / 100) + 1
if reseller:
price *= (float(reseller.pricepremium) / 100) + 1
+4 -1
View File
@@ -21,7 +21,10 @@ class Designer(db.Model):
visible_list = db.Column(db.Integer(), nullable=False, default=1)
visible_productpage = db.Column(db.Integer(), nullable=False, default=1)
visible_search = db.Column(db.Integer(), nullable=False, default=1)
pricepremium = db.Column(db.Numeric(), nullable=False, default=0)
pricepremium_wallpaper = db.Column(db.Numeric(), nullable=False, default=0)
pricepremium_canvas = db.Column(db.Numeric(), nullable=False, default=0)
pricepremium_poster = db.Column(db.Numeric(), nullable=False, default=0)
pricepremium_framed_print = db.Column(db.Numeric(), nullable=False, default=0)
def __init__(self, name, username, territory, currency, *args, **kwargs):
super(Designer, self).__init__(*args, **kwargs)
+6 -6
View File
@@ -13,7 +13,7 @@ from api.lib.prices import (
poster_price,
poster_hanger_price,
framed_print_price,
m2_price,
wallpaper_m2_price,
inquiry_price,
)
from api.lib.limits import calculate_canvas_limits
@@ -56,7 +56,7 @@ def wallpaper():
{
"material": material.name,
"material_id": material.id,
"m2_price": m2_price(
"m2_price": wallpaper_m2_price(
material,
market,
reseller=reseller,
@@ -64,7 +64,7 @@ def wallpaper():
rounded=False,
inc_vat=True,
),
"m2_price_excl_vat": m2_price(
"m2_price_excl_vat": wallpaper_m2_price(
material,
market,
reseller=reseller,
@@ -311,7 +311,7 @@ def inquiry_wallpaper(inquiry):
{
"material": material.name,
"material_id": material.id,
"m2_price": m2_price(
"m2_price": wallpaper_m2_price(
material,
inquiry.market,
designer=inquiry.designer,
@@ -320,7 +320,7 @@ def inquiry_wallpaper(inquiry):
rounded=False,
inc_vat=True,
),
"m2_price_excl_vat": m2_price(
"m2_price_excl_vat": wallpaper_m2_price(
material,
inquiry.market,
designer=inquiry.designer,
@@ -555,7 +555,7 @@ def list_prices_wallpaper(territory):
market = market_model.from_territory(territory)
for wallpaper in wallpapers:
result[wallpaper.id] = m2_price(
result[wallpaper.id] = wallpaper_m2_price(
material=material, market=market, designer=wallpaper.product.designer
)
return jsonify(result)