Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
261
Issues
261
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paul
third-party
Commits
313c7e0f
Commit
313c7e0f
authored
Jul 01, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'aide_a_la_commande' into dev_cooperatic
parents
cb98235d
46ef6a41
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
24 deletions
+33
-24
orders_helper.js
orders/static/js/orders_helper.js
+31
-22
models.py
products/models.py
+2
-2
No files found.
orders/static/js/orders_helper.js
View file @
313c7e0f
...
...
@@ -424,7 +424,7 @@ function save_supplier_products(supplier, new_products) {
products
.
push
(
np
);
}
else
{
// Prevent adding ducplicate supplierinfo
let
index_existing_supplierinfo
=
products
[
index
].
suppliersinfo
.
find
(
psi
=>
psi
.
supplier_id
==
supplier
.
id
);
let
index_existing_supplierinfo
=
products
[
index
].
suppliersinfo
.
find
Index
(
psi
=>
psi
.
supplier_id
==
supplier
.
id
);
if
(
index_existing_supplierinfo
===
-
1
)
{
np_supplierinfo
=
np
.
suppliersinfo
[
0
];
...
...
@@ -882,7 +882,7 @@ function display_suppliers() {
$
(
"#suppliers_container"
).
empty
();
$
(
".remove_supplier_icon"
).
off
();
for
(
supplier
of
selected_suppliers
)
{
for
(
let
supplier
of
selected_suppliers
)
{
let
template
=
$
(
"#templates #supplier_pill_template"
);
template
.
find
(
".pill_supplier_name"
).
text
(
supplier
.
display_name
);
...
...
@@ -895,10 +895,10 @@ function display_suppliers() {
const
el_id
=
$
(
this
).
attr
(
'id'
)
.
split
(
'_'
);
const
supplier_id
=
el_id
[
el_id
.
length
-
1
];
const
clicked_supplier
=
selected_suppliers
.
find
(
s
=>
s
.
id
==
supplier_id
);
let
modal_remove_supplier
=
$
(
'#templates #modal_remove_supplier'
);
modal_remove_supplier
.
find
(
".supplier_name"
).
text
(
supplier
.
display_name
);
modal_remove_supplier
.
find
(
".supplier_name"
).
text
(
clicked_supplier
.
display_name
);
openModal
(
modal_remove_supplier
.
html
(),
...
...
@@ -951,14 +951,18 @@ function _compute_product_data(product) {
/* Coverage related data */
if
(
order_doc
.
coverage_days
!==
null
)
{
let
unmet_needs
=
product
.
daily_conso
*
order_doc
.
coverage_days
-
product
.
qty_available
-
product
.
incoming_qty
-
purchase_qty
;
unmet_needs
=
-
Math
.
round
(
unmet_needs
);
unmet_needs
=
(
unmet_needs
>
0
)
?
0
:
unmet_needs
;
let
days_not_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
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
;
}
item
.
unmet_needs
=
unmet_needs
;
item
.
days_not_covered
=
days_not_covered
;
}
else
{
item
.
unmet_needs
=
'X'
;
item
.
days_not_covered
=
'X'
;
}
return
item
;
...
...
@@ -1033,16 +1037,6 @@ function prepare_datatable_columns() {
title
:
"Produit"
},
{
data
:
"purchase_ok"
,
title
:
`NPA`
,
className
:
"dt-body-center"
,
orderable
:
false
,
render
:
function
(
data
)
{
return
`<input type="checkbox" class="product_npa_cb" value="purchase_ok"
${
data
?
''
:
'checked'
}
>`
;
},
width
:
"4%"
},
{
data
:
"qty_available"
,
title
:
"Stock"
,
className
:
"dt-body-center"
,
...
...
@@ -1120,12 +1114,23 @@ function prepare_datatable_columns() {
});
columns
.
push
({
data
:
"
unmet_needs
"
,
data
:
"
days_not_covered
"
,
title
:
"Besoin non couvert"
,
className
:
"dt-body-center"
,
width
:
"4%"
});
columns
.
push
({
data
:
"purchase_ok"
,
title
:
`NPA`
,
className
:
"dt-body-center"
,
orderable
:
false
,
render
:
function
(
data
)
{
return
`<input type="checkbox" class="product_npa_cb" value="purchase_ok"
${
data
?
''
:
'checked'
}
>`
;
},
width
:
"4%"
});
return
columns
;
}
...
...
@@ -1165,7 +1170,11 @@ function display_products(params) {
],
stripeClasses
:
[],
// Remove datatable cells coloring
orderClasses
:
false
,
iDisplayLength
:
100
,
aLengthMenu
:
[
[
25
,
50
,
100
,
200
,
-
1
],
[
25
,
50
,
100
,
200
,
"Tout"
]
],
iDisplayLength
:
-
1
,
scrollX
:
true
,
language
:
{
url
:
'/static/js/datatables/french.json'
},
createdRow
:
function
(
row
)
{
...
...
products/models.py
View file @
313c7e0f
...
...
@@ -503,8 +503,8 @@ class CagetteProducts(models.Model):
sales_average_params
=
{
'ids'
:
ptids
,
#'from': '2019-06-10',
#'to': '2019-08-10',
#
'from': '2019-06-10',
#
'to': '2019-08-10',
}
sales
=
CagetteProducts
.
get_template_products_sales_average
(
sales_average_params
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment