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
a325f466
Commit
a325f466
authored
Dec 16, 2021
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1495 add percent adjustment to compute needed products
parent
5e8434ac
Pipeline
#1663
passed with stage
in 1 minute 32 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
2 deletions
+39
-2
oders_helper_style.css
orders/static/css/oders_helper_style.css
+17
-0
orders_helper.js
orders/static/js/orders_helper.js
+15
-0
helper.html
templates/orders/helper.html
+7
-2
No files found.
orders/static/css/oders_helper_style.css
View file @
a325f466
...
...
@@ -197,6 +197,23 @@
border-radius
:
3px
;
}
#coverage_form
>
div
{
display
:
inline-block
;
float
:
left
;
}
#coverage_form
.input-wrapper
{
margin-right
:
3px
;
}
#coverage_days_input
,
#percent_adjust_input
{
display
:
block
;
}
#coverage_days_input
{
margin-bottom
:
3px
;
}
/* -- Table */
#products_table_filter
{
text-align
:
right
!important
;
...
...
orders/static/js/orders_helper.js
View file @
a325f466
...
...
@@ -189,7 +189,14 @@ function add_product() {
* Set the computed qty for the first supplier only.
*/
function
compute_products_coverage_qties
()
{
const
pc_adjust
=
$
(
'#percent_adjust_input'
).
val
();
let
coeff
=
1
;
if
(
!
isNaN
(
parseFloat
(
pc_adjust
)))
{
coeff
=
(
1
+
parseFloat
(
pc_adjust
)
/
100
);
}
if
(
order_doc
.
coverage_days
!=
null
)
{
order_doc
.
coeff
=
coeff
;
for
(
const
[
key
,
product
...
...
@@ -202,12 +209,16 @@ function compute_products_coverage_qties() {
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
;
// Reduce to nb of packages to purchase
purchase_package_qty_for_coverage
=
purchase_qty_for_coverage
/
product
.
suppliersinfo
[
0
].
package_qty
;
if
(
order_doc
.
coeff
!=
1
)
{
purchase_package_qty_for_coverage
*=
order_doc
.
coeff
;
}
// Round up to unit for all products
purchase_package_qty_for_coverage
=
Math
.
ceil
(
purchase_package_qty_for_coverage
);
...
...
@@ -1885,6 +1896,10 @@ function update_main_screen(params) {
$
(
"#coverage_days_input"
).
val
(
''
);
}
if
(
order_doc
.
coeff
&&
order_doc
.
coeff
!=
1
)
{
$
(
"#percent_adjust_input"
).
val
(
-
Math
.
ceil
((
1
-
order_doc
.
coeff
)
*
100
));
}
if
(
order_doc
.
stats_date_period
!==
undefined
&&
order_doc
.
stats_date_period
!==
null
)
{
$
(
"#stats_date_period_select"
).
val
(
order_doc
.
stats_date_period
);
}
else
{
...
...
templates/orders/helper.html
View file @
a325f466
...
...
@@ -93,8 +93,13 @@
</select>
</form>
<form
action=
"javascript:;"
id=
"coverage_form"
class=
"order_form_item"
>
<input
type=
"number"
name=
"coverage_days"
id=
"coverage_days_input"
placeholder=
"Nb jours de couverture"
min=
"1"
>
<button
type=
"submit"
class=
'btn--primary'
>
Calculer les besoins
</button>
<i
class=
'main fa fa-info-circle fa-lg'
></i>
<div
class=
"input-wrapper"
>
<input
type=
"number"
name=
"coverage_days"
id=
"coverage_days_input"
placeholder=
"Nb jours de couverture"
min=
"1"
>
<input
type=
"number"
name=
"percent_adjustement"
id=
"percent_adjust_input"
placeholder=
"ajustement en % (+ ou -)"
>
</div>
<div>
<button
type=
"submit"
class=
'btn--primary'
>
Calculer les besoins
</button>
<i
class=
'main fa fa-info-circle fa-lg'
></i>
</div>
</form>
</div>
...
...
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