P5-7013 Move wallpaperkit price to api (#38)

This commit is contained in:
Niklas Fondberg
2021-03-24 11:44:35 +01:00
committed by GitHub
parent 464e2f1fa6
commit 2b452a573a
4 changed files with 76 additions and 0 deletions
+22
View File
@@ -511,3 +511,25 @@ def inquiry_price(
price = round_half_up(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
+20
View File
@@ -19,6 +19,7 @@ from api.lib.prices import (
framed_print_price,
wallpaper_m2_price,
inquiry_price,
wallpaper_kit_price,
)
from api.lib.limits import calculate_canvas_limits
@@ -226,6 +227,25 @@ def diy_frame():
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"])
@validate_number("width")
@validate_exists("market")
+28
View File
@@ -291,3 +291,31 @@ Sample response
"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
}
]
}
```
+6
View File
@@ -491,3 +491,9 @@ class TestPrice(unittest2.TestCase):
framed_print_price(sku="invalid", market=sweden)
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))