TIMESTAMP(timezone=True) updated

This commit is contained in:
berkay 2024-11-26 12:29:01 +03:00
parent 3539a26d77
commit 288a393719
8 changed files with 32 additions and 41 deletions

View File

@ -156,7 +156,7 @@ class AccountMaster(CrudCollection):
__exclude__fields__ = [] __exclude__fields__ = []
doc_date: Mapped[TIMESTAMP] = mapped_column( doc_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, nullable=False, comment="Document Date" TIMESTAMP(timezone=True), nullable=False, comment="Document Date"
) )
plug_type: Mapped[str] = mapped_column(String, nullable=False, comment="Plug Type") plug_type: Mapped[str] = mapped_column(String, nullable=False, comment="Plug Type")
plug_number: Mapped[int] = mapped_column( plug_number: Mapped[int] = mapped_column(
@ -243,7 +243,7 @@ class AccountDetail(CrudCollection):
__enum_list__ = [("plug_type", "AccountingReceiptTypes", "M")] __enum_list__ = [("plug_type", "AccountingReceiptTypes", "M")]
doc_date: Mapped[TIMESTAMP] = mapped_column( doc_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, nullable=False, comment="Document Date" TIMESTAMP(timezone=True), nullable=False, comment="Document Date"
) )
line_no: Mapped[int] = mapped_column( line_no: Mapped[int] = mapped_column(
SmallInteger, nullable=False, comment="Line Number" SmallInteger, nullable=False, comment="Line Number"
@ -385,7 +385,7 @@ class AccountRecords(CrudCollection):
String(64), nullable=False, comment="IBAN Number of Bank" String(64), nullable=False, comment="IBAN Number of Bank"
) )
bank_date: Mapped[TIMESTAMP] = mapped_column( bank_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, nullable=False, comment="Bank Transaction Date" TIMESTAMP(timezone=True), nullable=False, comment="Bank Transaction Date"
) )
currency_value: Mapped[float] = mapped_column( currency_value: Mapped[float] = mapped_column(
@ -434,7 +434,7 @@ class AccountRecords(CrudCollection):
Boolean, server_default="0" Boolean, server_default="0"
) )
accounting_receipt_date: Mapped[TIMESTAMP] = mapped_column( accounting_receipt_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, server_default="1900-01-01 00:00:00" TIMESTAMP(timezone=True), server_default="1900-01-01 00:00:00"
) )
accounting_receipt_number: Mapped[int] = mapped_column(Integer, server_default="0") accounting_receipt_number: Mapped[int] = mapped_column(Integer, server_default="0")
status_id: Mapped[int] = mapped_column(SmallInteger, server_default="0") status_id: Mapped[int] = mapped_column(SmallInteger, server_default="0")
@ -675,7 +675,7 @@ class AccountRecords(CrudCollection):
# String(5), nullable=False, comment="Unit of Currency" # String(5), nullable=False, comment="Unit of Currency"
# ) # )
# arc_processing_time: Mapped[TIMESTAMP] = mapped_column( # arc_processing_time: Mapped[TIMESTAMP] = mapped_column(
# TIMESTAMP, nullable=False, comment="Processing Time" # TIMESTAMP(timezone=True), nullable=False, comment="Processing Time"
# ) # )
# arc_currency_value: Mapped[float] = mapped_column( # arc_currency_value: Mapped[float] = mapped_column(
# Numeric(20, 6), nullable=False, comment="Currency Value" # Numeric(20, 6), nullable=False, comment="Currency Value"

View File

@ -16,11 +16,11 @@ class BuildIbans(CrudCollection):
String(40), server_default="", nullable=False, comment="IBAN number" String(40), server_default="", nullable=False, comment="IBAN number"
) )
start_date: Mapped[TIMESTAMP] = mapped_column( start_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, nullable=False, comment="Bank Transaction Start Date" TIMESTAMP(timezone=True), nullable=False, comment="Bank Transaction Start Date"
) )
stop_date: Mapped[TIMESTAMP] = mapped_column( stop_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, server_default="2900-01-01 00:00:00" TIMESTAMP(timezone=True), server_default="2900-01-01 00:00:00"
) )
bank_code: Mapped[str] = mapped_column(String(24), server_default="TR0000000000000") bank_code: Mapped[str] = mapped_column(String(24), server_default="TR0000000000000")
xcomment: Mapped[str] = mapped_column(String(64), server_default="????") xcomment: Mapped[str] = mapped_column(String(64), server_default="????")

View File

