database: add gebunden field to delivery_part

This commit is contained in:
2023-10-15 13:31:18 +02:00
parent 65ad166d87
commit 2143bf66e5
3 changed files with 31 additions and 24 deletions

View File

@ -597,14 +597,14 @@ def migrate_reeds(in_dir: str, out_dir: str) -> None:
def migrate_attributes(in_dir: str, out_dir: str) -> None:
with utils.csv_open(f'{out_dir}/wine_attribute.csv') as f:
f.header('attrid', 'name', 'max_kg_per_ha', 'active')
f.header('attrid', 'name', 'max_kg_per_ha', 'fill_lower_bins', 'active')
for a in utils.csv_parse_dict(f'{in_dir}/TSortenAttribute.csv'):
if a['SANR'] is None:
continue
f.row(a['SANR'], a['Attribut'], int(a['KgProHa']) if a['KgProHa'] is not None else None, True)
f.row(a['SANR'], a['Attribut'], int(a['KgProHa']) if a['KgProHa'] is not None else None, 0, True)
if CLIENT == WG.MATZEN:
f.row('M', 'Matzen', None, False)
f.row('HU', 'Huber', None, False)
f.row('M', 'Matzen', None, 0, False)
f.row('HU', 'Huber', None, 0, False)
def migrate_cultivations(in_dir: str, out_dir: str) -> None:
@ -1356,7 +1356,7 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
utils.csv_open(f'{out_dir}/delivery_part_attribute.csv') as f_attr:
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',
'gerebelt', 'manual_weighing', 'spl_check', 'hand_picked', 'lesewagen',
'gerebelt', 'manual_weighing', 'spl_check', 'hand_picked', 'lesewagen', 'gebunden',
'temperature', 'acid', 'scale_id', 'weighing_id', 'weighing_reason', 'comment')
f_attr.header('year', 'did', 'dpnr', 'attrid')
@ -1472,7 +1472,7 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
comment: Optional[str] = d['Anmerkung']
acid = d['Säure']
hand, lesemaschine = None, None
hand, lesewagen = None, None
if comment:
comment = comment.replace('Söure', 'Säure')
if comment.startswith('Säure'):
@ -1489,10 +1489,11 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
if comment:
comments.append(comment)
gerebelt = True if CLIENT == WG.MATZEN or (CLIENT == WG.WINZERKELLER and zwstid == 'W') else d['Gerebelt'] or False
gebunden = None if CLIENT in (WG.MATZEN, WG.WINZERKELLER) else d['Gebunden']
f_part.row(
date.year, snr, dpnr, sortid, int(d['Gewicht']), kmw, qualid, hkid, kgnr, rdnr,
gerebelt, handwiegung, d['Spaetlese-Ueberpruefung'] or False,
hand, lesemaschine, d['Temperatur'], acid, scale_id, weighing_id, None, comment
hand, lesewagen, gebunden, d['Temperatur'], acid, scale_id, weighing_id, None, comment
)
for attrid in attributes:
f_attr.row(date.year, snr, dpnr, attrid)