Commit da96a62e by Damien Moulard

display days covered & qty not covered

parent 709bec61
......@@ -19,7 +19,7 @@
flex-direction: column;
justify-content: center;
align-items: center;
padding: 10px 20px 10px 20px;
padding: 8px 20px 8px 20px;
margin: 0 10px 5px 10px;
}
......
......@@ -797,7 +797,7 @@ function create_orders() {
for (let p of products) {
for (let p_supplierinfo of p.suppliersinfo) {
// If a qty is set for a supplier for a product
if ('qty' in p_supplierinfo) {
if ('qty' in p_supplierinfo && p_supplierinfo.qty != 0) {
const supplier_id = p_supplierinfo.supplier_id;
orders_data.suppliers_data[supplier_id].lines.push({
......@@ -815,9 +815,6 @@ function create_orders() {
}
}
console.log(orders_data);
// TODO
$.ajax({
type: "POST",
url: "/orders/create_orders",
......@@ -1036,18 +1033,23 @@ function _compute_product_data(product) {
/* Coverage related data */
if (order_doc.coverage_days !== null) {
let days_not_covered = 0;
let qty_not_covered = 0;
let days_covered = 0;
if (product.daily_conso !== 0) {
let qty_not_covered = product.daily_conso * order_doc.coverage_days - product.qty_available - product.incoming_qty - purchase_qty;
days_not_covered = qty_not_covered / product.daily_conso; // get unmet needs in nb of days
qty_not_covered = product.daily_conso * order_doc.coverage_days - product.qty_available - product.incoming_qty - purchase_qty;
days_covered = qty_not_covered / product.daily_conso;
qty_not_covered = -Math.ceil(qty_not_covered); // round up, so if a value is not fully covered display it
qty_not_covered = (qty_not_covered > 0) ? 0 : qty_not_covered; // only display qty not covered (neg value)
days_not_covered = -Math.ceil(days_not_covered); // round up, so if a day is not fully covered display it
days_not_covered = (days_not_covered > 0) ? 0 : days_not_covered;
days_covered = -Math.ceil(days_covered);
}
item.days_not_covered = days_not_covered;
item.qty_not_covered = qty_not_covered;
item.days_covered = days_covered;
} else {
item.days_not_covered = 'X';
item.qty_not_covered = 'X';
item.days_covered = 'X';
}
return item;
......@@ -1112,7 +1114,7 @@ function prepare_datatable_columns() {
{
data: "default_code",
title: "Ref",
width: "8%",
width: "6%",
render: function (data) {
return (data === false) ? "" : data;
}
......@@ -1199,8 +1201,15 @@ function prepare_datatable_columns() {
});
columns.push({
data: "days_not_covered",
title: "Besoin non couvert (jours)",
data: "qty_not_covered",
title: "Besoin non couvert (qté)",
className: "dt-body-center",
width: "4%"
});
columns.push({
data: "days_covered",
title: "Jours de couverture",
className: "dt-body-center",
width: "4%"
});
......
......@@ -503,8 +503,8 @@ class CagetteProducts(models.Model):
sales_average_params = {
'ids': ptids,
# 'from': '2019-04-10',
# 'to': '2019-08-10',
'from': '2019-04-10',
'to': '2019-08-10',
}
sales = CagetteProducts.get_template_products_sales_average(sales_average_params)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment