database: remove delivery_part_attribute table
This commit is contained in:
@ -630,23 +630,23 @@ def migrate_cultivations(in_dir: str, out_dir: str) -> None:
|
||||
|
||||
def migrate_area_commitment_types(in_dir: str, out_dir: str) -> None:
|
||||
with utils.csv_open(f'{out_dir}/area_commitment_type.csv') as f:
|
||||
f.header('vtrgid', 'sortid', 'attrid_1', 'attrid_2', 'disc',
|
||||
f.header('vtrgid', 'sortid', 'attrid', 'disc',
|
||||
'min_kg_per_ha', 'max_kg_per_ha', 'penalty_amount')
|
||||
for t in utils.csv_parse_dict(f'{in_dir}/TLiefermengen.csv'):
|
||||
sortid: str = t['SNR']
|
||||
if not sortid or sortid == 'SV':
|
||||
continue
|
||||
menge = int(t['ErwarteteLiefermengeProHa'])
|
||||
f.row(sortid + (t['SANR'] or ''), sortid[:2], t['SANR'] or sortid[2:] or None, None, None,
|
||||
f.row(sortid + (t['SANR'] or ''), sortid[:2], t['SANR'] or sortid[2:] or None, None,
|
||||
menge, menge, None)
|
||||
bio = []
|
||||
if CLIENT == WG.MATZEN:
|
||||
bio = ['GV', 'ZW', 'MT']
|
||||
f.row('BM', 'BM', None, None, None, None, None, None)
|
||||
f.row('BM', 'BM', None, None, None, None, None)
|
||||
elif CLIENT == WG.WINZERKELLER:
|
||||
bio = ['GV', 'ZW', 'WR', 'MT', 'RR', 'WB', 'CH', 'MU']
|
||||
for sortid in bio:
|
||||
f.row(f'{sortid}B', sortid, 'B', None, None, None, None, None)
|
||||
f.row(f'{sortid}B', sortid, 'B', None, None, None, None)
|
||||
|
||||
|
||||
def normalize_name(family_name: str, given_name: str) -> Tuple[Optional[str], Optional[str], Optional[str], Optional[str], Optional[str], Optional[str]]:
|
||||
@ -1356,13 +1356,11 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
|
||||
updated_varieties = {}
|
||||
|
||||
with utils.csv_open(f'{out_dir}/delivery.csv') as f_delivery, \
|
||||
utils.csv_open(f'{out_dir}/delivery_part.csv') as f_part, \
|
||||
utils.csv_open(f'{out_dir}/delivery_part_attribute.csv') as f_attr:
|
||||
utils.csv_open(f'{out_dir}/delivery_part.csv') as f_part:
|
||||
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', 'attrid', 'weight', 'kmw', 'qualid', 'hkid', 'kgnr', 'rdnr',
|
||||
'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')
|
||||
|
||||
for lsnr, linrs, date in fixed:
|
||||
if date.year not in seasons:
|
||||
@ -1416,6 +1414,7 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
|
||||
if sortid == 'HU':
|
||||
# Gr.Veltliner (Huber)
|
||||
sortid = 'GV'
|
||||
attributes.remove('B')
|
||||
attributes.add('HU')
|
||||
elif sortid == 'SV':
|
||||
sortid = 'SW'
|
||||
@ -1500,13 +1499,14 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
|
||||
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']
|
||||
if len(attributes) > 1:
|
||||
print("ERROR: ", attributes)
|
||||
attrid = attributes.pop() if len(attributes) == 1 else None
|
||||
f_part.row(
|
||||
date.year, snr, dpnr, sortid, int(d['Gewicht']), kmw, qualid, hkid, kgnr, rdnr,
|
||||
date.year, snr, dpnr, sortid, attrid, int(d['Gewicht']), kmw, qualid, hkid, kgnr, rdnr,
|
||||
gerebelt, handwiegung, d['Spaetlese-Ueberpruefung'] or False,
|
||||
hand, lesewagen, gebunden, d['Temperatur'], acid, scale_id, weighing_id, None, comment
|
||||
)
|
||||
for attrid in attributes:
|
||||
f_attr.row(date.year, snr, dpnr, attrid)
|
||||
f_delivery.row(date.year, snr, date, d['Uhrzeit'], zwstid, lnr, lsnr, mgnr, '; '.join(comments) or None)
|
||||
for k, v in updated_varieties.items():
|
||||
print(k + (f' ({v} times)' if v > 1 else ''))
|
||||
|
Reference in New Issue
Block a user