feat: enforce KS-2/KS-3 stornation integrity

This commit is contained in:
Арсентьев Александр
2026-09-27 18:12:19 +03:00
parent 80b7d4732e
commit 9992a435b2
15 changed files with 947 additions and 20 deletions
+7
View File
@@ -37,6 +37,13 @@ def render_ks2_excel(doc: KS2ExportDocument) -> bytes:
c.alignment = Alignment(horizontal="center")
row += 1
if h.status == "cancelled":
ws.merge_cells(start_row=row, start_column=1, end_row=row, end_column=col_count)
c = ws.cell(row=row, column=1, value="СТОРНИРОВАН")
c.font = Font(bold=True, size=12, color="C00000")
c.alignment = Alignment(horizontal="center")
row += 1
# Unified project requisites
header_lines = project_requisite_lines(
project_name=h.project_name,
+7
View File
@@ -35,6 +35,13 @@ def render_ks3_excel(doc: KS3ExportDocument) -> bytes:
c.alignment = Alignment(horizontal="center")
row += 1
if h.status == "cancelled":
ws.merge_cells(start_row=row, start_column=1, end_row=row, end_column=col_count)
c = ws.cell(row=row, column=1, value="СТОРНИРОВАН")
c.font = Font(bold=True, size=12, color="C00000")
c.alignment = Alignment(horizontal="center")
row += 1
header_lines = project_requisite_lines(
project_name=h.project_name,
customer=h.customer,
+2
View File
@@ -27,6 +27,7 @@ class KS2ExportHeader:
period_from: date | None
period_to: date | None
comment: str
status: str
@dataclass(frozen=True)
@@ -68,5 +69,6 @@ def build_ks2_export_dto(db, ks2_document) -> KS2ExportDocument:
period_from=ks2_document.reporting_period_from,
period_to=ks2_document.reporting_period_to,
comment=ks2_document.comment or "",
status=ks2_document.status or "",
)
return KS2ExportDocument(header=header, items=items, total=total)
+2
View File
@@ -26,6 +26,7 @@ class KS3ExportHeader:
period_from: date | None
period_to: date | None
comment: str
status: str
@dataclass(frozen=True)
@@ -68,5 +69,6 @@ def build_ks3_export_dto(db, ks3_document) -> KS3ExportDocument:
period_from=ks3_document.reporting_period_from,
period_to=ks3_document.reporting_period_to,
comment=ks3_document.comment or "",
status=ks3_document.status or "",
)
return KS3ExportDocument(header=header, items=items, total=total)
+9 -1
View File
@@ -5,7 +5,7 @@ from docx import Document
from docx.enum.section import WD_ORIENT
from docx.enum.table import WD_TABLE_ALIGNMENT
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.shared import Pt
from docx.shared import Pt, RGBColor
from app.exporters.common import MONEY_TEXT, QTY_TEXT, format_period, project_requisite_lines
from app.exporters.ks2_dto import KS2ExportDocument
@@ -26,6 +26,14 @@ def render_ks2_word(doc: KS2ExportDocument) -> bytes:
run.bold = True
run.font.size = Pt(14)
if h.status == "cancelled":
mark = d.add_paragraph()
mark.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = mark.add_run("СТОРНИРОВАН")
run.bold = True
run.font.size = Pt(12)
run.font.color.rgb = RGBColor(0xC0, 0x00, 0x00)
d.add_paragraph()
header_lines = project_requisite_lines(
+9 -1
View File
@@ -5,7 +5,7 @@ from docx import Document
from docx.enum.section import WD_ORIENT
from docx.enum.table import WD_TABLE_ALIGNMENT
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.shared import Pt
from docx.shared import Pt, RGBColor
from app.exporters.common import MONEY_TEXT, format_date, format_period, project_requisite_lines
from app.exporters.ks3_dto import KS3ExportDocument
@@ -26,6 +26,14 @@ def render_ks3_word(doc: KS3ExportDocument) -> bytes:
run.bold = True
run.font.size = Pt(14)
if h.status == "cancelled":
mark = d.add_paragraph()
mark.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = mark.add_run("СТОРНИРОВАН")
run.bold = True
run.font.size = Pt(12)
run.font.color.rgb = RGBColor(0xC0, 0x00, 0x00)
d.add_paragraph()
header_lines = project_requisite_lines(