Do not use bio as attribute

This commit is contained in:
2024-02-19 21:58:28 +01:00
parent 977509fbe6
commit 0bbad83b75
6 changed files with 45 additions and 27 deletions

View File

@ -756,6 +756,8 @@ def migrate_attributes(in_dir: str, out_dir: str) -> None:
if attrid == 'BIO':
attrid = 'B'
ATTRIBUTE_MAP[a['SANR']] = attrid
if attrid == 'B':
continue
f.row(attrid, a['Attribut'], True, max_kg, False, 0)
if CLIENT == WG.MATZEN:
f.row('M', 'Matzen', False, None, False, 0)
@ -783,9 +785,14 @@ def migrate_cultivations(in_dir: str, out_dir: str) -> None:
cultid = name[0].upper()
if name.isupper():
cultid = name
elif name == 'Normal':
cultid = None
elif 'biolog' in name.lower():
cultid = 'BIO'
cultid = 'B'
name = 'Bio'
CULTIVATION_MAP[c['BANR']] = cultid
if cultid is None:
continue
f.row(cultid, name, None)
@ -803,14 +810,8 @@ def migrate_area_commitment_types(in_dir: str, out_dir: str) -> None:
attrid = ATTRIBUTE_MAP[t['SANR']] if t['SANR'] else None
f.row(sortid + (attrid or ''), sortid[:2], attrid or sortid[2:] or None, None, menge,
None, None, None)
bio = []
if CLIENT == WG.MATZEN:
bio = ['GV', 'ZW', 'MT']
f.row('BM', 'BM', None, 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('BM', 'BM', None, None, None, 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]]:
@ -1449,6 +1450,8 @@ def migrate_area_commitments(in_dir: str, out_dir: str) -> None:
to = fb['Bis'] if fb['Bis'] and fb['Bis'] < 3000 else None
attrid = ATTRIBUTE_MAP[fb['SANR']] if fb['SANR'] else None
if attrid == 'B':
attrid = None
f_fb.row(fbnr, mgnr, fb['SNR'] + (attrid or ''), CULTIVATION_MAP[fb['BANR'] or 1], area,
kgnr, gstnr, rdnr, fb['Von'], to, comment)
@ -1560,9 +1563,9 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
with utils.csv_open(f'{out_dir}/delivery.csv') as f_delivery, \
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', '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_part.header('year', 'did', 'dpnr', 'sortid', 'attrid', 'cultid', 'weight', 'kmw', 'qualid',
'hkid', 'kgnr', 'rdnr', 'gerebelt', 'manual_weighing', 'spl_check', 'hand_picked', 'lesewagen',
'gebunden', 'temperature', 'acid', 'scale_id', 'weighing_id', 'weighing_reason', 'comment')
for lsnr, linrs, date in fixed:
if date.year not in seasons:
@ -1607,7 +1610,10 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
kmw = GRADATION_MAP[oe]
sortid = d['SNR'].upper()
attrid = ATTRIBUTE_MAP[d['SANR']] if d['SANR'] else None
if attrid:
cultid = None
if attrid == 'B':
cultid = 'B'
elif attrid:
attributes.add(attrid)
if len(sortid) != 2:
attributes.add(sortid[2:])
@ -1716,7 +1722,7 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
print("ERROR: ", attributes)
attrid = attributes.pop() if len(attributes) == 1 else None
f_part.row(
date.year, snr, dpnr, sortid, attrid, int(d['Gewicht']), kmw, qualid, hkid, kgnr, rdnr,
date.year, snr, dpnr, sortid, attrid, cultid, 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
)
@ -1928,7 +1934,7 @@ def migrate_payments(in_dir: str, out_dir: str) -> None:
variant_year_map[year] = []
variant_year_map[year].append((p['AZNR'], year_map[year], p['TeilzahlungNr']))
f_payment.row(year, year_map[year], p['Titel'], p['Datum'], test, None,
p['Beschreibung'], json.dumps(data))
p['Beschreibung'], json.dumps(data).replace('/B', '/-B').replace('"/-B"', '"-B"'))
with utils.csv_open(f'{out_dir}/payment_delivery_part.csv') as f_del_pay, \
utils.csv_open(f'{out_dir}/delivery_part_bucket.csv') as f_bucket: