mirror of
https://codeberg.org/metamuffin/abrechenbarkeit.git
synced 2025-01-14 13:14:35 +00:00
add preliminary check to avoid adding same barcode twice or to multible products
This commit is contained in:
parent
e69972dc87
commit
49dbe1baa7
1 changed files with 11 additions and 0 deletions
|
@ -746,6 +746,17 @@ local function r_products_post()
|
|||
if barcode == nil or barcode:match(matchers_global.barcode) == nil then
|
||||
return error_box("{+error.invalid_barcode}")
|
||||
end
|
||||
local exists = false
|
||||
for _, a_barcode in read_barcodes() do
|
||||
if a_barcode == barcode then
|
||||
exists = true
|
||||
end
|
||||
end
|
||||
|
||||
if exists then
|
||||
return error_box("{+error.invalid_barcode}")
|
||||
end
|
||||
|
||||
local barcodes = io.open("barcodes", "a+")
|
||||
if barcodes == nil then
|
||||
return error_box("{+error.open_barcodes}")
|
||||
|
|
Loading…
Reference in a new issue