From 99439b63e82e048609994e87afcc3089782fb1b7 Mon Sep 17 00:00:00 2001 From: tanshu Date: Tue, 15 Mar 2016 16:11:19 +0530 Subject: [PATCH] Fix: Recipe details shows the current sale price of product and also lets you edit the sale price. --- brewman/static/partial/recipe-detail.html | 8 +++++++- brewman/views/recipe.py | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/brewman/static/partial/recipe-detail.html b/brewman/static/partial/recipe-detail.html index 04d9459a..a6940283 100644 --- a/brewman/static/partial/recipe-detail.html +++ b/brewman/static/partial/recipe-detail.html @@ -16,12 +16,18 @@ + + + + Product's Sale Price {{recipe.Product.SalePrice}}, Recipe's Sale Price {{recipe.SalePrice}}, + + + value="{{costPrice | currency}} / {{costPrice * 100 / recipe.SalePrice | number:2}}%"/> diff --git a/brewman/views/recipe.py b/brewman/views/recipe.py index 430de463..1ffed8e6 100644 --- a/brewman/views/recipe.py +++ b/brewman/views/recipe.py @@ -246,7 +246,8 @@ def recipe_info(id, request): else: recipe = DBSession.query(Recipe).filter(Recipe.id == id).one() info = {'RecipeID': recipe.id, - 'Product': {'ProductID': recipe.product_id, 'Name': recipe.product.name, 'Units': recipe.product.units}, + 'Product': {'ProductID': recipe.product_id, 'Name': recipe.product.name, 'Units': recipe.product.units, + 'SalePrice': recipe.product.sale_price}, 'Quantity': recipe.quantity, 'SalePrice': recipe.sale_price, 'CostPrice': recipe.cost_price, 'ValidFrom': recipe.valid_from.strftime('%d-%b-%Y'), 'ValidTo': recipe.valid_to.strftime('%d-%b-%Y'), 'RecipeItems': []}