P5-7013 Move wallpaperkit price to api (#38)
This commit is contained in:
@@ -511,3 +511,25 @@ def inquiry_price(
|
|||||||
price = round_half_up(price)
|
price = round_half_up(price)
|
||||||
|
|
||||||
return price
|
return price
|
||||||
|
|
||||||
|
def wallpaper_kit_price(
|
||||||
|
market, reseller=None, rounded=True, inc_vat=True
|
||||||
|
):
|
||||||
|
# Hardcode price as it hasn't been updated for a long time
|
||||||
|
# price from "product-stockprices"
|
||||||
|
price = 143.2
|
||||||
|
|
||||||
|
price *= market.price_adjustments
|
||||||
|
|
||||||
|
if reseller:
|
||||||
|
price *= (float(reseller.pricepremium) / 100) + 1
|
||||||
|
|
||||||
|
price *= market.exchange_rate
|
||||||
|
|
||||||
|
if inc_vat:
|
||||||
|
price *= market.vat
|
||||||
|
|
||||||
|
if rounded:
|
||||||
|
price = round_half_up(price)
|
||||||
|
|
||||||
|
return price
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from api.lib.prices import (
|
|||||||
framed_print_price,
|
framed_print_price,
|
||||||
wallpaper_m2_price,
|
wallpaper_m2_price,
|
||||||
inquiry_price,
|
inquiry_price,
|
||||||
|
wallpaper_kit_price,
|
||||||
)
|
)
|
||||||
from api.lib.limits import calculate_canvas_limits
|
from api.lib.limits import calculate_canvas_limits
|
||||||
|
|
||||||
@@ -226,6 +227,25 @@ def diy_frame():
|
|||||||
return jsonify(data=data)
|
return jsonify(data=data)
|
||||||
|
|
||||||
|
|
||||||
|
@mod.route("/wallpaper-kit", methods=["GET"])
|
||||||
|
@validate_exists("market")
|
||||||
|
def wallpaper_kit():
|
||||||
|
market_id = request.args.get("market", type=int)
|
||||||
|
market = Market.query.get_or_404(market_id)
|
||||||
|
reseller = get_reseller()
|
||||||
|
|
||||||
|
data = [
|
||||||
|
{
|
||||||
|
"price": wallpaper_kit_price(market, reseller=reseller, rounded=False),
|
||||||
|
"price_excl_vat": wallpaper_kit_price(
|
||||||
|
market, reseller=reseller, rounded=False, inc_vat=False
|
||||||
|
),
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
return jsonify(data=data)
|
||||||
|
|
||||||
|
|
||||||
@mod.route("/poster-hanger", methods=["GET"])
|
@mod.route("/poster-hanger", methods=["GET"])
|
||||||
@validate_number("width")
|
@validate_number("width")
|
||||||
@validate_exists("market")
|
@validate_exists("market")
|
||||||
|
|||||||
@@ -291,3 +291,31 @@ Sample response
|
|||||||
"retouch_price": 0
|
"retouch_price": 0
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Calculate wallpaper kit price
|
||||||
|
|
||||||
|
Calculate the price for a wallpaper kit
|
||||||
|
|
||||||
|
| Parameter | Description |
|
||||||
|
| --------- | ------------|
|
||||||
|
| `market` | Market id e.g `1` for sweden. Markets affect the price in different ways like VAT, currency exchanges etc. |
|
||||||
|
| `dealerurl` | Optional parameter e.g `ackes`. Should always be used when calling the api from a dealerstore. If a dealerstore exists with this url additional fees will be applied to the price. |
|
||||||
|
|
||||||
|
|
||||||
|
Sample request
|
||||||
|
|
||||||
|
`curl -X GET 'https://api.photowall.com/prices/wallpaper-kit?market=4`
|
||||||
|
|
||||||
|
Sample response
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"price": 166.46999999999997,
|
||||||
|
"price_excl_vat": 133.176
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -491,3 +491,9 @@ class TestPrice(unittest2.TestCase):
|
|||||||
framed_print_price(sku="invalid", market=sweden)
|
framed_print_price(sku="invalid", market=sweden)
|
||||||
|
|
||||||
self.assertTrue("Invalid SKU number" in str(context.exception))
|
self.assertTrue("Invalid SKU number" in str(context.exception))
|
||||||
|
|
||||||
|
def test_wallpaper_kit_price(self):
|
||||||
|
self.assertEqual(143.2, wallpaper_kit_price(market=sweden, rounded=False, inc_vat=False))
|
||||||
|
self.assertEqual(179.0, wallpaper_kit_price(market=sweden, rounded=False, inc_vat=True))
|
||||||
|
self.assertEqual(18.0, wallpaper_kit_price(market=us))
|
||||||
|
self.assertEqual(169.0, wallpaper_kit_price(market=denmark))
|
||||||
|
|||||||
Reference in New Issue
Block a user