Andrey Epifancev b2a89394c9 synthgen: словарь компаний, состав группы, выгрузка ЕЦП (#38)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-12 23:39:15 +04:00

30 lines
1.3 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.

"""Источник: synthetic-group/gen/ecp.py (#35). Выгрузка ЕЦП (спека §6.3): состав ГК, все компании — «Входит в ГСК».
Формат сверен с импортом ядра (`arm-core/api/src/domain/directory_import.py`): обязательные колонки ИНН,
iD ГК, Группа компаний, Организация, Тип; необязательные Базовый РФ ГК в CRM, ГСК, ГСЗ, КПП.
"""
from pathlib import Path
import openpyxl
from synthgen.group import Group
from synthgen.xlsx import save_deterministic
HEADER = ["ИНН", "КПП", "iD ГК", "Базовый РФ ГК в CRM", "Группа компаний", "Организация", "ГСК", "ГСЗ", "Тип"]
BASE_RF = "Ростовский региональный филиал" # как в #35
def write_ecp(group: Group, path: Path) -> None:
wb = openpyxl.Workbook()
ws = wb.active
assert ws is not None
ws.title = "Выписки"
ws.append(HEADER)
for m in group.members:
ws.append([m.inn, m.kpp, group.gk_id, BASE_RF, group.name, m.name, "Входит в ГСК", None, "ЮЛ"])
for row in ws.iter_rows(min_row=2, max_col=2):
for cell in row:
cell.number_format = "@" # ИНН и КПП — текстом
save_deterministic(wb, path)