feat: official KS-2 Excel/Word forms with template markers and single-table flow

Replace the simplified KS-2 exports with the official unified form:

- Excel: official blank as working template, merge-safe row insertion,
  compact layout, header/signer polish, 0.00 money format
- Word: official blank via named template markers (DOC-C4), one dynamic
  works table with repeating header rows, separate closing totals block
  (Итого / Всего по акту), system group rows merged across 8 columns
- Word money formatter (space thousands, comma decimals) and split
  contract date day/month/year boxes
- Issue persists both xlsx and docx artifacts; UI keeps Excel and adds
  Word download
- Daily reports: multi-system item selection in the form

Regression tests for renderers, artifacts and layout; docs/tasks +
docs/implementation for the DOC-C* series.
This commit is contained in:
Арсентьев Александр
2026-10-03 19:48:29 +03:00
parent 79c7d4f335
commit bd64bb6307
49 changed files with 6917 additions and 353 deletions
+19
View File
@@ -13,6 +13,8 @@ class KS2ExportItem:
quantity: Decimal
unit_price: Decimal
amount: Decimal
group_header: str | None = None
group_code: str | None = None
@dataclass(frozen=True)
@@ -55,10 +57,25 @@ def build_ks2_export_dto(db, ks2_document) -> KS2ExportDocument:
project = ks2_document.project
items = []
total = D("0")
current_group = None
for idx, line in enumerate(ks2_document.items, start=1):
wi = line.work_item
amount = D(str(line.amount or 0))
total += amount
# Determine group header from System → Section hierarchy
group_header = None
group_code = None
if wi is not None:
system_name = wi.system.name if wi.system else None
system_code = wi.system.code if wi.system else None
section_name = wi.section.name if wi.section else None
if system_name and system_name != current_group:
group_header = system_name
group_code = system_code
current_group = system_name
elif section_name and system_name is None and section_name != current_group:
group_header = section_name
current_group = section_name
items.append(KS2ExportItem(
row_number=idx,
source_number=wi.source_number or "",
@@ -67,6 +84,8 @@ def build_ks2_export_dto(db, ks2_document) -> KS2ExportDocument:
quantity=D(str(line.quantity or 0)),
unit_price=D(str(line.unit_price or 0)),
amount=amount,
group_header=group_header,
group_code=group_code,
))
header = KS2ExportHeader(