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
0
Issues
0
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
Alexis AOUN
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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
23 deletions
+32
-23
orders_helper.js
orders/static/js/orders_helper.js
+30
-21
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) {
...
@@ -424,7 +424,7 @@ function save_supplier_products(supplier, new_products) {
products
.
push
(
np
);
products
.
push
(
np
);
}
else
{
}
else
{
// Prevent adding ducplicate supplierinfo
// 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
)
{
if
(
index_existing_supplierinfo
===
-
1
)
{
np_supplierinfo
=
np
.
suppliersinfo
[
0
];
np_supplierinfo
=
np
.
suppliersinfo
[
0
];
...
@@ -882,7 +882,7 @@ function display_suppliers() {
...
@@ -882,7 +882,7 @@ function display_suppliers() {
$
(
"#suppliers_container"
).
empty
();
$
(
"#suppliers_container"
).
empty
();
$
(
".remove_supplier_icon"
).
off
();
$
(
".remove_supplier_icon"
).
off
();
for
(
supplier
of
selected_suppliers
)
{
for
(
let
supplier
of
selected_suppliers
)
{
let
template
=
$
(
"#templates #supplier_pill_template"
);
let
template
=
$
(
"#templates #supplier_pill_template"
);
template
.
find
(
".pill_supplier_name"
).
text
(
supplier
.
display_name
);
template
.
find
(
".pill_supplier_name"
).
text
(
supplier
.
display_name
);
...
@@ -895,10 +895,10 @@ function display_suppliers() {
...
@@ -895,10 +895,10 @@ function display_suppliers() {
const
el_id
=
$
(
this
).
attr
(
'id'
)
const
el_id
=
$
(
this
).
attr
(
'id'
)
.
split
(
'_'
);
.
split
(
'_'
);
const
supplier_id
=
el_id
[
el_id
.
length
-
1
];
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'
);
let
modal_remove_supplier
=
$
(
'#templates #modal_remove_supplier'
);
modal_remove_supplier
.
find
(
".supplier_name"
).
text
(
clicked_supplier
.
display_name
);
modal_remove_supplier
.
find
(
".supplier_name"
).
text
(
supplier
.
display_name
);
openModal
(
openModal
(
modal_remove_supplier
.
html
(),
modal_remove_supplier
.
html
(),
...
@@ -951,14 +951,18 @@ function _compute_product_data(product) {
...
@@ -951,14 +951,18 @@ function _compute_product_data(product) {
/* Coverage related data */
/* Coverage related data */
if
(
order_doc
.
coverage_days
!==
null
)
{
if
(
order_doc
.
coverage_days
!==
null
)
{
let
unmet_needs
=
product
.
daily_conso
*
order_doc
.
coverage_days
-
product
.
qty_available
-
product
.
incoming_qty
-
purchase_qty
;
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
unmet_needs
=
-
Math
.
round
(
unmet_needs
);
days_not_covered
=
-
Math
.
ceil
(
days_not_covered
);
// round up, so if a day is not fully covered display it
unmet_needs
=
(
unmet_needs
>
0
)
?
0
:
unmet_needs
;
days_not_covered
=
(
days_not_covered
>
0
)
?
0
:
days_not_covered
;
}
item
.
unmet_needs
=
unmet_needs
;
item
.
days_not_covered
=
days_not_covered
;
}
else
{
}
else
{
item
.
unmet_needs
=
'X'
;
item
.
days_not_covered
=
'X'
;
}
}
return
item
;
return
item
;
...
@@ -1033,16 +1037,6 @@ function prepare_datatable_columns() {
...
@@ -1033,16 +1037,6 @@ function prepare_datatable_columns() {
title
:
"Produit"
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"
,
data
:
"qty_available"
,
title
:
"Stock"
,
title
:
"Stock"
,
className
:
"dt-body-center"
,
className
:
"dt-body-center"
,
...
@@ -1120,12 +1114,23 @@ function prepare_datatable_columns() {
...
@@ -1120,12 +1114,23 @@ function prepare_datatable_columns() {
});
});
columns
.
push
({
columns
.
push
({
data
:
"
unmet_needs
"
,
data
:
"
days_not_covered
"
,
title
:
"Besoin non couvert"
,
title
:
"Besoin non couvert"
,
className
:
"dt-body-center"
,
className
:
"dt-body-center"
,
width
:
"4%"
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
;
return
columns
;
}
}
...
@@ -1165,7 +1170,11 @@ function display_products(params) {
...
@@ -1165,7 +1170,11 @@ function display_products(params) {
],
],
stripeClasses
:
[],
// Remove datatable cells coloring
stripeClasses
:
[],
// Remove datatable cells coloring
orderClasses
:
false
,
orderClasses
:
false
,
iDisplayLength
:
100
,
aLengthMenu
:
[
[
25
,
50
,
100
,
200
,
-
1
],
[
25
,
50
,
100
,
200
,
"Tout"
]
],
iDisplayLength
:
-
1
,
scrollX
:
true
,
scrollX
:
true
,
language
:
{
url
:
'/static/js/datatables/french.json'
},
language
:
{
url
:
'/static/js/datatables/french.json'
},
createdRow
:
function
(
row
)
{
createdRow
:
function
(
row
)
{
...
...
products/models.py
View file @
313c7e0f
...
@@ -503,8 +503,8 @@ class CagetteProducts(models.Model):
...
@@ -503,8 +503,8 @@ class CagetteProducts(models.Model):
sales_average_params
=
{
sales_average_params
=
{
'ids'
:
ptids
,
'ids'
:
ptids
,
#'from': '2019-06-10',
#
'from': '2019-06-10',
#'to': '2019-08-10',
#
'to': '2019-08-10',
}
}
sales
=
CagetteProducts
.
get_template_products_sales_average
(
sales_average_params
)
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