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
20b89a57
Commit
20b89a57
authored
Jun 29, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AAC: integrate package qty
parent
37bd4c98
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
23 deletions
+74
-23
oders_helper_style.css
orders/static/css/oders_helper_style.css
+5
-0
orders_helper.js
orders/static/js/orders_helper.js
+69
-23
No files found.
orders/static/css/oders_helper_style.css
View file @
20b89a57
...
...
@@ -120,6 +120,11 @@
width
:
100px
;
}
.supplier_package_qty
{
font-style
:
italic
;
font-size
:
1.3rem
;
}
.product_not_from_supplier
{
background-color
:
#e7e9ed
;
cursor
:
pointer
;
...
...
orders/static/js/orders_helper.js
View file @
20b89a57
...
...
@@ -285,6 +285,7 @@ function save_supplier_product_association(product, supplier, cell) {
products_table
.
row
(
row
).
data
(
new_row_data
)
.
draw
();
update_cdb_order
();
closeModal
();
},
error
:
function
(
data
)
{
...
...
@@ -318,8 +319,13 @@ function save_supplier_products(supplier, new_products) {
if
(
index
===
-
1
)
{
products
.
push
(
np
);
}
else
{
np_supplierinfo
=
np
.
suppliersinfo
[
0
];
products
[
index
].
suppliersinfo
.
push
(
np_supplierinfo
);
// Prevent adding ducplicate supplierinfo
let
index_existing_supplierinfo
=
products
[
index
].
suppliersinfo
.
find
(
psi
=>
psi
.
supplier_id
==
supplier
.
id
);
if
(
index_existing_supplierinfo
===
-
1
)
{
np_supplierinfo
=
np
.
suppliersinfo
[
0
];
products
[
index
].
suppliersinfo
.
push
(
np_supplierinfo
);
}
}
}
}
...
...
@@ -803,9 +809,6 @@ function prepare_datatable_data(product_ids = []) {
}
for
(
product
of
products_to_format
)
{
// Calculate product's total qty to buy
let
qty_to_buy
=
0
;
let
item
=
{
id
:
product
.
id
,
name
:
product
.
name
,
...
...
@@ -815,19 +818,24 @@ function prepare_datatable_data(product_ids = []) {
purchase_ok
:
product
.
purchase_ok
,
uom
:
product
.
uom_id
[
1
]
};
// If product related to supplier: qty or null (qty to be set)
for
(
product_supplier
of
product
.
suppliersinfo
)
{
let
supplier_qty
=
(
"qty"
in
product_supplier
)
?
product_supplier
.
qty
:
null
;
item
[
supplier_column_name
(
product_supplier
)]
=
supplier_qty
;
let
qty_to_buy
=
0
;
// Calculate product's total qty to buy
let
p_package_qties
=
[];
// Look for differences in package qties
for
(
product_supplierinfo
of
product
.
suppliersinfo
)
{
// Set qty for input if product related to supplier: qty or null (qty to be set)
let
supplier_qty
=
(
"qty"
in
product_supplierinfo
)
?
product_supplierinfo
.
qty
:
null
;
item
[
supplier_column_name
(
product_supplierinfo
)]
=
supplier_qty
;
// Update product's total qty to buy if qty set for this supplier
if
(
supplier_qty
!==
null
)
{
// TODO calculate according to package_qty
qty_to_buy
+=
supplier_qty
;
qty_to_buy
+=
supplier_qty
*
product_supplierinfo
.
package_qty
;
}
p_package_qties
.
push
(
product_supplierinfo
.
package_qty
)
}
item
.
qty_to_buy
=
qty_to_buy
;
// If product not related to supplier: false;
for
(
supplier
of
selected_suppliers
)
{
if
(
!
is_product_related_to_supplier
(
product
,
supplier
))
{
...
...
@@ -835,7 +843,14 @@ function prepare_datatable_data(product_ids = []) {
}
}
item
.
qty_to_buy
=
qty_to_buy
;
if
(
p_package_qties
.
every
(
(
val
,
i
,
arr
)
=>
val
===
arr
[
0
]
))
{
// If all package qties are all equals, ok
item
.
package_qty
=
p_package_qties
[
0
];
}
else
{
// Else display an X
item
.
package_qty
=
'X'
}
data
.
push
(
item
);
}
...
...
@@ -909,15 +924,40 @@ function prepare_datatable_columns() {
if
(
data
===
false
)
{
return
`<div id="
${
base_id
}
_cell_content" class="cell_content">X</div>`
;
}
else
{
return
`<div id="
${
base_id
}
_cell_content" class="cell_content">
<input type="number" class="product_qty_input" id="
${
base_id
}
_qty_input" value=
${
data
}
>
</div>`
;
let
content
=
`<div id="
${
base_id
}
_cell_content" class="cell_content">
<input type="number" class="product_qty_input" id="
${
base_id
}
_qty_input" min="0" value=
${
data
}
>`
;
if
(
full
.
package_qty
===
'X'
)
{
let
product_data
=
products
.
find
(
p
=>
p
.
id
==
full
.
id
);
if
(
product_data
!==
undefined
)
{
let
supplierinfo
=
product_data
.
suppliersinfo
.
find
(
psi
=>
psi
.
supplier_id
==
supplier
.
id
);
content
+=
`<span class="supplier_package_qty">Colisage :
${
supplierinfo
.
package_qty
}
</span>`
;
}
}
content
+=
`</div>`
return
content
;
}
}
});
}
columns
.
push
({
data
:
"package_qty"
,
title
:
"Colisage"
,
className
:
"dt-body-center"
,
render
:
(
data
,
type
,
full
)
=>
{
if
(
full
.
package_qty
===
'X'
)
{
return
'<div class="tooltip">'
+
data
+
' <span class="tooltiptext tt_twolines">Colisages différents !</span></div>'
}
else
{
return
data
;
}
},
width
:
"4%"
});
columns
.
push
({
data
:
"uom"
,
title
:
"UDM"
,
className
:
"dt-body-center"
,
...
...
@@ -990,11 +1030,11 @@ function display_products(params) {
$
(
'#do_inventory'
).
show
();
// On inputs change
$
(
'#products_table'
).
on
(
'
input
'
,
'tbody td .product_qty_input'
,
function
()
{
$
(
'#products_table'
).
on
(
'
change
'
,
'tbody td .product_qty_input'
,
function
()
{
let
val
=
parseFloat
(
$
(
this
).
val
());
// If value is a number
if
(
!
isNaN
(
val
))
{
if
(
!
isNaN
(
val
)
&&
val
>=
0
)
{
const
id_split
=
$
(
this
).
attr
(
'id'
)
.
split
(
'_'
);
const
prod_id
=
id_split
[
1
];
...
...
@@ -1009,6 +1049,8 @@ function display_products(params) {
products_table
.
row
(
$
(
this
).
closest
(
'tr'
)).
data
(
new_row_data
).
draw
();
update_cdb_order
();
}
else
{
$
(
this
).
val
(
''
);
}
});
...
...
@@ -1041,18 +1083,22 @@ function display_products(params) {
// Find existing price in another supplierinfo
let
default_price
=
null
;
let
default_package_qty
=
1
;
// Default package qty is 1
for
(
let
psi
of
product
.
suppliersinfo
)
{
if
(
'price'
in
psi
&&
psi
.
price
!==
null
)
{
default_price
=
psi
.
price
;
break
;
}
if
(
'package_qty'
in
psi
&&
psi
.
package_qty
!==
null
)
{
default_package_qty
=
psi
.
package_qty
;
}
}
// Set default value for price & package qty for new supplierinfo
$
(
".new_product_supplier_package_pty"
).
val
(
1
);
// Default package qty is 1
$
(
".new_product_supplier_price"
).
val
(
default_price
);
// Default price is existing price for other suppli
er
$
(
".new_product_supplier_package_pty"
).
val
(
default_package_qty
);
$
(
".new_product_supplier_price"
).
val
(
default_price
);
// Default price is existing price for other supplier, or none if no oth
er
new_product_supplier_association
=
{
package_qty
:
1
,
package_qty
:
default_package_qty
,
price
:
default_price
}
...
...
@@ -1150,7 +1196,7 @@ function unselect_all_rows() {
*/
function
update_main_screen
(
params
)
{
// Remove listener before recreating them
$
(
'#products_table'
).
off
(
'
input
'
,
'tbody td .product_qty_input'
);
$
(
'#products_table'
).
off
(
'
change
'
,
'tbody td .product_qty_input'
);
$
(
'#products_table'
).
off
(
'click'
,
'tbody .product_not_from_supplier'
);
$
(
'#products_table'
).
off
(
'click'
,
'thead th #select_all_products_cb'
);
$
(
'#products_table'
).
off
(
'click'
,
'tbody td .select_product_cb'
);
...
...
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