aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiley L. <riley@e926.de>2025-01-02 00:54:20 +0100
committerRiley L. <riley@e926.de>2025-01-02 00:54:20 +0100
commit49dbe1baa73ccda401293db4a0eaa0bd6f0e2175 (patch)
tree762281389d23aba07fcb3d8e9ad67beaade1906f
parente69972dc8760ce1ac18c57198dae489df900a692 (diff)
downloadabrechenbarkeit-49dbe1baa73ccda401293db4a0eaa0bd6f0e2175.tar
abrechenbarkeit-49dbe1baa73ccda401293db4a0eaa0bd6f0e2175.tar.bz2
abrechenbarkeit-49dbe1baa73ccda401293db4a0eaa0bd6f0e2175.tar.zst
add preliminary check to avoid adding same barcode twice or to multible products
-rwxr-xr-xabrechenbarkeit.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua
index dee8b4d..3291224 100755
--- a/abrechenbarkeit.lua
+++ b/abrechenbarkeit.lua
@@ -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}")