From 49dbe1baa73ccda401293db4a0eaa0bd6f0e2175 Mon Sep 17 00:00:00 2001 From: "Riley L." Date: Thu, 2 Jan 2025 00:54:20 +0100 Subject: [PATCH] add preliminary check to avoid adding same barcode twice or to multible products --- abrechenbarkeit.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) 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}")