first commit
This commit is contained in:
588
databases/sql_models/account/account.py
Normal file
588
databases/sql_models/account/account.py
Normal file
@@ -0,0 +1,588 @@
|
||||
from databases.sql_models.core_mixin import CrudCollection
|
||||
|
||||
from sqlalchemy.orm import mapped_column
|
||||
from sqlalchemy import (
|
||||
String,
|
||||
Integer,
|
||||
ForeignKey,
|
||||
Index,
|
||||
SmallInteger,
|
||||
Boolean,
|
||||
TIMESTAMP,
|
||||
Numeric,
|
||||
)
|
||||
|
||||
|
||||
class AccountBooks(CrudCollection):
|
||||
|
||||
__tablename__ = "account_books"
|
||||
__exclude__fields__ = []
|
||||
|
||||
country = mapped_column(String, nullable=False)
|
||||
branch_type = mapped_column(SmallInteger, server_default="0")
|
||||
# start_date = mapped_column(TIMESTAMP, nullable=False, comment="Account Start Date")
|
||||
# stop_date = mapped_column(TIMESTAMP, server_default="2900-01-01 00:00:00")
|
||||
|
||||
company_id = mapped_column(ForeignKey("companies.id"), nullable=False)
|
||||
company_uu_id = mapped_column(String, nullable=False)
|
||||
branch_id = mapped_column(ForeignKey("companies.id"))
|
||||
branch_uu_id = mapped_column(String, comment="Branch UU ID")
|
||||
|
||||
# company: Mapped["Companies"] = relationship(
|
||||
# "Company", back_populates="company_account_books", foreign_keys=[company_id]
|
||||
# )
|
||||
# branch: Mapped["Companies"] = relationship(
|
||||
# "Company", back_populates="branch_account_books", foreign_keys=[branch_id]
|
||||
# )
|
||||
# account_master: Mapped[List["AccountMaster"]] = relationship(
|
||||
# "AccountMaster",
|
||||
# back_populates="account_header",
|
||||
# foreign_keys="AccountMaster.account_header_id",
|
||||
# )
|
||||
# account_detail: Mapped[List["AccountDetail"]] = relationship(
|
||||
# "AccountDetail",
|
||||
# back_populates="account_header",
|
||||
# foreign_keys="AccountDetail.account_header_id",
|
||||
# )
|
||||
|
||||
__table_args__ = (
|
||||
Index(
|
||||
"account_companies_book_ndx_00", company_id, CrudCollection.expiry_starts
|
||||
),
|
||||
{"comment": "Account Book Information"},
|
||||
)
|
||||
|
||||
|
||||
class AccountCodes(CrudCollection):
|
||||
|
||||
__tablename__ = "account_codes"
|
||||
__exclude__fields__ = []
|
||||
|
||||
account_code = mapped_column(String(48), nullable=False, comment="Account Code")
|
||||
comment_line = mapped_column(String(128), nullable=False, comment="Comment Line")
|
||||
|
||||
is_receive_or_debit = mapped_column(Boolean)
|
||||
product_id = mapped_column(Integer, server_default="0")
|
||||
nvi_id = mapped_column(String(48), server_default="")
|
||||
status_id = mapped_column(SmallInteger, server_default="0")
|
||||
account_code_seperator = mapped_column(String(1), server_default=".")
|
||||
|
||||
system_id = mapped_column(SmallInteger, server_default="0")
|
||||
locked = mapped_column(SmallInteger, server_default="0")
|
||||
|
||||
company_id = mapped_column(ForeignKey("companies.id"))
|
||||
company_uu_id = mapped_column(String, nullable=False, comment="Company UU ID")
|
||||
customer_id = mapped_column(ForeignKey("companies.id"))
|
||||
customer_uu_id = mapped_column(String, nullable=False, comment="Customer UU ID")
|
||||
person_id = mapped_column(ForeignKey("people.id"))
|
||||
person_uu_id = mapped_column(String, nullable=False, comment="Person UU ID")
|
||||
|
||||
# company: Mapped["Companies"] = relationship(
|
||||
# "Company", back_populates="account_codes", foreign_keys=[company_id]
|
||||
# )
|
||||
# customer: Mapped["Companies"] = relationship(
|
||||
# "Company", back_populates="account_codes", foreign_keys=[customer_id]
|
||||
# )
|
||||
# person: Mapped["People"] = relationship(
|
||||
# "People", back_populates="account_codes", foreign_keys=[person_id]
|
||||
# )
|
||||
# account_detail: Mapped[List["AccountDetail"]] = relationship(
|
||||
# "AccountDetail",
|
||||
# back_populates="account_code",
|
||||
# foreign_keys="AccountDetail.account_code_id",
|
||||
# )
|
||||
#
|
||||
# account_code_parser: Mapped["AccountCodeParser"] = relationship(
|
||||
# "AccountCodeParser",
|
||||
# back_populates="account_codes",
|
||||
# foreign_keys="AccountCodeParser.account_code_id",
|
||||
# )
|
||||
|
||||
|
||||
class AccountCodeParser(CrudCollection):
|
||||
|
||||
__tablename__ = "account_code_parser"
|
||||
__exclude__fields__ = []
|
||||
|
||||
account_code_1 = mapped_column(String, nullable=False, comment="Order")
|
||||
account_code_2 = mapped_column(String, nullable=False, comment="Order")
|
||||
account_code_3 = mapped_column(String, nullable=False, comment="Order")
|
||||
account_code_4 = mapped_column(String, server_default="")
|
||||
account_code_5 = mapped_column(String, server_default="")
|
||||
account_code_6 = mapped_column(String, server_default="")
|
||||
|
||||
account_code_id = mapped_column(ForeignKey("account_codes.id"), nullable=False)
|
||||
account_code_uu_id = mapped_column(
|
||||
String, nullable=False, comment="Account Code UU ID"
|
||||
)
|
||||
|
||||
# account_codes: Mapped["AccountCodes"] = relationship(
|
||||
# "AccountCodes",
|
||||
# back_populates="account_code_parser",
|
||||
# foreign_keys=[account_code_id],
|
||||
# )
|
||||
|
||||
__table_args__ = (
|
||||
Index("_account_code_parser_ndx_00", account_code_id),
|
||||
{"comment": "Account Code Parser Information"},
|
||||
)
|
||||
|
||||
@property
|
||||
def get_account_code(self):
|
||||
return f"{self.account_codes.account_code_seperator}".join(
|
||||
[
|
||||
getattr(self, f"account_code_{i}")
|
||||
for i in range(1, 7)
|
||||
if getattr(self, f"account_code_{i}")
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class AccountMaster(CrudCollection):
|
||||
"""
|
||||
AccountCodes class based on declarative_base and CrudCollection via session
|
||||
"""
|
||||
|
||||
__tablename__ = "account_master"
|
||||
__exclude__fields__ = []
|
||||
|
||||
doc_date = mapped_column(TIMESTAMP, nullable=False, comment="Document Date")
|
||||
plug_type = mapped_column(String, nullable=False, comment="Plug Type")
|
||||
plug_number = mapped_column(Integer, nullable=False, comment="Plug Number")
|
||||
|
||||
special_code = mapped_column(String(12), server_default="")
|
||||
authorization_code = mapped_column(String(12), server_default="")
|
||||
|
||||
doc_code = mapped_column(String(12), server_default="")
|
||||
doc_type = mapped_column(SmallInteger, server_default="0")
|
||||
|
||||
comment_line1 = mapped_column(String, server_default="")
|
||||
comment_line2 = mapped_column(String, server_default="")
|
||||
comment_line3 = mapped_column(String, server_default="")
|
||||
comment_line4 = mapped_column(String, server_default="")
|
||||
comment_line5 = mapped_column(String, server_default="")
|
||||
comment_line6 = mapped_column(String, server_default="")
|
||||
project_code = mapped_column(String(12), server_default="")
|
||||
module_no = mapped_column(String, server_default="")
|
||||
journal_no = mapped_column(Integer, server_default="0")
|
||||
|
||||
status_id = mapped_column(SmallInteger, server_default="0")
|
||||
canceled = mapped_column(Boolean, server_default="0")
|
||||
print_count = mapped_column(SmallInteger, server_default="0")
|
||||
total_active = mapped_column(Numeric(20, 6), server_default="0")
|
||||
total_passive = mapped_column(Numeric(20, 6), server_default="0")
|
||||
total_active_1 = mapped_column(Numeric(20, 6), server_default="0")
|
||||
total_passive_1 = mapped_column(Numeric(20, 6), server_default="0")
|
||||
total_active_2 = mapped_column(Numeric(20, 6), server_default="0")
|
||||
total_passive_2 = mapped_column(Numeric(20, 6), server_default="0")
|
||||
total_active_3 = mapped_column(Numeric(20, 6), server_default="0")
|
||||
total_passive_3 = mapped_column(Numeric(20, 6), server_default="0")
|
||||
total_active_4 = mapped_column(Numeric(20, 6), server_default="0")
|
||||
total_passive_4 = mapped_column(Numeric(20, 6), server_default="0")
|
||||
cross_ref = mapped_column(Integer, server_default="0")
|
||||
data_center_id = mapped_column(String, server_default="")
|
||||
data_center_rec_num = mapped_column(Integer, server_default="0")
|
||||
|
||||
account_header_id = mapped_column(ForeignKey("account_books.id"), nullable=False)
|
||||
account_header_uu_id = mapped_column(
|
||||
String, nullable=False, comment="Account Header UU ID"
|
||||
)
|
||||
project_item_id = mapped_column(ForeignKey("build_decision_book_projects.id"))
|
||||
project_item_uu_id = mapped_column(String, comment="Project Item UU ID")
|
||||
department_id = mapped_column(ForeignKey("departments.id"))
|
||||
department_uu_id = mapped_column(String, comment="Department UU ID")
|
||||
|
||||
# account_header: Mapped["AccountBooks"] = relationship(
|
||||
# "AccountBooks",
|
||||
# back_populates="account_master",
|
||||
# foreign_keys=[account_header_id],
|
||||
# )
|
||||
# project_item: Mapped["BuildDecisionBookProjects"] = relationship(
|
||||
# "BuildDecisionBookProjects",
|
||||
# back_populates="account_master",
|
||||
# foreign_keys=[project_item_id],
|
||||
# )
|
||||
# account_detail: Mapped[List["AccountDetail"]] = relationship(
|
||||
# "AccountDetail",
|
||||
# back_populates="account_master",
|
||||
# foreign_keys="AccountDetail.account_master_id",
|
||||
# )
|
||||
|
||||
__table_args__ = (
|
||||
Index("_account_master_ndx_00", doc_date, account_header_id),
|
||||
{"comment": "Account Master Information"},
|
||||
)
|
||||
|
||||
|
||||
class AccountDetail(CrudCollection):
|
||||
"""
|
||||
AccountCodes class based on declarative_base and CrudCollection via session
|
||||
"""
|
||||
|
||||
__tablename__ = "account_detail"
|
||||
__exclude__fields__ = []
|
||||
__enum_list__ = [("plug_type", "AccountingReceiptTypes", "M")]
|
||||
|
||||
doc_date = mapped_column(TIMESTAMP, nullable=False, comment="Document Date")
|
||||
line_no = mapped_column(SmallInteger, nullable=False, comment="Line Number")
|
||||
receive_debit = mapped_column(String(1), nullable=False, comment="Receive Debit")
|
||||
debit = mapped_column(Numeric(20, 6), nullable=False, comment="Debit")
|
||||
|
||||
department = mapped_column(String(24), server_default="")
|
||||
special_code = mapped_column(String(12), server_default="")
|
||||
account_ref = mapped_column(Integer, server_default="0")
|
||||
account_fiche_ref = mapped_column(Integer, server_default="0")
|
||||
center_ref = mapped_column(Integer, server_default="0")
|
||||
general_code = mapped_column(String(32), server_default="")
|
||||
credit = mapped_column(Numeric(20, 6), server_default="0")
|
||||
currency_type = mapped_column(String(4), server_default="TL")
|
||||
exchange_rate = mapped_column(Numeric(20, 6), server_default="0")
|
||||
debit_cur = mapped_column(Numeric(20, 6), server_default="0")
|
||||
credit_cur = mapped_column(Numeric(20, 6), server_default="0")
|
||||
discount_cur = mapped_column(Numeric(20, 6), server_default="0")
|
||||
amount = mapped_column(Numeric(20, 6), server_default="0")
|
||||
cross_account_code = mapped_column(String(32), server_default="")
|
||||
inf_index = mapped_column(Numeric(20, 6), server_default="0")
|
||||
not_inflated = mapped_column(SmallInteger, server_default="0")
|
||||
not_calculated = mapped_column(SmallInteger, server_default="0")
|
||||
comment_line1 = mapped_column(String(64), server_default="")
|
||||
comment_line2 = mapped_column(String(64), server_default="")
|
||||
comment_line3 = mapped_column(String(64), server_default="")
|
||||
comment_line4 = mapped_column(String(64), server_default="")
|
||||
comment_line5 = mapped_column(String(64), server_default="")
|
||||
comment_line6 = mapped_column(String(64), server_default="")
|
||||
owner_acc_ref = mapped_column(Integer, server_default="0")
|
||||
from_where = mapped_column(Integer, server_default="0")
|
||||
orj_eid = mapped_column(Integer, server_default="0")
|
||||
canceled = mapped_column(SmallInteger, server_default="0")
|
||||
cross_ref = mapped_column(Integer, server_default="0")
|
||||
data_center_id = mapped_column(String, server_default="")
|
||||
data_center_rec_num = mapped_column(Integer, server_default="0")
|
||||
status_id = mapped_column(SmallInteger, server_default="0")
|
||||
|
||||
plug_type_id = mapped_column(ForeignKey("api_enum_dropdown.id"), nullable=True)
|
||||
plug_type_uu_id = mapped_column(String, nullable=False, comment="Plug Type UU ID")
|
||||
account_header_id = mapped_column(ForeignKey("account_books.id"), nullable=False)
|
||||
account_header_uu_id = mapped_column(
|
||||
String, nullable=False, comment="Account Header UU ID"
|
||||
)
|
||||
account_code_id = mapped_column(ForeignKey("account_codes.id"), nullable=False)
|
||||
account_code_uu_id = mapped_column(
|
||||
String, nullable=False, comment="Account Code UU ID"
|
||||
)
|
||||
account_master_id = mapped_column(ForeignKey("account_master.id"), nullable=False)
|
||||
account_master_uu_id = mapped_column(
|
||||
String, nullable=False, comment="Account Master UU ID"
|
||||
)
|
||||
project_id = mapped_column(ForeignKey("build_decision_book_projects.id"))
|
||||
project_uu_id = mapped_column(String, comment="Project UU ID")
|
||||
|
||||
# account_header: Mapped["AccountBooks"] = relationship(
|
||||
# "AccountBooks",
|
||||
# back_populates="account_detail",
|
||||
# foreign_keys=[account_header_id],
|
||||
# )
|
||||
# account_code: Mapped["AccountCodes"] = relationship(
|
||||
# "AccountCodes",
|
||||
# back_populates="account_detail",
|
||||
# foreign_keys=[account_code_id],
|
||||
# )
|
||||
# account_master: Mapped["AccountMaster"] = relationship(
|
||||
# "AccountMaster",
|
||||
# back_populates="account_detail",
|
||||
# foreign_keys=[account_master_id],
|
||||
# )
|
||||
# project: Mapped["BuildDecisionBookProjects"] = relationship(
|
||||
# "BuildDecisionBookProjects",
|
||||
# back_populates="account_detail",
|
||||
# foreign_keys=[project_id],
|
||||
# )
|
||||
# decision_book_payment_detail: Mapped["BuildDecisionBookPaymentsDetail"] = (
|
||||
# relationship(
|
||||
# "BuildDecisionBookPaymentsDetail",
|
||||
# back_populates="accounting",
|
||||
# foreign_keys="BuildDecisionBookPaymentsDetail.accounting_id",
|
||||
# )
|
||||
# )
|
||||
# decision_book_project_payment_detail: Mapped[
|
||||
# "BuildDecisionBookProjectPaymentsDetail"
|
||||
# ] = relationship(
|
||||
# "BuildDecisionBookProjectPaymentsDetail",
|
||||
# back_populates="accounting",
|
||||
# foreign_keys="BuildDecisionBookProjectPaymentsDetail.accounting_id",
|
||||
# )
|
||||
# decision_book_budget: Mapped["BuildDecisionBookBudget"] = relationship(
|
||||
# "BuildDecisionBookBudget",
|
||||
# back_populates="accounting",
|
||||
# foreign_keys="BuildDecisionBookBudget.accounting_id",
|
||||
# )
|
||||
|
||||
__table_args__ = (
|
||||
Index(
|
||||
"_account_detail_ndx_00",
|
||||
account_master_id,
|
||||
doc_date,
|
||||
line_no,
|
||||
account_header_id,
|
||||
unique=True,
|
||||
),
|
||||
{"comment": "Account Detail Information"},
|
||||
)
|
||||
|
||||
|
||||
class AccountRecords(CrudCollection):
|
||||
|
||||
__tablename__ = "account_records"
|
||||
__exclude__fields__ = []
|
||||
__enum_list__ = [
|
||||
("receive_debit", "DebitTypes", "D"),
|
||||
("budget_type", "BudgetType", "B"),
|
||||
]
|
||||
"""
|
||||
build_decision_book_id = kaydın sorumlu olduğu karar defteri
|
||||
send_company_id = kaydı gönderen firma, send_person_id = gönderen kişi
|
||||
customer_id = sorumlu kullanıcı bilgisi, company_id = sorumlu firma
|
||||
|
||||
"""
|
||||
|
||||
iban = mapped_column(String(64), nullable=False, comment="IBAN Number of Bank")
|
||||
bank_date = mapped_column(
|
||||
TIMESTAMP, nullable=False, comment="Bank Transaction Date"
|
||||
)
|
||||
|
||||
currency_value = mapped_column(
|
||||
Numeric(20, 6), nullable=False, comment="Currency Value"
|
||||
)
|
||||
bank_balance = mapped_column(Numeric(20, 6), nullable=False, comment="Bank Balance")
|
||||
currency = mapped_column(String(5), nullable=False, comment="Unit of Currency")
|
||||
additional_balance = mapped_column(
|
||||
Numeric(20, 6), nullable=False, comment="Additional Balance"
|
||||
)
|
||||
channel_branch = mapped_column(String(120), nullable=False, comment="Branch Bank")
|
||||
process_name = mapped_column(
|
||||
String, nullable=False, comment="Bank Process Type Name"
|
||||
)
|
||||
process_type = mapped_column(
|
||||
String, nullable=False, comment="Bank Process Type"
|
||||
)
|
||||
process_comment = mapped_column(
|
||||
String, nullable=False, comment="Transaction Record Comment"
|
||||
)
|
||||
bank_reference_code = mapped_column(
|
||||
String, nullable=False, comment="Bank Reference Code"
|
||||
)
|
||||
|
||||
add_comment_note = mapped_column(String, server_default="")
|
||||
is_receipt_mail_send = mapped_column(Boolean, server_default="0")
|
||||
found_from = mapped_column(String, server_default="")
|
||||
similarity = mapped_column(Numeric(20, 6), server_default="0")
|
||||
remainder_balance = mapped_column(Numeric(20, 6), server_default="0")
|
||||
|
||||
bank_date_y = mapped_column(Integer)
|
||||
bank_date_m = mapped_column(SmallInteger)
|
||||
bank_date_w = mapped_column(SmallInteger)
|
||||
bank_date_d = mapped_column(SmallInteger)
|
||||
|
||||
approving_accounting_record = mapped_column(Boolean, server_default="0")
|
||||
accounting_receipt_date = mapped_column(
|
||||
TIMESTAMP, server_default="1900-01-01 00:00:00"
|
||||
)
|
||||
accounting_receipt_number = mapped_column(Integer, server_default="0")
|
||||
status_id = mapped_column(SmallInteger, server_default="0")
|
||||
|
||||
approved_record = mapped_column(Boolean, server_default="0")
|
||||
import_file_name = mapped_column(String, nullable=True, comment="XLS Key")
|
||||
|
||||
receive_debit = mapped_column(ForeignKey("api_enum_dropdown.id"))
|
||||
receive_debit_uu_id = mapped_column(String, nullable=True, comment="Debit UU ID")
|
||||
budget_type = mapped_column(ForeignKey("api_enum_dropdown.uu_id"), nullable=True)
|
||||
budget_type_uu_id = mapped_column(
|
||||
String, nullable=True, comment="Budget Type UU ID"
|
||||
)
|
||||
|
||||
company_id = mapped_column(ForeignKey("companies.id"))
|
||||
company_uu_id = mapped_column(String, nullable=True, comment="Company UU ID")
|
||||
send_company_id = mapped_column(ForeignKey("companies.id"))
|
||||
send_company_uu_id = mapped_column(
|
||||
String, nullable=True, comment="Send Company UU ID"
|
||||
)
|
||||
|
||||
customer_id = mapped_column(ForeignKey("people.id"))
|
||||
customer_uu_id = mapped_column(String, nullable=True, comment="Customer UU ID")
|
||||
send_person_id = mapped_column(ForeignKey("people.id"))
|
||||
send_person_uu_id = mapped_column(
|
||||
String, nullable=True, comment="Send Person UU ID"
|
||||
)
|
||||
approving_accounting_person = mapped_column(ForeignKey("people.id"))
|
||||
approving_accounting_person_uu_id = mapped_column(
|
||||
String, nullable=True, comment="Approving Accounting Person UU ID"
|
||||
)
|
||||
# build_id = mapped_column(ForeignKey("build.id"), nullable=True)
|
||||
build_parts_id = mapped_column(ForeignKey("build_parts.id"))
|
||||
build_parts_uu_id = mapped_column(
|
||||
String, nullable=True, comment="Build Parts UU ID"
|
||||
)
|
||||
build_decision_book_id = mapped_column(ForeignKey("build_decision_book.id"))
|
||||
build_decision_book_uu_id = mapped_column(
|
||||
String, nullable=True, comment="Build Decision Book UU ID"
|
||||
)
|
||||
|
||||
# companies: Mapped[List["Company"]] = relationship(
|
||||
# "Company", back_populates="budget_records", foreign_keys=[company_id]
|
||||
# )
|
||||
# send_companies: Mapped[List["Company"]] = relationship(
|
||||
# "Company", back_populates="send_budget_records", foreign_keys=[send_company_id]
|
||||
# )
|
||||
#
|
||||
# parts: Mapped[List["BuildParts"]] = relationship(
|
||||
# "BuildParts", back_populates="budget_records", foreign_keys=[build_parts_id]
|
||||
# )
|
||||
# people: Mapped["People"] = relationship(
|
||||
# "People", back_populates="budget_records", foreign_keys=[customer_id]
|
||||
# )
|
||||
# send_person: Mapped["People"] = relationship(
|
||||
# "People", back_populates="budget_records", foreign_keys=[send_person_id]
|
||||
# )
|
||||
# decision_books: Mapped[List["BuildDecisionBook"]] = relationship(
|
||||
# "BuildDecisionBook",
|
||||
# back_populates="budget_records",
|
||||
# foreign_keys=[build_decision_book_id],
|
||||
# )
|
||||
#
|
||||
# decision_book_payment_detail: Mapped["BuildDecisionBookPaymentsDetail"] = (
|
||||
# relationship(
|
||||
# "BuildDecisionBookPaymentsDetail",
|
||||
# back_populates="budget_records",
|
||||
# foreign_keys="BuildDecisionBookPaymentsDetail.budget_records_id",
|
||||
# )
|
||||
# )
|
||||
#
|
||||
# decision_book_project_payments_detail: Mapped[
|
||||
# List["BuildDecisionBookProjectPaymentsDetail"]
|
||||
# ] = relationship(
|
||||
# "BuildDecisionBookProjectPaymentsDetail",
|
||||
# back_populates="budget_records",
|
||||
# foreign_keys="BuildDecisionBookProjectPaymentsDetail.budget_records_id",
|
||||
# )
|
||||
|
||||
__table_args__ = (
|
||||
Index("_budget_records_ndx_00", is_receipt_mail_send, bank_date),
|
||||
Index(
|
||||
"_budget_records_ndx_01",
|
||||
iban,
|
||||
bank_date,
|
||||
bank_reference_code,
|
||||
bank_balance,
|
||||
unique=True,
|
||||
),
|
||||
Index("_budget_records_ndx_02", status_id, bank_date),
|
||||
{
|
||||
"comment": "Bank Records that are related to building and financial transactions"
|
||||
},
|
||||
)
|
||||
#
|
||||
# def payment_budget_record_close(self):
|
||||
# from database_sql_models import (
|
||||
# DecisionBookProjectPaymentsMaster,
|
||||
# ApiEnumDropdown,
|
||||
# BuildDecisionBook,
|
||||
# BuildDecisionBookPaymentsMaster,
|
||||
# )
|
||||
#
|
||||
# budget_record = self
|
||||
# if self.receive_debit == ApiEnumDropdown.uuid_of_enum(
|
||||
# enum_class="DebitTypes", key="R"
|
||||
# ):
|
||||
# print(
|
||||
# "This record is not debit. Debit:",
|
||||
# self.receive_debit,
|
||||
# "DebitTypes.R.name",
|
||||
# # str(DebitTypes.R.name),
|
||||
# )
|
||||
# return
|
||||
# if abs(budget_record.currency_value + budget_record.remainder_balance) > 0:
|
||||
# payment_dict = {
|
||||
# "budget_records_id": self.id,
|
||||
# "build_decision_book_id": budget_record.build_decision_book_id,
|
||||
# "build_parts_id": budget_record.build_parts_id,
|
||||
# "start_date": budget_record.bank_date,
|
||||
# "paid_value": budget_record.currency_value
|
||||
# - budget_record.remainder_balance,
|
||||
# "is_all": False,
|
||||
# }
|
||||
# (paid_value, start_paid_value, balance) = (
|
||||
# float(budget_record.currency_value - budget_record.remainder_balance),
|
||||
# float(budget_record.currency_value - budget_record.remainder_balance),
|
||||
# float(budget_record.remainder_balance),
|
||||
# )
|
||||
# print(
|
||||
# "self.id",
|
||||
# self.id,
|
||||
# "paid_value",
|
||||
# paid_value,
|
||||
# "start_paid_value",
|
||||
# start_paid_value,
|
||||
# "balance",
|
||||
# balance,
|
||||
# self.receive_debit,
|
||||
# )
|
||||
#
|
||||
# if not BuildDecisionBook.find_one(
|
||||
# id=payment_dict["build_decision_book_id"]
|
||||
# ):
|
||||
# return paid_value
|
||||
#
|
||||
# if budget_record.replication_id == 55:
|
||||
# if paid_value > 0:
|
||||
# payment_dict["dues_type"] = ApiEnumDropdown.uuid_of_enum(
|
||||
# enum_class="BuildDuesTypes", key="L"
|
||||
# )
|
||||
# paid_value = (
|
||||
# DecisionBookProjectPaymentsMaster.pay_law_and_ren_of_build_part(
|
||||
# **payment_dict
|
||||
# )
|
||||
# )
|
||||
# print("dues_type", payment_dict["dues_type"], paid_value)
|
||||
# if paid_value > 0:
|
||||
# payment_dict.pop("dues_type", None)
|
||||
# paid_value = BuildDecisionBookPaymentsMaster.pay_dues_of_build_part(
|
||||
# **payment_dict
|
||||
# )
|
||||
# print("dues_type", None, paid_value)
|
||||
# if paid_value > 0:
|
||||
# payment_dict["dues_type"] = ApiEnumDropdown.uuid_of_enum(
|
||||
# enum_class="BuildDuesTypes", key="R"
|
||||
# )
|
||||
# paid_value = (
|
||||
# DecisionBookProjectPaymentsMaster.pay_law_and_ren_of_build_part(
|
||||
# **payment_dict
|
||||
# )
|
||||
# )
|
||||
# print("dues_type", payment_dict["dues_type"], paid_value)
|
||||
# payment_dict["is_all"] = True
|
||||
# if paid_value > 0:
|
||||
# payment_dict["dues_type"] = ApiEnumDropdown.uuid_of_enum(
|
||||
# enum_class="BuildDuesTypes", key="L"
|
||||
# )
|
||||
# paid_value = (
|
||||
# DecisionBookProjectPaymentsMaster.pay_law_and_ren_of_build_part(
|
||||
# **payment_dict
|
||||
# )
|
||||
# )
|
||||
# print("is all dues_type", payment_dict["dues_type"], paid_value)
|
||||
# if paid_value > 0:
|
||||
# payment_dict.pop("dues_type", None)
|
||||
# paid_value = BuildDecisionBookPaymentsMaster.pay_dues_of_build_part(
|
||||
# **payment_dict
|
||||
# )
|
||||
# print("is all dues_type", None, paid_value)
|
||||
# if paid_value > 0:
|
||||
# payment_dict["dues_type"] = ApiEnumDropdown.uuid_of_enum(
|
||||
# enum_class="BuildDuesTypes", key="R"
|
||||
# )
|
||||
# paid_value = (
|
||||
# DecisionBookProjectPaymentsMaster.pay_law_and_ren_of_build_part(
|
||||
# **payment_dict
|
||||
# )
|
||||
# )
|
||||
# print("is all dues_type", payment_dict["dues_type"], paid_value)
|
||||
101
databases/sql_models/account/iban.py
Normal file
101
databases/sql_models/account/iban.py
Normal file
@@ -0,0 +1,101 @@
|
||||
from sqlalchemy.orm import mapped_column
|
||||
from sqlalchemy import String, ForeignKey, Index, TIMESTAMP, SmallInteger
|
||||
|
||||
from databases.sql_models.core_mixin import CrudCollection
|
||||
|
||||
|
||||
class BuildIbans(CrudCollection):
|
||||
"""
|
||||
BuildParts class based on declarative_base and BaseMixin via session
|
||||
"""
|
||||
|
||||
__tablename__ = "build_ibans"
|
||||
__exclude__fields__ = []
|
||||
|
||||
iban = mapped_column(
|
||||
String(40), server_default="", nullable=False, comment="IBAN number"
|
||||
)
|
||||
start_date = mapped_column(
|
||||
TIMESTAMP, nullable=False, comment="Bank Transaction Start Date"
|
||||
)
|
||||
|
||||
stop_date = mapped_column(TIMESTAMP, server_default="2900-01-01 00:00:00")
|
||||
bank_code = mapped_column(String(24), server_default="TR0000000000000")
|
||||
xcomment = mapped_column(String(64), server_default="????")
|
||||
|
||||
build_id = mapped_column(
|
||||
ForeignKey("build.id"), nullable=False, comment="Building ID"
|
||||
)
|
||||
build_uu_id = mapped_column(
|
||||
String, nullable=False, comment="Building UUID", index=True
|
||||
)
|
||||
# building: Mapped["Build"] = relationship(
|
||||
# "Build", back_populates="build_ibans", foreign_keys=[build_id]
|
||||
# )
|
||||
|
||||
__table_args__ = (
|
||||
Index("_build_ibans_ndx_01", iban, start_date, unique=True),
|
||||
{"comment": "IBANs related to money transactions due to building objects"},
|
||||
)
|
||||
|
||||
# @property
|
||||
# def enums(self):
|
||||
# return_dict = {}
|
||||
# for key, enum in self.__enums_list__.items():
|
||||
# for enum_item in EnumDropdown.filter_by(enum_class=enum):
|
||||
# return_dict[key] = {
|
||||
# enum_item.get_dict(include=["key", "value", "description"])
|
||||
# }
|
||||
# return return_dict
|
||||
|
||||
|
||||
class BuildIbanDescription(CrudCollection):
|
||||
"""
|
||||
SearchComments class based on declarative_base and CrudCollection via session
|
||||
"""
|
||||
|
||||
__tablename__ = "build_iban_description"
|
||||
__exclude__fields__ = []
|
||||
|
||||
iban = mapped_column(String, nullable=False, comment="IBAN Number")
|
||||
group_id = mapped_column(SmallInteger, nullable=False, comment="Group ID")
|
||||
search_word = mapped_column(
|
||||
String, nullable=False, comment="Search Word", index=True
|
||||
)
|
||||
|
||||
decision_book_project_id = mapped_column(ForeignKey("build_decision_book_projects.id"))
|
||||
decision_book_project_uu_id = mapped_column(
|
||||
String, nullable=False, comment="Decision Book Project UUID"
|
||||
)
|
||||
customer_id = mapped_column(ForeignKey("people.id"))
|
||||
customer_uu_id = mapped_column(String, nullable=False, comment="Customer UUID")
|
||||
company_id = mapped_column(ForeignKey("companies.id"))
|
||||
company_uu_id = mapped_column(String, nullable=False, comment="Company UUID")
|
||||
build_parts_id = mapped_column(ForeignKey("build_parts.id"))
|
||||
build_parts_uu_id = mapped_column(
|
||||
String, nullable=False, comment="Build Parts UUID"
|
||||
)
|
||||
|
||||
# decision_book_project: Mapped["BuildDecisionBookProjects"] = relationship(
|
||||
# "BuildDecisionBookProjects",
|
||||
# back_populates="search_iban_description",
|
||||
# foreign_keys=[decision_book_project_id],
|
||||
# )
|
||||
# customer: Mapped["People"] = relationship(
|
||||
# "People", back_populates="search_iban_description", foreign_keys=[customer_id]
|
||||
# )
|
||||
# company: Mapped["Companies"] = relationship(
|
||||
# "Company", back_populates="search_iban_description", foreign_keys=[company_id]
|
||||
# )
|
||||
# parts: Mapped["BuildParts"] = relationship(
|
||||
# "BuildParts",
|
||||
# back_populates="search_iban_description",
|
||||
# foreign_keys=[build_parts_id],
|
||||
# )
|
||||
|
||||
__table_args__ = (
|
||||
Index(
|
||||
"_search_iban_description_ndx_00", iban, search_word, group_id, unique=True
|
||||
),
|
||||
{"comment": "Search Iban Description Information"},
|
||||
)
|
||||
Reference in New Issue
Block a user