+
Tetastock
@@ -20,8 +20,8 @@
-
-
+
+
{% block left_menu %}
-
Accueil
@@ -36,7 +36,7 @@
Fournisseurs
{% endblock %}
+
{% block content %}
diff --git a/templates/new_componant.html b/templates/new_componant.html
index 282ce14..84f2be5 100644
--- a/templates/new_componant.html
+++ b/templates/new_componant.html
@@ -6,8 +6,8 @@
{% block top_menu %}
')
+@resume_session
+def in_componants(componant_id):
+ """ Incoming order """
+ return render_template('wip.html', css=session[u'css'])
+
+@app.route('/orders/out/')
+@resume_session
+def out_componants(componant_id):
+ """ Outgoing order """
+ return render_template('wip.html', css=session[u'css'])
+
+
########################################################################
# Providers
########################################################################
-
-
+
+
{% endblock %}
{% block left_menu %}
diff --git a/templates/test.html b/templates/test.html
index 5e931ae..215a407 100644
--- a/templates/test.html
+++ b/templates/test.html
@@ -5,8 +5,8 @@
{% block title %}Liste des composants{% endblock %}
{% block top_menu %}
-
-
+
+
{% endblock %}
{% block left_menu %}
diff --git a/tetastock.py b/tetastock.py
index ea9c882..bf5ab71 100755
--- a/tetastock.py
+++ b/tetastock.py
@@ -413,18 +413,6 @@ def new_componant():
return 'KO'
return 'OK'
-@app.route('/componants/in')
-@resume_session
-def in_componants():
- """ Incoming order """
- return render_template('wip.html', css=session[u'css'])
-
-@app.route('/componants/out')
-@resume_session
-def out_componants():
- """ Outgoing order """
- return render_template('wip.html', css=session[u'css'])
-
## Componants update result set
@app.route('/componants/update', methods=['GET', 'POST'])
@resume_session
@@ -480,6 +468,43 @@ def update_componants():
sync_cookies(response, session)
return response
+########################################################################
+# Orders
+########################################################################
+def compute_mean_price(componant_id, price, quantity):
+ """ Compute mean price """
+ try:
+ componant_id = int(componant_id)
+ price = float(price)
+ quantity = float(quantity)
+ except ValueError:
+ # bad parameters
+ return -1
+ componant = Stock_componants.query.filter_by(id=componant_id).first()
+ if componant:
+ actual_mean_price = componant.mean_price
+ actual_quantity = componant.quantity
+ actual_total = actual_mean_price * actual_quantity
+ order_total = price * quantity
+ grand_total = order_total + actual_total
+ new_mean_price = grand_total / (actual_quantity + quantity)
+ return new_mean_price
+ # Componant does not exist
+ return -1
+
+@app.route('/orders/in/