Add Phase 14 sales and income foundation
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from sqlalchemy import DateTime, Float, ForeignKey, Integer, String, Text, UniqueConstraint
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.core.db.common import CommonBase
|
||||
|
||||
|
||||
class AccountingSalesIncomeTransaction(CommonBase):
|
||||
__tablename__ = "accounting_sales_income_transactions"
|
||||
__table_args__ = (
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"client_id",
|
||||
"fingerprint",
|
||||
name="uq_accounting_sales_income_fingerprint",
|
||||
),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
tenant_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("tenants.id", ondelete="CASCADE"), nullable=False, index=True
|
||||
)
|
||||
client_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("clients.id", ondelete="CASCADE"), nullable=False, index=True
|
||||
)
|
||||
|
||||
source_type: Mapped[str] = mapped_column(String(30), nullable=False, default="outward_import", index=True)
|
||||
source_file_name: Mapped[str] = mapped_column(String(255), nullable=False, default="")
|
||||
fingerprint: Mapped[str] = mapped_column(String(80), nullable=False, index=True)
|
||||
|
||||
return_period: Mapped[str] = mapped_column(String(20), nullable=False, default="", index=True)
|
||||
document_type: Mapped[str] = mapped_column(String(40), nullable=False, default="Invoice", index=True)
|
||||
invoice_number: Mapped[str] = mapped_column(String(120), nullable=False, default="", index=True)
|
||||
invoice_date: Mapped[str] = mapped_column(String(20), nullable=False, default="", index=True)
|
||||
|
||||
customer_name: Mapped[str] = mapped_column(String(255), nullable=False, default="", index=True)
|
||||
customer_gstin: Mapped[str] = mapped_column(String(20), nullable=False, default="", index=True)
|
||||
place_of_supply: Mapped[str] = mapped_column(String(120), nullable=False, default="")
|
||||
supply_type: Mapped[str] = mapped_column(String(60), nullable=False, default="")
|
||||
export_type: Mapped[str] = mapped_column(String(60), nullable=False, default="")
|
||||
|
||||
hsn_code: Mapped[str] = mapped_column(String(20), nullable=False, default="", index=True)
|
||||
description_text: Mapped[str] = mapped_column(Text, nullable=False, default="")
|
||||
|
||||
taxable_value: Mapped[float] = mapped_column(Float, nullable=False, default=0)
|
||||
cgst: Mapped[float] = mapped_column(Float, nullable=False, default=0)
|
||||
sgst: Mapped[float] = mapped_column(Float, nullable=False, default=0)
|
||||
igst: Mapped[float] = mapped_column(Float, nullable=False, default=0)
|
||||
cess: Mapped[float] = mapped_column(Float, nullable=False, default=0)
|
||||
invoice_value: Mapped[float] = mapped_column(Float, nullable=False, default=0)
|
||||
|
||||
suggested_nature_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("accounting_natures.id", ondelete="SET NULL"), nullable=True, index=True
|
||||
)
|
||||
suggested_ledger_name: Mapped[str] = mapped_column(String(255), nullable=False, default="")
|
||||
suggested_confidence: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
suggestion_reason: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
|
||||
review_status: Mapped[str] = mapped_column(String(30), nullable=False, default="pending", index=True)
|
||||
final_nature_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("accounting_natures.id", ondelete="SET NULL"), nullable=True, index=True
|
||||
)
|
||||
final_ledger_name: Mapped[str] = mapped_column(String(255), nullable=False, default="")
|
||||
review_note: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
reviewed_by_user_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("users.id", ondelete="SET NULL"), nullable=True
|
||||
)
|
||||
reviewed_at_utc: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||
|
||||
created_by_user_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("users.id", ondelete="SET NULL"), nullable=True
|
||||
)
|
||||
created_at_utc: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), nullable=False, default=lambda: datetime.now(timezone.utc), index=True
|
||||
)
|
||||
updated_at_utc: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
nullable=False,
|
||||
default=lambda: datetime.now(timezone.utc),
|
||||
onupdate=lambda: datetime.now(timezone.utc),
|
||||
)
|
||||
Reference in New Issue
Block a user