Commit a2126725 by Damien Moulard

REC: display received qty in prices step

parent 841076df
Pipeline #2187 passed with stage
in 1 minute 34 seconds
...@@ -58,6 +58,8 @@ RECEPTION_MERGE_ORDERS_PSWD = 'jpsrcp' ...@@ -58,6 +58,8 @@ RECEPTION_MERGE_ORDERS_PSWD = 'jpsrcp'
RECEPTION_PB = "Ici, vous pouvez signaler toute anomalie lors d'une réception, les produits non commandés, cassés ou pourris. \ RECEPTION_PB = "Ici, vous pouvez signaler toute anomalie lors d'une réception, les produits non commandés, cassés ou pourris. \
Merci d'indiquer un maximum d'informations, le nom du produit et son code barre." Merci d'indiquer un maximum d'informations, le nom du produit et son code barre."
DISPLAY_COL_AUTRES = False DISPLAY_COL_AUTRES = False
RECEPTION_ADD_ALL_LEFT_IS_GOOD_QTIES = False
RECEPTION_ADD_ALL_LEFT_IS_GOOD_PRICES = True
DAV_PATH = '/shared_dir/dav/' DAV_PATH = '/shared_dir/dav/'
......
...@@ -61,7 +61,8 @@ RECEPTION_PDT_LABELS_BTN_TEXT = 'Lancer l\'impression' ...@@ -61,7 +61,8 @@ RECEPTION_PDT_LABELS_BTN_TEXT = 'Lancer l\'impression'
RECEPTION_SHELF_LABEL_PRINT = True RECEPTION_SHELF_LABEL_PRINT = True
FIXED_BARCODE_PREFIX = '0499' FIXED_BARCODE_PREFIX = '0499'
RECEPTION_ADD_ADMIN_MODE = True RECEPTION_ADD_ADMIN_MODE = True
RECEPTION_ADD_ALL_LEFT_IS_GOOD = True RECEPTION_ADD_ALL_LEFT_IS_GOOD_QTIES = True
RECEPTION_ADD_ALL_LEFT_IS_GOOD_PRICES = True
SUBSCRIPTION_PAYMENT_MEANINGS = [ SUBSCRIPTION_PAYMENT_MEANINGS = [
{'code': 'cash', 'title': 'Espèces', 'journal_id': CASH_PAYMENT_ID}, {'code': 'cash', 'title': 'Espèces', 'journal_id': CASH_PAYMENT_ID},
......
...@@ -337,9 +337,14 @@ ...@@ -337,9 +337,14 @@
- RECEPTION_ADD_ADMIN_MODE = True - RECEPTION_ADD_ADMIN_MODE = True
- RECEPTION_ADD_ALL_LEFT_IS_GOOD = True - RECEPTION_ADD_ALL_LEFT_IS_GOOD_QTIES = False
A second button appears to make all pending products (left list) to be considered as "good" During qties step, a second button appears to make all pending products (left list) to be considered as "good"
(RECEPTION_ADD_ADMIN_MODE needs to be set at True)
- RECEPTION_ADD_ALL_LEFT_IS_GOOD_PRICES = False
During prices step, a second button appears to make all pending products (left list) to be considered as "good"
(RECEPTION_ADD_ADMIN_MODE needs to be set at True) (RECEPTION_ADD_ADMIN_MODE needs to be set at True)
- RECEPTION_MERGE_ORDERS_PSWD = 'pass2makeApause' - RECEPTION_MERGE_ORDERS_PSWD = 'pass2makeApause'
......
...@@ -147,7 +147,11 @@ table.dataTable { ...@@ -147,7 +147,11 @@ table.dataTable {
border-radius: 3px; border-radius: 3px;
} }
#connected_actions .full_width_button, .half_width_button { #all_left_is_good {
display: none;
}
.connected_actions .full_width_button, .half_width_button {
height: 45px; height: 45px;
width: 40%; width: 40%;
border-radius: 3px; border-radius: 3px;
...@@ -193,6 +197,14 @@ div#container_edition { ...@@ -193,6 +197,14 @@ div#container_edition {
font-size: 2rem; font-size: 2rem;
} }
tr.even td.row_product_no_qty {
background-color: #f0ad4e; /*#ec971f*/
}
tr.odd td.row_product_no_qty {
background-color: rgb(236, 182, 106); /*#ec971f*/
}
/* Accordion style */ /* Accordion style */
/* Style the buttons that are used to open and close the accordion panel */ /* Style the buttons that are used to open and close the accordion panel */
......
...@@ -251,6 +251,23 @@ function fetch_data() { ...@@ -251,6 +251,23 @@ function fetch_data() {
for (order_data of data.orders) { for (order_data of data.orders) {
// for each product in order // for each product in order
for (i in order_data.po) { for (i in order_data.po) {
// If in step 2, find old qty in previous step data
if (
reception_status == 'qty_valid'
&& "previous_steps_data" in orders[order_data.id_po]
&& "False" in orders[order_data.id_po]["previous_steps_data"]
&& "updated_products" in orders[order_data.id_po]["previous_steps_data"]["False"] // extra + secturity
) {
// For each updated product in step 1
for (let step1_updated_product of orders[order_data.id_po]["previous_steps_data"]["False"]["updated_products"]) {
// If product found
if (step1_updated_product["product_id"][0] === order_data.po[i]["product_id"][0]) {
// Add old qty
order_data.po[i].old_qty = step1_updated_product.old_qty;
}
}
}
// Does product already exists in list_to_process? // Does product already exists in list_to_process?
var existing_index = null; var existing_index = null;
...@@ -315,7 +332,17 @@ function fetch_data() { ...@@ -315,7 +332,17 @@ function fetch_data() {
// Init Data & listeners // Init Data & listeners
function initLists() { function initLists() {
try { try {
// Enable validation buttons now the data's here // Set action buttons for remaining items
if (
add_all_left_is_good_qties === "True" && reception_status == "False"
||
add_all_left_is_good_prices === "True" && reception_status == "qty_valid"
) {
$("#remaining_lines_actions_area").addClass("connected_actions");
$("#all_left_is_good").show();
}
// Enable validation buttons now the data's here
if (reception_status == "False") { if (reception_status == "False") {
document.getElementById("valid_qty").disabled = false; document.getElementById("valid_qty").disabled = false;
document.getElementById("valid_all_qties").disabled = false; document.getElementById("valid_all_qties").disabled = false;
...@@ -385,7 +412,15 @@ function initLists() { ...@@ -385,7 +412,15 @@ function initLists() {
data:"product_qty", data:"product_qty",
title: "Qté", title: "Qté",
className:"dt-body-center", className:"dt-body-center",
visible: (reception_status == "False") render: function (data, type, full) {
if (reception_status == "False") {
return data;
} else if ("old_qty" in full) {
return `${data}/${full.old_qty}`;
} else {
return `${data}/${data}`;
}
}
}, },
{ {
data:"price_unit", data:"price_unit",
...@@ -447,14 +482,13 @@ function initLists() { ...@@ -447,14 +482,13 @@ function initLists() {
data:"product_qty", data:"product_qty",
title:"Qté", title:"Qté",
className:"dt-head-center dt-body-center", className:"dt-head-center dt-body-center",
visible: (reception_status == "False"), // visible: (reception_status == "False"),
render: function (data, type, full) { render: function (data, type, full) {
let disp = [ let disp = [
full.product_qty, data,
(full.old_qty !== undefined)?full.old_qty:full.product_qty (full.old_qty !== undefined) ? full.old_qty : data
].join("/"); ].join("/");
return disp; return disp;
}, },
orderable: false orderable: false
...@@ -487,9 +521,6 @@ function initLists() { ...@@ -487,9 +521,6 @@ function initLists() {
} }
]; ];
console.log(columns_to_process);
// Init table for to_process content // Init table for to_process content
table_to_process = $('#table_to_process').DataTable({ table_to_process = $('#table_to_process').DataTable({
data: list_to_process, data: list_to_process,
...@@ -505,7 +536,21 @@ function initLists() { ...@@ -505,7 +536,21 @@ function initLists() {
scrollCollapse: true, scrollCollapse: true,
paging: false, paging: false,
dom: 'lrtip', // Remove the search input from that table dom: 'lrtip', // Remove the search input from that table
language: {url : '/static/js/datatables/french.json'} language: {url : '/static/js/datatables/french.json'},
createdRow: function(row) {
// Add class to rows with product with qty at 0
var row_data = $('#table_to_process').DataTable()
.row(row)
.data();
if (row_data !== undefined && row_data.product_qty === 0) {
for (var i = 0; i < row.cells.length; i++) {
const cell_node = row.cells[i];
$(cell_node).addClass('row_product_no_qty');
}
}
}
}); });
// Init table for processed content // Init table for processed content
...@@ -523,7 +568,20 @@ function initLists() { ...@@ -523,7 +568,20 @@ function initLists() {
scrollCollapse: true, scrollCollapse: true,
paging: false, paging: false,
dom: 'lrtip', // Remove the search input from that table dom: 'lrtip', // Remove the search input from that table
language: {url : '/static/js/datatables/french.json'} language: {url : '/static/js/datatables/french.json'},
createdRow: function(row) {
var row_data = $('#table_processed').DataTable()
.row(row)
.data();
if (row_data !== undefined && row_data.product_qty === 0) {
for (var i = 0; i < row.cells.length; i++) {
const cell_node = row.cells[i];
$(cell_node).addClass('row_product_no_qty');
}
}
}
}); });
} catch (e) { } catch (e) {
err = {msg: e.name + ' : ' + e.message, ctx: 'initLists: init tables'}; err = {msg: e.name + ' : ' + e.message, ctx: 'initLists: init tables'};
...@@ -966,7 +1024,7 @@ function editProductInfo (productToEdit, value = null, batch = false) { ...@@ -966,7 +1024,7 @@ function editProductInfo (productToEdit, value = null, batch = false) {
// If 'value' parameter not set, get value from edition input // If 'value' parameter not set, get value from edition input
if (value == null) { if (value == null) {
newValue = parseFloat(document.getElementById('edition_input').value.replace(',', '.')); newValue = parseFloat(document.getElementById('edition_input').value.replace(',', '.'));
newValue = newValue.isFinite() ? newValue : 0; newValue = isFinite(newValue) ? newValue : 0;
} }
$.each(list_processed, function(i, e) { $.each(list_processed, function(i, e) {
...@@ -1058,7 +1116,6 @@ function editProductInfo (productToEdit, value = null, batch = false) { ...@@ -1058,7 +1116,6 @@ function editProductInfo (productToEdit, value = null, batch = false) {
} }
} }
} else { } else {
if (isValid) { if (isValid) {
//if product is valid -> remove from updated_products list and add to valid_products list //if product is valid -> remove from updated_products list and add to valid_products list
//removing from updated_products //removing from updated_products
...@@ -1977,7 +2034,7 @@ $(document).ready(function() { ...@@ -1977,7 +2034,7 @@ $(document).ready(function() {
} }
} }
// if not in group, add current order to group // if not in group, add current order to group (1 order = group of 1)
if (group_ids.length == 0) { if (group_ids.length == 0) {
group_ids.push(id); group_ids.push(id);
} }
......
...@@ -79,6 +79,8 @@ def produits(request, id): ...@@ -79,6 +79,8 @@ def produits(request, id):
'db': settings.COUCHDB['dbs']['reception'], 'db': settings.COUCHDB['dbs']['reception'],
'POUCHDB_VERSION': getattr(settings, 'POUCHDB_VERSION', ''), 'POUCHDB_VERSION': getattr(settings, 'POUCHDB_VERSION', ''),
"DISPLAY_AUTRES": getattr(settings, 'DISPLAY_COL_AUTRES', True), "DISPLAY_AUTRES": getattr(settings, 'DISPLAY_COL_AUTRES', True),
"ADD_ALL_LEFT_IS_GOOD_QTIES": False,
"ADD_ALL_LEFT_IS_GOOD_PRICES": False,
} }
fixed_barcode_prefix = '0490' fixed_barcode_prefix = '0490'
...@@ -91,10 +93,14 @@ def produits(request, id): ...@@ -91,10 +93,14 @@ def produits(request, id):
fixed_barcode_prefix = settings.FIXED_BARCODE_PREFIX fixed_barcode_prefix = settings.FIXED_BARCODE_PREFIX
if hasattr(settings, 'RECEPTION_ADD_ADMIN_MODE'): if hasattr(settings, 'RECEPTION_ADD_ADMIN_MODE'):
context['add_admin_mode'] = settings.RECEPTION_ADD_ADMIN_MODE context['add_admin_mode'] = settings.RECEPTION_ADD_ADMIN_MODE
if hasattr(settings, 'RECEPTION_ADD_ALL_LEFT_IS_GOOD'): if hasattr(settings, 'RECEPTION_ADD_ALL_LEFT_IS_GOOD_QTIES'):
is_connected_user = CagetteUser.are_credentials_ok(request) is_connected_user = CagetteUser.are_credentials_ok(request)
if is_connected_user is True: if is_connected_user is True:
context['add_all_left_is_good'] = settings.RECEPTION_ADD_ALL_LEFT_IS_GOOD context['ADD_ALL_LEFT_IS_GOOD_QTIES'] = settings.RECEPTION_ADD_ALL_LEFT_IS_GOOD_QTIES
if hasattr(settings, 'RECEPTION_ADD_ALL_LEFT_IS_GOOD_PRICES'):
is_connected_user = CagetteUser.are_credentials_ok(request)
if is_connected_user is True:
context['ADD_ALL_LEFT_IS_GOOD_PRICES'] = settings.RECEPTION_ADD_ALL_LEFT_IS_GOOD_PRICES
context['FIXED_BARCODE_PREFIX'] = fixed_barcode_prefix context['FIXED_BARCODE_PREFIX'] = fixed_barcode_prefix
template = loader.get_template('reception/reception_produits.html') template = loader.get_template('reception/reception_produits.html')
...@@ -113,7 +119,7 @@ def get_orders_lines(request): ...@@ -113,7 +119,7 @@ def get_orders_lines(request):
data = json.loads(request.body.decode()) data = json.loads(request.body.decode())
orders = [] orders = []
for id_po in data['po_ids']: for id_po in data['po_ids']:
order_lines = CagetteReception.get_order_lines_by_po(int(id_po)) order_lines = CagetteReception.get_order_lines_by_po(int(id_po), nullQty = True)
orders.append({'id_po': id_po, 'po': order_lines}) orders.append({'id_po': id_po, 'po': order_lines})
return JsonResponse({'orders': orders}) return JsonResponse({'orders': orders})
......
...@@ -88,16 +88,18 @@ ...@@ -88,16 +88,18 @@
<button class="btn--warning full_width_button" name="faq" onclick="openFAQ()">FAQ - En cas de soucis avec la marche à suivre...</button> <button class="btn--warning full_width_button" name="faq" onclick="openFAQ()">FAQ - En cas de soucis avec la marche à suivre...</button>
</div> </div>
<div class="page_element txtcenter"> <div class="page_element txtcenter">
{% if add_all_left_is_good %} <div id="remaining_lines_actions_area">
<div id="connected_actions">
<span id="valid_all"></span> <span id="valid_all"></span>
<span id="all_left_is_good"> <span id="all_left_is_good">
<button class='btn--danger half_width_button' onclick="openModal($('#templates #modal_all_left_is_good').html(), confirm_all_left_is_good, 'Confirmer', false);">Tout le reste est bon</button> <button
class='btn--danger half_width_button'
id="all_left_is_good_button"
onclick="openModal($('#templates #modal_all_left_is_good').html(), confirm_all_left_is_good, 'Confirmer', false);"
>
Tout le reste est bon
</button>
</span> </span>
</div> </div>
{% else %}
<span id="valid_all"></span>
{% endif %}
</div> </div>
</div> </div>
...@@ -194,6 +196,8 @@ ...@@ -194,6 +196,8 @@
var couchdb_dbname = '{{db}}'; var couchdb_dbname = '{{db}}';
var couchdb_server = '{{couchdb_server}}' + couchdb_dbname; var couchdb_server = '{{couchdb_server}}' + couchdb_dbname;
var display_autres = "{{DISPLAY_AUTRES}}"; var display_autres = "{{DISPLAY_AUTRES}}";
var add_all_left_is_good_qties = "{{ADD_ALL_LEFT_IS_GOOD_QTIES}}"
var add_all_left_is_good_prices = "{{ADD_ALL_LEFT_IS_GOOD_PRICES}}"
</script> </script>
<script src="{% static "js/all_common.js" %}?v="></script> <script src="{% static "js/all_common.js" %}?v="></script>
<script src='{% static "js/barcodes.js" %}?v='></script> <script src='{% static "js/barcodes.js" %}?v='></script>
......
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