@ -125,7 +125,7 @@ class DecisionBookBudgets(CrudCollection):
__exclude__fields__ = [] __exclude__fields__ = []
process_date: Mapped[TIMESTAMP] = mapped_column( process_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, nullable=False TIMESTAMP(timezone=True), nullable=False
) # Başlangıç tarihi ) # Başlangıç tarihi
budget_codes_id: Mapped[int] = mapped_column( budget_codes_id: Mapped[int] = mapped_column(
Integer, ForeignKey("decision_book_budget_codes.id"), nullable=False Integer, ForeignKey("decision_book_budget_codes.id"), nullable=False

View File

@ -151,10 +151,10 @@ class Build(CrudCollection, SelectActionWithEmployee):
SmallInteger, server_default="0", nullable=False, comment="Underground Floor" SmallInteger, server_default="0", nullable=False, comment="Underground Floor"
) )
build_date: Mapped[TIMESTAMP] = mapped_column( build_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, server_default="1900-01-01" TIMESTAMP(timezone=True), server_default="1900-01-01"
) )
decision_period_date: Mapped[TIMESTAMP] = mapped_column( decision_period_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, TIMESTAMP(timezone=True),
server_default="1900-01-01", server_default="1900-01-01",
comment="Building annual ordinary meeting period", comment="Building annual ordinary meeting period",
) )

View File

