Add client financial year Accounting Mirror registry

This commit is contained in:
A R R R Associates
2026-09-18 20:58:41 +05:30
parent 93f2e02c35
commit 8a0d5b212d
11 changed files with 630 additions and 71 deletions
@@ -0,0 +1,52 @@
"""Accounting Mirror client/FY registry.
Revision ID: 20260918_accounting_mirror_reg
Revises: 20260903_tds_withholding_tools
"""
from alembic import op
import sqlalchemy as sa
revision = "20260918_accounting_mirror_reg"
down_revision = "20260903_tds_withholding_tools"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_table(
"accounting_mirror_registry",
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
sa.Column("tenant_id", sa.Integer(), sa.ForeignKey("tenants.id", ondelete="CASCADE"), nullable=False),
sa.Column("client_id", sa.Integer(), sa.ForeignKey("clients.id", ondelete="CASCADE"), nullable=False),
sa.Column("storage_node_id", sa.Integer(), sa.ForeignKey("branch_storage_nodes.id", ondelete="SET NULL"), nullable=True),
sa.Column("financial_year", sa.String(length=7), nullable=False),
sa.Column("accounting_relative_dir", sa.String(length=1000), nullable=False),
sa.Column("mirror_file_name", sa.String(length=255), nullable=False),
sa.Column("company_name", sa.String(length=255), nullable=False, server_default=""),
sa.Column("company_guid", sa.String(length=160), nullable=False, server_default=""),
sa.Column("voucher_from_date", sa.Date(), nullable=True),
sa.Column("voucher_to_date", sa.Date(), nullable=True),
sa.Column("file_size_bytes", sa.BigInteger(), nullable=False, server_default="0"),
sa.Column("status", sa.String(length=30), nullable=False, server_default="active"),
sa.Column("is_active", sa.Boolean(), nullable=False, server_default=sa.true()),
sa.Column("replacement_count", sa.Integer(), nullable=False, server_default="0"),
sa.Column("created_by_user_id", sa.Integer(), sa.ForeignKey("users.id", ondelete="SET NULL"), nullable=True),
sa.Column("last_synced_by_user_id", sa.Integer(), sa.ForeignKey("users.id", ondelete="SET NULL"), nullable=True),
sa.Column("created_at_utc", sa.DateTime(timezone=True), nullable=False),
sa.Column("last_synced_at_utc", sa.DateTime(timezone=True), nullable=True),
sa.Column("updated_at_utc", sa.DateTime(timezone=True), nullable=False),
sa.UniqueConstraint("tenant_id", "client_id", "financial_year", name="uq_accounting_mirror_registry_client_fy"),
)
for name, col in (
("ix_accounting_mirror_registry_tenant_id", "tenant_id"),
("ix_accounting_mirror_registry_client_id", "client_id"),
("ix_accounting_mirror_registry_storage_node_id", "storage_node_id"),
("ix_accounting_mirror_registry_financial_year", "financial_year"),
("ix_accounting_mirror_registry_status", "status"),
("ix_accounting_mirror_registry_is_active", "is_active"),
):
op.create_index(name, "accounting_mirror_registry", [col], unique=False)
def downgrade() -> None:
op.drop_table("accounting_mirror_registry")