Database: Add weighing_reason to delivery_part

This commit is contained in:
2023-09-14 23:23:59 +02:00
parent 93dd3f42f3
commit db51e069bc
2 changed files with 6 additions and 3 deletions

View File

@ -542,6 +542,7 @@ CREATE TABLE delivery_part (
scale_id TEXT, scale_id TEXT,
weighing_id TEXT, weighing_id TEXT,
weighing_reason TEXT CHECK (NOT (manual_weighing = TRUE AND weighing_reason IS NOT NULL)),
comment TEXT DEFAULT NULL, comment TEXT DEFAULT NULL,
ctime INTEGER NOT NULL DEFAULT (UNIXEPOCH()), ctime INTEGER NOT NULL DEFAULT (UNIXEPOCH()),

View File

@ -1354,7 +1354,7 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
f_delivery.header('year', 'did', 'date', 'time', 'zwstid', 'lnr', 'lsnr', 'mgnr', 'comment') f_delivery.header('year', 'did', 'date', 'time', 'zwstid', 'lnr', 'lsnr', 'mgnr', 'comment')
f_part.header('year', 'did', 'dpnr', 'sortid', 'weight', 'kmw', 'qualid', 'hkid', 'kgnr', 'rdnr', f_part.header('year', 'did', 'dpnr', 'sortid', 'weight', 'kmw', 'qualid', 'hkid', 'kgnr', 'rdnr',
'gerebelt', 'manual_weighing', 'spl_check', 'hand_picked', 'lesewagen', 'gerebelt', 'manual_weighing', 'spl_check', 'hand_picked', 'lesewagen',
'temperature', 'acid', 'scale_id', 'weighing_id', 'comment') 'temperature', 'acid', 'scale_id', 'weighing_id', 'weighing_reason', 'comment')
f_attr.header('year', 'did', 'dpnr', 'attrid') f_attr.header('year', 'did', 'dpnr', 'attrid')
for lsnr, linrs, date in fixed: for lsnr, linrs, date in fixed:
@ -1475,19 +1475,21 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
if comment.startswith('Säure'): if comment.startswith('Säure'):
acid = float(comment.split(' ')[-1].replace(',', '.')) acid = float(comment.split(' ')[-1].replace(',', '.'))
comment = None comment = None
elif comment == 'Maschine': elif comment in ('Maschine', 'Masschine'):
hand = False hand = False
comment = None comment = None
elif comment == 'Hand': elif comment == 'Hand':
hand = True hand = True
comment = None comment = None
elif comment == '.':
comment = None
if comment: if comment:
comments.append(comment) comments.append(comment)
gerebelt = True if CLIENT == WG.MATZEN or (CLIENT == WG.WINZERKELLER and zwstid == 'W') else d['Gerebelt'] or False gerebelt = True if CLIENT == WG.MATZEN or (CLIENT == WG.WINZERKELLER and zwstid == 'W') else d['Gerebelt'] or False
f_part.row( f_part.row(
date.year, snr, dpnr, sortid, int(d['Gewicht']), kmw, qualid, hkid, kgnr, rdnr, date.year, snr, dpnr, sortid, int(d['Gewicht']), kmw, qualid, hkid, kgnr, rdnr,
gerebelt, handwiegung, d['Spaetlese-Ueberpruefung'] or False, gerebelt, handwiegung, d['Spaetlese-Ueberpruefung'] or False,
hand, lesemaschine, d['Temperatur'], acid, scale_id, weighing_id, comment hand, lesemaschine, d['Temperatur'], acid, scale_id, weighing_id, None, comment
) )
for attrid in attributes: for attrid in attributes:
f_attr.row(date.year, snr, dpnr, attrid) f_attr.row(date.year, snr, dpnr, attrid)