@ -53,12 +53,12 @@ class BuildDecisionBook(CrudCollection):
) # ) #
is_out_sourced: Mapped[bool] = mapped_column(Boolean, server_default="0") is_out_sourced: Mapped[bool] = mapped_column(Boolean, server_default="0")
meeting_date: Mapped[TIMESTAMP] = mapped_column( meeting_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, server_default="1900-01-01" TIMESTAMP(timezone=True), server_default="1900-01-01"
) )
decision_type: Mapped[str] = mapped_column(String(3), server_default="RBM") decision_type: Mapped[str] = mapped_column(String(3), server_default="RBM")
meeting_is_completed: Mapped[bool] = mapped_column(Boolean, server_default="0") meeting_is_completed: Mapped[bool] = mapped_column(Boolean, server_default="0")
meeting_completed_date: Mapped[TIMESTAMP] = mapped_column( meeting_completed_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, nullable=True, comment="Meeting Completed Date" TIMESTAMP(timezone=True), nullable=True, comment="Meeting Completed Date"
) )
build_id: Mapped[int] = mapped_column(ForeignKey("build.id"), nullable=False) build_id: Mapped[int] = mapped_column(ForeignKey("build.id"), nullable=False)
@ -267,10 +267,10 @@ class BuildDecisionBookInvitations(CrudCollection):
Text, nullable=True, comment="Invitation Message" Text, nullable=True, comment="Invitation Message"
) )
planned_date: Mapped[TIMESTAMP] = mapped_column( planned_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, nullable=False, comment="Planned Meeting Date" TIMESTAMP(timezone=True), nullable=False, comment="Planned Meeting Date"
) )
planned_date_expires: Mapped[TIMESTAMP] = mapped_column( planned_date_expires: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, nullable=False, comment="Planned Meeting Date Expires" TIMESTAMP(timezone=True), nullable=False, comment="Planned Meeting Date Expires"
) )
__table_args__ = ( __table_args__ = (
@ -345,16 +345,16 @@ class BuildDecisionBookPerson(CrudCollection):
dues_percent_discount: Mapped[int] = mapped_column(SmallInteger, server_default="0") dues_percent_discount: Mapped[int] = mapped_column(SmallInteger, server_default="0")
dues_fix_discount: Mapped[float] = mapped_column(Numeric(10, 2), server_default="0") dues_fix_discount: Mapped[float] = mapped_column(Numeric(10, 2), server_default="0")
dues_discount_approval_date: Mapped[TIMESTAMP] = mapped_column( dues_discount_approval_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, server_default="1900-01-01 00:00:00" TIMESTAMP(timezone=True), server_default="1900-01-01 00:00:00"
) )
send_date: Mapped[TIMESTAMP] = mapped_column( send_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, nullable=False, comment="Confirmation Date" TIMESTAMP(timezone=True), nullable=False, comment="Confirmation Date"
) )
is_attending: Mapped[bool] = mapped_column( is_attending: Mapped[bool] = mapped_column(
Boolean, server_default="0", comment="Occupant is Attending to invitation" Boolean, server_default="0", comment="Occupant is Attending to invitation"
) )
confirmed_date: Mapped[TIMESTAMP] = mapped_column( confirmed_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, nullable=True, comment="Confirmation Date" TIMESTAMP(timezone=True), nullable=True, comment="Confirmation Date"
) )
token: Mapped[str] = mapped_column( token: Mapped[str] = mapped_column(
String, server_default="", comment="Invitation Token" String, server_default="", comment="Invitation Token"
@ -844,7 +844,7 @@ class BuildDecisionBookPayments(CrudCollection):
String(10), nullable=False, comment="Payment Plan Time Periods" String(10), nullable=False, comment="Payment Plan Time Periods"
) )
process_date: Mapped[TIMESTAMP] = mapped_column( process_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, nullable=False, comment="Payment Due Date" TIMESTAMP(timezone=True), nullable=False, comment="Payment Due Date"
) )
payment_amount: Mapped[float] = mapped_column( payment_amount: Mapped[float] = mapped_column(
Numeric(16, 2), nullable=False, comment="Payment Amount" Numeric(16, 2), nullable=False, comment="Payment Amount"
@ -945,17 +945,17 @@ class BuildDecisionBookLegal(CrudCollection):
__exclude__fields__ = [] __exclude__fields__ = []
period_start_date: Mapped[TIMESTAMP] = mapped_column( period_start_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, nullable=False, comment="Start Date of Legal Period" TIMESTAMP(timezone=True), nullable=False, comment="Start Date of Legal Period"
) )
lawsuits_decision_number: Mapped[str] = mapped_column( lawsuits_decision_number: Mapped[str] = mapped_column(
String, nullable=False, comment="Lawsuits Decision Number" String, nullable=False, comment="Lawsuits Decision Number"
) )
lawsuits_decision_date: Mapped[TIMESTAMP] = mapped_column( lawsuits_decision_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, nullable=False, comment="Lawsuits Decision Date" TIMESTAMP(timezone=True), nullable=False, comment="Lawsuits Decision Date"
) )
period_stop_date: Mapped[TIMESTAMP] = mapped_column( period_stop_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, server_default="2099-12-31 23:59:59" TIMESTAMP(timezone=True), server_default="2099-12-31 23:59:59"
) )
decision_book_pdf_path: Mapped[str] = mapped_column( decision_book_pdf_path: Mapped[str] = mapped_column(
String, server_default="", nullable=True String, server_default="", nullable=True
@ -967,10 +967,10 @@ class BuildDecisionBookLegal(CrudCollection):
String, server_default="", nullable=True String, server_default="", nullable=True
) )
contact_agreement_date: Mapped[TIMESTAMP] = mapped_column( contact_agreement_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, server_default="1900-01-01 00:00:00", nullable=True TIMESTAMP(timezone=True), server_default="1900-01-01 00:00:00", nullable=True
) )
meeting_date: Mapped[str] = mapped_column( meeting_date: Mapped[str] = mapped_column(
TIMESTAMP, server_default="1900-01-01 00:00:00" TIMESTAMP(timezone=True), server_default="1900-01-01 00:00:00"
) )
lawsuits_type: Mapped[str] = mapped_column(String(1), server_default="C") lawsuits_type: Mapped[str] = mapped_column(String(1), server_default="C")
lawsuits_name: Mapped[str] = mapped_column(String(128)) lawsuits_name: Mapped[str] = mapped_column(String(128))
@ -1027,10 +1027,10 @@ class BuildDecisionBookProjects(CrudCollection):
String, nullable=False, comment="Project Name" String, nullable=False, comment="Project Name"
) )
project_start_date: Mapped[TIMESTAMP] = mapped_column( project_start_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, nullable=False, comment="Project Start Date" TIMESTAMP(timezone=True), nullable=False, comment="Project Start Date"
) )
project_stop_date: Mapped[TIMESTAMP] = mapped_column( project_stop_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, server_default="2099-12-31 23:59:59" TIMESTAMP(timezone=True), server_default="2099-12-31 23:59:59"
) )
project_type: Mapped[str] = mapped_column(String, server_default="C") project_type: Mapped[str] = mapped_column(String, server_default="C")
project_note: Mapped[str] = mapped_column(Text) project_note: Mapped[str] = mapped_column(Text)
@ -1048,7 +1048,7 @@ class BuildDecisionBookProjects(CrudCollection):
is_out_sourced: Mapped[bool] = mapped_column(Boolean, server_default="0") is_out_sourced: Mapped[bool] = mapped_column(Boolean, server_default="0")
meeting_date: Mapped[TIMESTAMP] = mapped_column( meeting_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, server_default="1900-01-01 00:00:00", index=True TIMESTAMP(timezone=True), server_default="1900-01-01 00:00:00", index=True
) )
currency: Mapped[str] = mapped_column(String(8), server_default="TRY") currency: Mapped[str] = mapped_column(String(8), server_default="TRY")
bid_price: Mapped[float] = mapped_column(Numeric(16, 4), server_default="0") bid_price: Mapped[float] = mapped_column(Numeric(16, 4), server_default="0")

