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
f58946f8
Commit
f58946f8
authored
Jul 01, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display total order values
parent
1e31fc73
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
3 deletions
+76
-3
oders_helper_style.css
orders/static/css/oders_helper_style.css
+24
-2
orders_helper.js
orders/static/js/orders_helper.js
+42
-1
helper.html
templates/orders/helper.html
+10
-0
No files found.
orders/static/css/oders_helper_style.css
View file @
f58946f8
...
...
@@ -154,12 +154,34 @@
cursor
:
pointer
;
}
/* --
Bottom action button
*/
/* --
Footer
*/
#main_content_footer
{
margin
:
10px
0
35px
0
;
}
#footer_orders_recap
{
width
:
100%
;
display
:
flex
;
justify-content
:
space-evenly
;
margin-bottom
:
15px
;
}
#footer_actions
{
width
:
100%
;
display
:
flex
;
justify-content
:
space-between
;
margin
:
15px
0
35px
0
;
}
#suppliers_total_values
{
display
:
flex
;
}
.supplier_total_item
{
display
:
flex
;
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
}
/* -- Suppliers list */
...
...
orders/static/js/orders_helper.js
View file @
f58946f8
...
...
@@ -253,7 +253,7 @@ function add_supplier() {
const
user_input
=
$
(
"#supplier_input"
).
val
();
// Check if user input is a valid supplier
cons
t
supplier
=
suppliers_list
.
find
(
s
=>
s
.
display_name
===
user_input
);
le
t
supplier
=
suppliers_list
.
find
(
s
=>
s
.
display_name
===
user_input
);
if
(
supplier
===
undefined
)
{
alert
(
"Le fournisseur renseigné n'est pas valide.
\
n"
...
...
@@ -272,6 +272,7 @@ function add_supplier() {
openModal
();
supplier
.
total_value
=
0
;
selected_suppliers
.
push
(
supplier
);
let
url
=
"/orders/get_supplier_products"
;
...
...
@@ -468,6 +469,25 @@ function is_product_related_to_supplier(product, supplier) {
return
product
.
suppliersinfo
.
find
(
s
=>
s
.
supplier_id
===
supplier
.
id
)
!==
undefined
;
}
/**
* Calculate the total value purchased for all supplier
*/
function
_compute_total_values_by_supplier
()
{
// Reinit
for
(
let
s
of
selected_suppliers
)
{
s
.
total_value
=
0
;
}
for
(
let
p
of
products
)
{
for
(
let
supinfo
of
p
.
suppliersinfo
)
{
let
supplier_index
=
selected_suppliers
.
findIndex
(
s
=>
s
.
id
==
supinfo
.
supplier_id
);
let
product_supplier_value
=
(
'qty'
in
supinfo
)
?
supinfo
.
qty
*
supinfo
.
price
:
0
;
selected_suppliers
[
supplier_index
].
total_value
+=
product_supplier_value
;
}
}
}
/* - PRODUCT */
/**
...
...
@@ -1264,6 +1284,7 @@ function display_products(params) {
.
draw
();
update_cdb_order
();
display_total_values
();
}
else
{
$
(
this
).
val
(
''
);
}
...
...
@@ -1409,6 +1430,25 @@ function unselect_all_rows() {
}
/**
* Display the total values for each supplier & the global total value
*/
function
display_total_values
()
{
_compute_total_values_by_supplier
();
$
(
'#suppliers_total_values_container'
).
empty
();
let
total_values_content
=
'<ul>'
;
let
order_total_value
=
0
;
for
(
let
supplier
of
selected_suppliers
)
{
total_values_content
+=
`<li>
${
supplier
.
display_name
}
:
${
supplier
.
total_value
}
€</li>`
;
order_total_value
+=
supplier
.
total_value
;
}
total_values_content
+=
'</ul>'
;
$
(
'#suppliers_total_values_container'
).
append
(
total_values_content
);
$
(
'#order_total_value'
).
text
(
`
${
order_total_value
}
€`
);
}
/**
* Update DOM display on main screen
*/
function
update_main_screen
(
params
)
{
...
...
@@ -1422,6 +1462,7 @@ function update_main_screen(params) {
$
(
".order_name_container"
).
text
(
order_doc
.
_id
);
display_suppliers
();
display_products
(
params
);
display_total_values
();
// Re-select previously selected rows
if
(
selected_rows
.
length
>
0
)
{
...
...
templates/orders/helper.html
View file @
f58946f8
...
...
@@ -64,6 +64,15 @@
</div>
<div
id=
"main_content_footer"
style=
"display:none;"
>
<div
id=
"footer_orders_recap"
>
<div
id=
"suppliers_total_values"
>
<h4>
Total /fournisseur :
</h4><div
id=
"suppliers_total_values_container"
></div>
</div>
<div
id=
"order_total_value_container"
>
<h4>
Total :
<span
id=
"order_total_value"
></span></h4>
</div>
</div>
<div
id=
"footer_actions"
>
<div
class=
"add_product_container"
>
<div
id=
"product_form_container"
>
<form
action=
"javascript:;"
id=
"product_form"
>
...
...
@@ -77,6 +86,7 @@
</button>
</div>
</div>
</div>
<div
id=
"orders_created"
class=
"page_content"
style=
"display:none;"
>
<div
class=
"actions_buttons_area"
>
...
...
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