server: fix update stock

This commit is contained in:
King Kévin 2023-03-08 12:53:11 +01:00
parent cd601ede89
commit 3395d36c3c
1 changed files with 2 additions and 0 deletions

View File

@ -311,6 +311,8 @@ def add_part(part)
field = "location"
part[field] = nil if part[field] and 0 == part[field].length
if part[field] then
delete = @db.prepare("DELETE FROM inventory WHERE part = ?")
delete.execute(part["id"])
statement = @db.prepare("SELECT id FROM #{field} WHERE LOWER(name) = ?")
ref = statement.execute(part[field].downcase).to_a[0]
unless ref then