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
8347a3c1
Commit
8347a3c1
authored
Aug 30, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix errors on changing daily conso period
parent
8bf32ac2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
26 deletions
+31
-26
orders_helper.js
orders/static/js/orders_helper.js
+31
-26
No files found.
orders/static/js/orders_helper.js
View file @
8347a3c1
...
@@ -189,29 +189,31 @@ function add_product() {
...
@@ -189,29 +189,31 @@ function add_product() {
* Set the computed qty for the first supplier only.
* Set the computed qty for the first supplier only.
*/
*/
function
compute_products_coverage_qties
()
{
function
compute_products_coverage_qties
()
{
for
(
const
[
if
(
order_doc
.
coverage_days
!=
null
)
{
key
,
for
(
const
[
product
key
,
]
of
Object
.
entries
(
products
))
{
product
if
(
'suppliersinfo'
in
product
&&
product
.
suppliersinfo
.
length
>
0
)
{
]
of
Object
.
entries
(
products
))
{
let
purchase_qty_for_coverage
=
null
;
if
(
'suppliersinfo'
in
product
&&
product
.
suppliersinfo
.
length
>
0
)
{
let
purchase_qty_for_coverage
=
null
;
// Durée couverture produit = (stock + qté entrante + qté commandée ) / conso quotidienne
const
stock
=
product
.
qty_available
;
// Durée couverture produit = (stock + qté entrante + qté commandée ) / conso quotidienne
const
incoming_qty
=
product
.
incoming_qty
;
const
stock
=
product
.
qty_available
;
const
daily_conso
=
product
.
daily_conso
;
const
incoming_qty
=
product
.
incoming_qty
;
const
daily_conso
=
product
.
daily_conso
;
purchase_qty_for_coverage
=
order_doc
.
coverage_days
*
daily_conso
-
stock
-
incoming_qty
;
purchase_qty_for_coverage
=
(
purchase_qty_for_coverage
<
0
)
?
0
:
purchase_qty_for_coverage
;
purchase_qty_for_coverage
=
order_doc
.
coverage_days
*
daily_conso
-
stock
-
incoming_qty
;
purchase_qty_for_coverage
=
(
purchase_qty_for_coverage
<
0
)
?
0
:
purchase_qty_for_coverage
;
// Reduce to nb of packages to purchase
purchase_package_qty_for_coverage
=
purchase_qty_for_coverage
/
product
.
suppliersinfo
[
0
].
package_qty
;
// Reduce to nb of packages to purchase
purchase_package_qty_for_coverage
=
purchase_qty_for_coverage
/
product
.
suppliersinfo
[
0
].
package_qty
;
// Round up to unit for all products
purchase_package_qty_for_coverage
=
Math
.
ceil
(
purchase_package_qty_for_coverage
);
// Round up to unit for all products
purchase_package_qty_for_coverage
=
Math
.
ceil
(
purchase_package_qty_for_coverage
);
// Set qty to purchase for first supplier only
products
[
key
].
suppliersinfo
[
0
].
qty
=
purchase_package_qty_for_coverage
;
// Set qty to purchase for first supplier only
products
[
key
].
suppliersinfo
[
0
].
qty
=
purchase_package_qty_for_coverage
;
}
}
}
}
}
}
}
...
@@ -232,8 +234,10 @@ function check_products_data() {
...
@@ -232,8 +234,10 @@ function check_products_data() {
}
}
);
);
clicked_order_pill
.
find
(
'.pill_order_name'
).
empty
()
if
(
clicked_order_pill
!=
null
)
{
.
append
(
`<i class="fas fa-spinner fa-spin"></i>`
);
clicked_order_pill
.
find
(
'.pill_order_name'
).
empty
()
.
append
(
`<i class="fas fa-spinner fa-spin"></i>`
);
}
$
.
ajax
({
$
.
ajax
({
type
:
'GET'
,
type
:
'GET'
,
...
@@ -2112,8 +2116,9 @@ $(document).ready(function() {
...
@@ -2112,8 +2116,9 @@ $(document).ready(function() {
check_products_data
()
check_products_data
()
.
then
(()
=>
{
.
then
(()
=>
{
update_cdb_order
();
compute_products_coverage_qties
();
update_main_screen
();
update_main_screen
();
update_cdb_order
();
closeModal
();
closeModal
();
});
});
}
}
...
...
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