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
a650f122
Commit
a650f122
authored
Jul 10, 2021
by
Colin MORAND
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modifié : stock/static/js/stock_movements.js
parent
ad361176
Pipeline
#1192
passed with stage
in 1 minute 23 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
24 deletions
+14
-24
stock_movements.js
stock/static/js/stock_movements.js
+14
-24
No files found.
stock/static/js/stock_movements.js
View file @
a650f122
...
...
@@ -162,34 +162,15 @@ function init_datatable() {
// Listener on inputs
$
(
'#products_table tbody'
).
on
(
'change'
,
'.stock_edit_input'
,
function
()
{
let
qty
=
$
(
this
).
val
();
let
row
=
products_table
.
row
(
$
(
this
).
parents
(
'tr'
));
let
data
=
row
.
data
();
let
validated_data
=
qty_validation
(
qty
,
data
.
uom
.
id
);
if
(
validated_data
>=
0
)
{
data
.
qty
=
validated_data
;
row
.
remove
().
draw
();
products_table
.
row
.
add
(
data
).
draw
();
}
else
{
data
.
qty
=
null
;
row
.
remove
().
draw
();
products_table
.
row
.
add
(
data
).
draw
();
if
(
validated_data
==
-
2
)
{
$
.
notify
(
"Ce produit est vendu à l'unité : la valeur doit être un nombre entier !"
,
{
globalPosition
:
"top right"
,
className
:
"error"
});
}
else
if
(
validated_data
==
-
1
||
validated_data
==
-
3
)
{
$
.
notify
(
"Valeur invalide."
,
{
globalPosition
:
"top right"
,
className
:
"error"
});
}
}
update_total_value
();
});
...
...
@@ -281,7 +262,7 @@ function get_stored_product_with_bc(barcode) {
function
fetch_product_from_bc
(
barcode
)
{
//console.log(barcode)
if
(
barcode
==
''
)
{
if
(
barcode
==
''
)
{
creation
reset_focus
();
return
-
1
;
...
...
@@ -441,20 +422,29 @@ var update_existing_product = function(product, added_qty, undo_option = false)
*/
function
qty_validation
(
qty
,
uom_id
)
{
if
(
qty
==
null
||
qty
==
''
)
{
$
.
notify
(
"Il n'y a pas de quantité indiquée, ou ce n'est pas un nombre"
,
{
globalPosition
:
"top right"
,
className
:
"error"
});
return
-
1
;
}
if
(
uom_id
==
1
)
{
if
(
qty
/
parseInt
(
qty
)
!=
1
&&
qty
!=
0
)
return
-
2
;
if
(
qty
/
parseInt
(
qty
)
!=
1
&&
qty
!=
0
){
$
.
notify
(
"Une quantité avec décimale est indiquée alors que c'est un article à l'unité"
,
{
globalPosition
:
"top right"
,
className
:
"error"
});
return
-
2
;}
qty
=
parseInt
(
qty
);
// product by unit
}
else
{
qty
=
parseFloat
(
qty
).
toFixed
(
2
);
}
if
(
isNaN
(
qty
))
return
-
3
;
if
(
isNaN
(
qty
)){
$
.
notify
(
"Une quantité n'est pas un nombre"
,
{
globalPosition
:
"top right"
,
className
:
"error"
});
return
-
3
;}
return
qty
;
}
...
...
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