feat: add KS-3/payments, tech debt fixes, UI polish, and KS-2 Excel/Word export

Tasks 008-016: KS-6a journal, KS-3 documents, payments with allocations,
tech debt cleanup, financial privacy, document tree, storno mechanism,
row-click UI, BOQ collapse/sticky header, and KS-2 export to Excel/Word
via shared DTO architecture.
This commit is contained in:
Арсентьев Александр
2026-09-27 13:38:45 +03:00
parent 6c608a8779
commit 9cfb341774
57 changed files with 7163 additions and 50 deletions
+37
View File
@@ -0,0 +1,37 @@
from sqlalchemy import Column, Date, DateTime, ForeignKey, Integer, Numeric, String, Text, UniqueConstraint
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from app.database.database import Base
class KS3(Base):
__tablename__ = "ks3_documents"
id = Column(Integer, primary_key=True, index=True)
project_id = Column(Integer, ForeignKey("projects.id"), nullable=False, index=True)
number = Column(String, nullable=False)
date = Column(Date, nullable=False, index=True)
reporting_period_from = Column(Date, nullable=True)
reporting_period_to = Column(Date, nullable=True)
comment = Column(Text)
status = Column(String, nullable=False, default="draft", index=True)
created_at = Column(DateTime, nullable=False, server_default=func.now())
updated_at = Column(DateTime, nullable=False, server_default=func.now(), onupdate=func.now())
project = relationship("Project")
links = relationship("KS3KS2", back_populates="ks3", cascade="all, delete-orphan")
class KS3KS2(Base):
__tablename__ = "ks3_ks2_links"
__table_args__ = (
UniqueConstraint("ks3_id", "ks2_id", name="uq_ks3_ks2_link"),
)
id = Column(Integer, primary_key=True, index=True)
ks3_id = Column(Integer, ForeignKey("ks3_documents.id", ondelete="CASCADE"), nullable=False, index=True)
ks2_id = Column(Integer, ForeignKey("ks2_documents.id"), nullable=False, index=True)
ks3 = relationship("KS3", back_populates="links")
ks2 = relationship("KS2")
+39
View File
@@ -0,0 +1,39 @@
from sqlalchemy import CheckConstraint, Column, Date, DateTime, ForeignKey, Integer, Numeric, String, Text, UniqueConstraint
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from app.database.database import Base
class Payment(Base):
__tablename__ = "payments"
id = Column(Integer, primary_key=True, index=True)
project_id = Column(Integer, ForeignKey("projects.id"), nullable=False, index=True)
date = Column(Date, nullable=False, index=True)
document_number = Column(String, nullable=True)
amount = Column(Numeric(18, 2), nullable=False)
currency = Column(String, nullable=False, default="RUB")
comment = Column(Text)
status = Column(String, nullable=False, default="active", index=True)
created_at = Column(DateTime, nullable=False, server_default=func.now())
updated_at = Column(DateTime, nullable=False, server_default=func.now(), onupdate=func.now())
project = relationship("Project")
allocations = relationship("PaymentAllocation", back_populates="payment", cascade="all, delete-orphan")
class PaymentAllocation(Base):
__tablename__ = "payment_allocations"
__table_args__ = (
UniqueConstraint("payment_id", "ks3_id", name="uq_payment_ks3"),
CheckConstraint("amount > 0", name="ck_payment_alloc_positive"),
)
id = Column(Integer, primary_key=True, index=True)
payment_id = Column(Integer, ForeignKey("payments.id", ondelete="CASCADE"), nullable=False, index=True)
ks3_id = Column(Integer, ForeignKey("ks3_documents.id"), nullable=False, index=True)
amount = Column(Numeric(18, 2), nullable=False)
payment = relationship("Payment", back_populates="allocations")
ks3 = relationship("KS3")