migrate.py: Update payment migration
This commit is contained in:
@ -1333,7 +1333,7 @@ def fix_deliveries(deliveries: Iterable[Dict[str, Any]]) -> Iterable[Tuple[str,
|
||||
|
||||
def migrate_deliveries(in_dir: str, out_dir: str) -> None:
|
||||
global DELIVERY_MAP, MODIFIER_MAP, SORT_MAP
|
||||
DELIVERY_MAP, MODIFIER_MAP, SORT_MAP = {}, {}, {}
|
||||
DELIVERY_MAP, MODIFIER_MAP, SORT_MAP = {}, {}, {'HU/': 'GV/HU', 'SV/': 'SW/'}
|
||||
|
||||
modifiers = {
|
||||
m['ASNR']: m
|
||||
@ -1439,8 +1439,7 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
|
||||
attributes.remove('F')
|
||||
|
||||
if d['SNR'] != sortid:
|
||||
SORT_MAP[f'{d["SNR"]}/{d["SANR"] or ""}'] = f'{sortid}/{",".join(list(attributes)) or ""}' \
|
||||
if len(attributes) > 0 else None
|
||||
SORT_MAP[f'{d["SNR"]}/{d["SANR"] or ""}'] = f'{sortid}/{",".join(list(attributes)) or ""}'
|
||||
line = f'{d["SNR"]}/{d["SANR"]} -> {sortid}/{",".join(list(attributes)) or None}'
|
||||
if line not in updated_varieties:
|
||||
updated_varieties[line] = 0
|
||||
@ -1611,9 +1610,9 @@ def migrate_payments(in_dir: str, out_dir: str) -> None:
|
||||
keys = list(n.keys())
|
||||
vals = list(n.values())
|
||||
if len(n) == 0:
|
||||
n = {'73oe': 0}
|
||||
n = {'15kmw': 0}
|
||||
elif len(n) == 1:
|
||||
n = {'73oe': list(n.values())[0]}
|
||||
n = {'15kmw': list(n.values())[0]}
|
||||
return n
|
||||
|
||||
with (utils.csv_open(f'{out_dir}/payment_variant.csv') as f_payment):
|
||||
@ -1647,7 +1646,7 @@ def migrate_payments(in_dir: str, out_dir: str) -> None:
|
||||
if s['Oechsle'] is None:
|
||||
continue
|
||||
key = SORT_MAP.get(f'{s["SNR"]}/{s["SANR"] or ""}', f'{s["SNR"].upper()}/{s["SANR"] or ""}')
|
||||
if key is None:
|
||||
if key is None or len(key) < 3:
|
||||
continue
|
||||
azs[key] = azs.get(key, {'Gebunden': {}, 'NichtGebunden': {}})
|
||||
azs[key]['Gebunden' if s['gebunden'] else 'NichtGebunden'][s['Oechsle']] = s['Betrag']
|
||||
@ -1703,10 +1702,10 @@ def migrate_payments(in_dir: str, out_dir: str) -> None:
|
||||
del q['ID']
|
||||
qualid = QUAL_MAP[q['QSNR']]
|
||||
key = SORT_MAP.get(f'{q["SNR"]}/{q["SANR"] or ""}', f'{q["SNR"].upper()}/{q["SANR"] or ""}')
|
||||
if key is None:
|
||||
if key is None or len(key) < 3:
|
||||
continue
|
||||
azq[qualid] = azq.get(qualid, {})
|
||||
azq[qualid][key] = q['Betrag']
|
||||
azq[qualid][key] = q['Betrag'] or 0
|
||||
for qualid, d1 in azq.items():
|
||||
azq[qualid] = collapse_data(d1)
|
||||
|
||||
|
Reference in New Issue
Block a user