View File

@ -80,10 +80,10 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
valid_record_args = lambda class_: [class_.active == True, class_.deleted == False] valid_record_args = lambda class_: [class_.active == True, class_.deleted == False]
expiry_starts: Mapped[TIMESTAMP] = mapped_column( expiry_starts: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, server_default=func.now(), nullable=False TIMESTAMP(timezone=True), server_default=func.now(), nullable=False
) )
expiry_ends: Mapped[TIMESTAMP] = mapped_column( expiry_ends: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, default="2099-12-31", server_default="2099-12-31" TIMESTAMP(timezone=True), default="2099-12-31", server_default="2099-12-31"
) )
@classmethod @classmethod

View File

@ -37,7 +37,7 @@ class UsersTokens(CrudCollection):
token: Mapped[str] = mapped_column(String, server_default="") token: Mapped[str] = mapped_column(String, server_default="")
domain: Mapped[str] = mapped_column(String, server_default="") domain: Mapped[str] = mapped_column(String, server_default="")
expires_at: Mapped[TIMESTAMP] = mapped_column( expires_at: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, default=str(system_arrow.shift(date=system_arrow.now(), days=3)) TIMESTAMP(timezone=True), default=str(system_arrow.shift(date=system_arrow.now(), days=3))
) )
# users = relationship("Users", back_populates="tokens", foreign_keys=[user_id]) # users = relationship("Users", back_populates="tokens", foreign_keys=[user_id])
@ -92,7 +92,7 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
) )
password_expiry_begins: Mapped[TIMESTAMP] = mapped_column( password_expiry_begins: Mapped[TIMESTAMP] = mapped_column(
"expiry_begins", "expiry_begins",
TIMESTAMP, TIMESTAMP(timezone=True),
server_default=func.now(), server_default=func.now(),
comment="Timestamp when password expiry begins", comment="Timestamp when password expiry begins",
) )
@ -321,7 +321,7 @@ class People(CrudCollection, SelectAction):
String, server_default="", comment="Birth place of the person" String, server_default="", comment="Birth place of the person"
) )
birth_date: Mapped[TIMESTAMP] = mapped_column( birth_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, server_default="1900-01-01", comment="Birth date of the person" TIMESTAMP(timezone=True), server_default="1900-01-01", comment="Birth date of the person"
) )
tax_no: Mapped[str] = mapped_column( tax_no: Mapped[str] = mapped_column(
String, server_default="", comment="Tax number of the person" String, server_default="", comment="Tax number of the person"
@ -982,7 +982,7 @@ class Contracts(CrudCollection):
comment="contract_code is the unique code given by the system.", comment="contract_code is the unique code given by the system.",
) )
contract_date: Mapped[TIMESTAMP] = mapped_column( contract_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP, TIMESTAMP(timezone=True),
server_default="2099-12-31 23:59:59", server_default="2099-12-31 23:59:59",
comment="contract date is the date the contract is made. " comment="contract date is the date the contract is made. "
"expire start is the start date of the contract, expire en is the end date of the contract.", "expire start is the start date of the contract, expire en is the end date of the contract.",

View File

@ -67,15 +67,6 @@ def is_bank_retrieve_account_records(bank_data):
new_record_list = [] new_record_list = []
for data_keys in data_bulk: # data_bulk is a dict for data_keys in data_bulk: # data_bulk is a dict
for data_dict in data_bulk[data_keys]: # data_bulk[data_keys] is a list for data_dict in data_bulk[data_keys]: # data_bulk[data_keys] is a list
print(
'record json to create :',
dict(
bank_date=data_dict["bank_date"],
iban=data_dict["iban"],
bank_reference_code=data_dict["bank_reference_code"],
bank_balance=data_dict["balance"],
)
)
data_dict["bank_balance"] = data_dict.pop("balance") data_dict["bank_balance"] = data_dict.pop("balance")
data_dict["import_file_name"] = str(data_keys) data_dict["import_file_name"] = str(data_keys)
data_dict = BankReceive(**data_dict).model_dump() data_dict = BankReceive(**data_dict).model_dump()