Files
he-database/fix_top_right_cells.py

37 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from sheets.models import MonthlySheet, Client, Cell
TOP_RIGHT_CLIENTS = [
"Dr. Fohrer", # L
"AG Buntk.", # M
"AG Alff", # N
"AG Gutfl.", # O
"M3 Thiele", # P
"M3 Buntkowsky", # Q
"M3 Gutfleisch", # R
]
ROW_COUNT = 16 # top_right rows 015
sheets = MonthlySheet.objects.all().order_by('year', 'month')
for sheet in sheets:
print(f"Fixing sheet {sheet.year}-{sheet.month}...")
for col_idx, name in enumerate(TOP_RIGHT_CLIENTS):
try:
client = Client.objects.get(name=name)
except Client.DoesNotExist:
print(f" WARNING: client {name!r} not found, skipping this column")
continue
for row_idx in range(ROW_COUNT):
cell, created = Cell.objects.get_or_create(
sheet=sheet,
table_type='top_right',
client=client,
row_index=row_idx,
column_index=col_idx,
defaults={'value': None},
)
if created:
print(f" created cell: {name} row {row_idx}")