project budget updated
This commit is contained in:
157
databases/sql_models/building/budget.py
Normal file
157
databases/sql_models/building/budget.py
Normal file
@@ -0,0 +1,157 @@
|
||||
from sqlalchemy import (
|
||||
String,
|
||||
ForeignKey,
|
||||
Index,
|
||||
SmallInteger,
|
||||
Boolean,
|
||||
TIMESTAMP,
|
||||
Text,
|
||||
Numeric,
|
||||
Integer,
|
||||
)
|
||||
from sqlalchemy.orm import mapped_column, Mapped, relationship
|
||||
from databases.sql_models.core_mixin import CrudCollection
|
||||
|
||||
|
||||
class DecisionBookBudgetBooks(CrudCollection):
|
||||
|
||||
__tablename__ = "decision_book_budget_books"
|
||||
__exclude__fields__ = []
|
||||
|
||||
country: Mapped[str] = mapped_column(String, nullable=False)
|
||||
branch_type: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
|
||||
company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"), nullable=False)
|
||||
company_uu_id: Mapped[str] = mapped_column(String, nullable=False)
|
||||
branch_id: Mapped[int] = mapped_column(ForeignKey("companies.id"), nullable=True)
|
||||
branch_uu_id: Mapped[str] = mapped_column(
|
||||
String, comment="Branch UU ID", nullable=True
|
||||
)
|
||||
build_decision_book_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book.id"), nullable=False
|
||||
)
|
||||
build_decision_book_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Build Decision Book UU ID"
|
||||
)
|
||||
|
||||
__table_args__ = (
|
||||
Index(
|
||||
"_decision_book_budget_companies_book_ndx_00",
|
||||
company_id,
|
||||
CrudCollection.created_at,
|
||||
),
|
||||
{"comment": "budget Book Information"},
|
||||
)
|
||||
|
||||
|
||||
class DecisionBookBudgetCodes(CrudCollection):
|
||||
|
||||
__tablename__ = "decision_book_budget_codes"
|
||||
__exclude__fields__ = []
|
||||
|
||||
budget_code: Mapped[str] = mapped_column(
|
||||
String(48), nullable=False, comment="budget Code"
|
||||
)
|
||||
comment_line: Mapped[str] = mapped_column(
|
||||
Text, nullable=False, comment="Comment Line"
|
||||
)
|
||||
|
||||
build_decision_book_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_decision_book.id"), nullable=True
|
||||
)
|
||||
build_decision_book_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Build Decision Book UU ID"
|
||||
)
|
||||
|
||||
build_parts_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_parts.id"), nullable=True
|
||||
)
|
||||
build_parts_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Build Parts UU ID"
|
||||
)
|
||||
|
||||
company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"), nullable=True)
|
||||
company_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Company UU ID"
|
||||
)
|
||||
|
||||
__table_args__ = (
|
||||
Index("_decision_book_budget_codes_ndx_00", budget_code, "created_at"),
|
||||
Index("_decision_book_budget_codes_ndx_01", company_id, "created_at"),
|
||||
{"comment": "budget Book Information"},
|
||||
)
|
||||
|
||||
|
||||
class DecisionBookBudgetMaster(CrudCollection):
|
||||
|
||||
__tablename__ = "decision_book_budget_master"
|
||||
__exclude__fields__ = []
|
||||
|
||||
budget_type: Mapped[str] = mapped_column(
|
||||
String(50), nullable=False
|
||||
) # Bütçe tipi (örneğin: Operasyonel, Yatırım)
|
||||
currency: Mapped[str] = mapped_column(
|
||||
String(8), server_default="TRY"
|
||||
) # Bütçe para birimi
|
||||
total_budget: Mapped[float] = mapped_column(
|
||||
Numeric(10, 2), nullable=False
|
||||
) # Toplam bütçe
|
||||
|
||||
tracking_period_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("api_enum_dropdown.id"), nullable=True
|
||||
)
|
||||
tracking_period_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Part Direction UUID"
|
||||
)
|
||||
budget_books_id: Mapped[int] = mapped_column(
|
||||
Integer, ForeignKey("decision_book_budget_books.id"), nullable=False
|
||||
)
|
||||
budget_books_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Budget Books UU ID"
|
||||
)
|
||||
department_id: Mapped[int] = mapped_column(
|
||||
Integer, ForeignKey("departments.id"), nullable=False
|
||||
) # Departman ile ilişki
|
||||
department_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Department UU ID"
|
||||
)
|
||||
|
||||
__table_args__ = ({"comment": "budget Book Information"},)
|
||||
|
||||
|
||||
class DecisionBookBudgets(CrudCollection):
|
||||
|
||||
__tablename__ = "decision_book_budgets"
|
||||
__exclude__fields__ = []
|
||||
|
||||
process_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP, nullable=False
|
||||
) # Başlangıç tarihi
|
||||
budget_codes_id: Mapped[int] = mapped_column(
|
||||
Integer, ForeignKey("decision_book_budget_codes.id"), nullable=False
|
||||
)
|
||||
total_budget: Mapped[float] = mapped_column(
|
||||
Numeric(10, 2), nullable=False
|
||||
) # Toplam bütçe
|
||||
used_budget: Mapped[float] = mapped_column(
|
||||
Numeric(10, 2), nullable=False, default=0.0
|
||||
) # Kullanılan bütçe
|
||||
remaining_budget: Mapped[float] = mapped_column(
|
||||
Numeric(10, 2), nullable=False, default=0.0
|
||||
) # Kullanılan bütçe
|
||||
|
||||
decision_book_budget_master_id: Mapped[int] = mapped_column(
|
||||
Integer, ForeignKey("decision_book_budget_master.id"), nullable=False
|
||||
)
|
||||
decision_book_budget_master_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Decision Book Budget Master UU ID"
|
||||
)
|
||||
|
||||
__table_args__ = (
|
||||
Index(
|
||||
"_decision_book_budgets_ndx_00",
|
||||
decision_book_budget_master_uu_id,
|
||||
process_date,
|
||||
),
|
||||
{"comment": "budget Book Information"},
|
||||
)
|
||||
@@ -549,6 +549,7 @@ class BuildLivingSpace(CrudCollection):
|
||||
occupant_type_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Occupant Type UUID"
|
||||
)
|
||||
|
||||
__table_args__ = (
|
||||
{"comment": "Living Space inside building parts that are related to people"},
|
||||
)
|
||||
@@ -574,7 +575,6 @@ class BuildLivingSpace(CrudCollection):
|
||||
).data
|
||||
related_service = Services.filter_by_one(
|
||||
related_responsibility=occupant_type.occupant_code,
|
||||
**Services.valid_record_dict,
|
||||
).data
|
||||
|
||||
created_living_space.save_and_confirm()
|
||||
|
||||
@@ -883,14 +883,14 @@ class BuildDecisionBookPayments(CrudCollection):
|
||||
String, nullable=False, comment="Build Part UUID"
|
||||
)
|
||||
|
||||
budget_records_id: Mapped[int] = mapped_column(ForeignKey("account_records.id"), nullable=True)
|
||||
budget_records_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Budget UUID"
|
||||
)
|
||||
accounting_id: Mapped[int] = mapped_column(ForeignKey("account_detail.id"), nullable=True)
|
||||
accounting_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Accounting UUID"
|
||||
)
|
||||
# budget_records_id: Mapped[int] = mapped_column(ForeignKey("account_records.id"), nullable=True)
|
||||
# budget_records_uu_id: Mapped[str] = mapped_column(
|
||||
# String, nullable=True, comment="Budget UUID"
|
||||
# )
|
||||
# accounting_id: Mapped[int] = mapped_column(ForeignKey("account_detail.id"), nullable=True)
|
||||
# accounting_uu_id: Mapped[str] = mapped_column(
|
||||
# String, nullable=True, comment="Accounting UUID"
|
||||
# )
|
||||
# receive_debit_id: Mapped[int] = mapped_column(ForeignKey("api_enum_dropdown.id"), nullable=True)
|
||||
# receive_debit_uu_id: Mapped[str] = mapped_column(String, nullable=True, comment="Debit UUID")
|
||||
|
||||
@@ -920,11 +920,6 @@ class BuildDecisionBookPayments(CrudCollection):
|
||||
process_date,
|
||||
unique=True,
|
||||
),
|
||||
Index(
|
||||
"build_decision_book_payments_detail_ndx_01",
|
||||
budget_records_id,
|
||||
process_date,
|
||||
),
|
||||
{"comment": "Payment Details of Decision Book Payments"},
|
||||
)
|
||||
|
||||
@@ -1201,13 +1196,6 @@ class BuildDecisionBookProjectPerson(CrudCollection):
|
||||
String, nullable=True, comment="Living Space UUID"
|
||||
)
|
||||
|
||||
project_team_type_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("api_enum_dropdown.id"), nullable=True
|
||||
)
|
||||
project_team_type_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Management Type UUID"
|
||||
)
|
||||
|
||||
__table_args__ = (
|
||||
{"comment": "People that are attended to building project meetings."},
|
||||
)
|
||||
@@ -1245,6 +1233,7 @@ class BuildDecisionBookProjectItems(CrudCollection):
|
||||
{"comment": "Project Items related to decision taken at building meetings"},
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# class BuildDecisionBookPaymentsMaster(CrudCollection):
|
||||
# """
|
||||
|
||||
Reference in New Issue
Block a user