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
2
Merge Requests
2
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
cooperatic-foodcoops
third-party
Commits
da96a62e
Commit
da96a62e
authored
Jul 02, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display days covered & qty not covered
parent
709bec61
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
17 deletions
+26
-17
oders_helper_style.css
orders/static/css/oders_helper_style.css
+1
-1
orders_helper.js
orders/static/js/orders_helper.js
+23
-14
models.py
products/models.py
+2
-2
No files found.
orders/static/css/oders_helper_style.css
View file @
da96a62e
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
flex-direction
:
column
;
flex-direction
:
column
;
justify-content
:
center
;
justify-content
:
center
;
align-items
:
center
;
align-items
:
center
;
padding
:
10px
20px
10
px
20px
;
padding
:
8px
20px
8
px
20px
;
margin
:
0
10px
5px
10px
;
margin
:
0
10px
5px
10px
;
}
}
...
...
orders/static/js/orders_helper.js
View file @
da96a62e
...
@@ -797,7 +797,7 @@ function create_orders() {
...
@@ -797,7 +797,7 @@ function create_orders() {
for
(
let
p
of
products
)
{
for
(
let
p
of
products
)
{
for
(
let
p_supplierinfo
of
p
.
suppliersinfo
)
{
for
(
let
p_supplierinfo
of
p
.
suppliersinfo
)
{
// If a qty is set for a supplier for a product
// 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
;
const
supplier_id
=
p_supplierinfo
.
supplier_id
;
orders_data
.
suppliers_data
[
supplier_id
].
lines
.
push
({
orders_data
.
suppliers_data
[
supplier_id
].
lines
.
push
({
...
@@ -815,9 +815,6 @@ function create_orders() {
...
@@ -815,9 +815,6 @@ function create_orders() {
}
}
}
}
console
.
log
(
orders_data
);
// TODO
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
"/orders/create_orders"
,
url
:
"/orders/create_orders"
,
...
@@ -1036,18 +1033,23 @@ function _compute_product_data(product) {
...
@@ -1036,18 +1033,23 @@ function _compute_product_data(product) {
/* Coverage related data */
/* Coverage related data */
if
(
order_doc
.
coverage_days
!==
null
)
{
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
)
{
if
(
product
.
daily_conso
!==
0
)
{
let
qty_not_covered
=
product
.
daily_conso
*
order_doc
.
coverage_days
-
product
.
qty_available
-
product
.
incoming_qty
-
purchase_qty
;
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_
covered
=
qty_not_covered
/
product
.
daily_conso
;
days_not_covered
=
-
Math
.
ceil
(
days_not_covered
);
// round up, so if a day is not fully covered display it
qty_not_covered
=
-
Math
.
ceil
(
qty_not_covered
);
// round up, so if a value is not fully covered display it
days_not_covered
=
(
days_not_covered
>
0
)
?
0
:
days_not_covered
;
qty_not_covered
=
(
qty_not_covered
>
0
)
?
0
:
qty_not_covered
;
// only display qty not covered (neg value)
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
{
}
else
{
item
.
days_not_covered
=
'X'
;
item
.
qty_not_covered
=
'X'
;
item
.
days_covered
=
'X'
;
}
}
return
item
;
return
item
;
...
@@ -1112,7 +1114,7 @@ function prepare_datatable_columns() {
...
@@ -1112,7 +1114,7 @@ function prepare_datatable_columns() {
{
{
data
:
"default_code"
,
data
:
"default_code"
,
title
:
"Ref"
,
title
:
"Ref"
,
width
:
"
8
%"
,
width
:
"
6
%"
,
render
:
function
(
data
)
{
render
:
function
(
data
)
{
return
(
data
===
false
)
?
""
:
data
;
return
(
data
===
false
)
?
""
:
data
;
}
}
...
@@ -1199,8 +1201,15 @@ function prepare_datatable_columns() {
...
@@ -1199,8 +1201,15 @@ function prepare_datatable_columns() {
});
});
columns
.
push
({
columns
.
push
({
data
:
"days_not_covered"
,
data
:
"qty_not_covered"
,
title
:
"Besoin non couvert (jours)"
,
title
:
"Besoin non couvert (qté)"
,
className
:
"dt-body-center"
,
width
:
"4%"
});
columns
.
push
({
data
:
"days_covered"
,
title
:
"Jours de couverture"
,
className
:
"dt-body-center"
,
className
:
"dt-body-center"
,
width
:
"4%"
width
:
"4%"
});
});
...
...
products/models.py
View file @
da96a62e
...
@@ -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-04-10',
'from'
:
'2019-04-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