Commit 560b2c07 by Yvon

4809 : remove shelf value and all associated code + not in use already commented out code

parent 97a032e3
Pipeline #2977 failed with stage
in 1 minute 6 seconds
...@@ -80,57 +80,6 @@ function init_datatable() { ...@@ -80,57 +80,6 @@ function init_datatable() {
}, },
{data:"p_nb", title:"Nombre de réfs", width: "5%", className:"dt-body-center clickable"}, {data:"p_nb", title:"Nombre de réfs", width: "5%", className:"dt-body-center clickable"},
{ {
data:"shelf_value",
title:"Valeur théorique du rayon",
render: function (data, type) {
if (type == "sort" || type == 'type')
return data;
if (data == -1) { // Code: server send empty field -> loading
return '<i class="fas fa-spinner fa-spin"></i>';
} else if (data == -2) { // Code: error getting data from server
return '/';
} else {
return data + ' €';
}
},
width: "5%",
className:"dt-body-center clickable"
},
/* NOT IN USE */
// {
// data:"last_inv_delta_percentage",
// title:"Delta (dernier inv.)",
// width: "5%",
// className:"dt-body-center",
// render: function (data, type) {
// if (type == "sort" || type == 'type')
// return data;
// if (data == -99999999) {
// return '/';
// } else {
// return data + ' %';
// }
// }
// },
// {
// data:"last_inv_losses_percentage",
// title:"Pertes (dernier inv.)",
// width: "5%",
// className:"dt-body-center",
// render: function (data, type) {
// if (type == "sort" || type == 'type')
// return data;
// if (data == -99999999) {
// return '/';
// } else {
// return data + ' %';
// }
// }
// },
{
data:"inventory_status", data:"inventory_status",
title:"Inventaire à faire", title:"Inventaire à faire",
className:"dt-body-center", className:"dt-body-center",
...@@ -164,53 +113,6 @@ function init_datatable() { ...@@ -164,53 +113,6 @@ function init_datatable() {
}); });
} }
function get_shelfs_extra_data() {
try {
$.ajax({
type: 'GET',
url: '/shelfs/get_shelves_extra_data',
dataType:"json",
traditional: true,
contentType: "application/json; charset=utf-8",
success: function(data) {
for (item of data.res) {
var row_data = shelfs_table.row('#'+item.id).data();
row_data.shelf_value = item.shelf_value;
shelfs_table
.row('#'+item.id)
.data(row_data)
.draw();
}
},
error: function(data) {
if (typeof data.responseJSON != 'undefined') {
console.log(data.responseJSON);
}
set_null_to_extra_data();
}
});
} catch (e) {
console.log(e);
set_null_to_extra_data();
}
}
function set_null_to_extra_data() {
shelfs_table.rows().every(function () {
var d = this.data();
d.shelf_value = -2;
this.invalidate(); // invalidate the data DataTables has cached for this row
return 1;
});
shelfs_table.draw();
}
var getRowData = function(clicked) { var getRowData = function(clicked) {
var row = shelfs_table.row(clicked.parents('tr')); var row = shelfs_table.row(clicked.parents('tr'));
...@@ -324,7 +226,6 @@ $(document).ready(function() { ...@@ -324,7 +226,6 @@ $(document).ready(function() {
} }
shelfs_table = init_datatable(); shelfs_table = init_datatable();
get_shelfs_extra_data();
$(document).on('click', 'button.do_shelf_inventory', go_to_shelf_inventory); $(document).on('click', 'button.do_shelf_inventory', go_to_shelf_inventory);
$(document).on('click', 'tbody td .delete_ongoing_inv_icon', pre_delete_ongoing_inventory); $(document).on('click', 'tbody td .delete_ongoing_inv_icon', pre_delete_ongoing_inventory);
......
...@@ -84,40 +84,6 @@ function go_to_shelf_view() { ...@@ -84,40 +84,6 @@ function go_to_shelf_view() {
document.location.href = "shelf_view/" + row_data.id; document.location.href = "shelf_view/" + row_data.id;
} }
function get_shelfs_sales_data() {
try {
$.ajax({
type: 'GET',
url: '/shelfs/get_shelves_sales_data',
dataType:"json",
traditional: true,
contentType: "application/json; charset=utf-8",
success: function(data) {
for (item of data.res) {
var row_data = shelfs_table.row('#'+item.id).data();
row_data.shelf_value = item.shelf_value;
shelfs_table
.row('#'+item.id)
.data(row_data)
.draw();
}
},
error: function(data) {
if (typeof data.responseJSON != 'undefined') {
console.log(data.responseJSON);
}
}
});
} catch (e) {
err = {msg: e.toString(), ctx: 'get_shelfs_sales_data'};
report_JS_error(err, 'shelfs');
}
}
function export_sales_data(event) { function export_sales_data(event) {
event.stopImmediatePropagation(); event.stopImmediatePropagation();
var clicked = $(this); var clicked = $(this);
......
...@@ -10,7 +10,6 @@ urlpatterns = [ ...@@ -10,7 +10,6 @@ urlpatterns = [
url(r'^shelf_inventory/([0-9]+)$', views.shelf_inventory), url(r'^shelf_inventory/([0-9]+)$', views.shelf_inventory),
url(r'^inventory_process_state/([0-9]+)$', views.inventory_process_state), url(r'^inventory_process_state/([0-9]+)$', views.inventory_process_state),
url(r'^all/?([a-z]*)$', views.all), url(r'^all/?([a-z]*)$', views.all),
url(r'^get_shelves_extra_data$', views.get_shelves_extra_data),
url(r'^change_products_shelfs$', views.change_products_shelfs), url(r'^change_products_shelfs$', views.change_products_shelfs),
url(r'^(?P<shelf_id>\d+)$', views.shelf_data), url(r'^(?P<shelf_id>\d+)$', views.shelf_data),
url(r'^(?P<shelf_id>\d+)/products$', views.products), url(r'^(?P<shelf_id>\d+)/products$', views.products),
......
...@@ -13,8 +13,6 @@ def index(request): ...@@ -13,8 +13,6 @@ def index(request):
"""Main shelf page""" """Main shelf page"""
shelfs = Shelfs.get_all() shelfs = Shelfs.get_all()
# TODO : Make the distinction beetween active and inactive products # TODO : Make the distinction beetween active and inactive products
for s in shelfs:
s['shelf_value'] = -1
context = {'title': 'Rayons', context = {'title': 'Rayons',
'shelfs': json.dumps(shelfs)} 'shelfs': json.dumps(shelfs)}
...@@ -85,25 +83,6 @@ def all(request, precision): ...@@ -85,25 +83,6 @@ def all(request, precision):
"""Get all shelves data""" """Get all shelves data"""
return JsonResponse({'res': Shelfs.get_all(precision)}) return JsonResponse({'res': Shelfs.get_all(precision)})
def get_shelves_extra_data(request):
"""Get data that need calculation, so long execution time"""
shelfs = Shelfs.get_all()
res = []
for s in shelfs :
shelf_products = Shelf(s['id']).get_products()['data']
shelf_value = 0
for p in shelf_products :
shelf_value += float(p['qty_available']) * float(p['standard_price'])
res.append({
'id': s['id'],
'shelf_value': round(shelf_value, 2)
})
return JsonResponse({'res': res})
def products(request, shelf_id): def products(request, shelf_id):
"""Get all products from a shelf""" """Get all products from a shelf"""
res = {} res = {}
......
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