From 288a393719fe0c62d27bed40e330ec29a4cb4032 Mon Sep 17 00:00:00 2001 From: berkay Date: Tue, 26 Nov 2024 12:29:01 +0300 Subject: [PATCH] TIMESTAMP(timezone=True) updated --- databases/sql_models/account/account.py | 10 +++--- databases/sql_models/account/iban.py | 4 +-- databases/sql_models/building/budget.py | 2 +- databases/sql_models/building/build.py | 4 +-- .../sql_models/building/decision_book.py | 32 +++++++++---------- databases/sql_models/core_mixin.py | 4 +-- databases/sql_models/identity/identity.py | 8 ++--- service_app_banks/isbank/isbank_sender.py | 9 ------ 8 files changed, 32 insertions(+), 41 deletions(-) diff --git a/databases/sql_models/account/account.py b/databases/sql_models/account/account.py index b9e7abb..db48cf7 100644 --- a/databases/sql_models/account/account.py +++ b/databases/sql_models/account/account.py @@ -156,7 +156,7 @@ class AccountMaster(CrudCollection): __exclude__fields__ = [] 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_number: Mapped[int] = mapped_column( @@ -243,7 +243,7 @@ class AccountDetail(CrudCollection): __enum_list__ = [("plug_type", "AccountingReceiptTypes", "M")] 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( SmallInteger, nullable=False, comment="Line Number" @@ -385,7 +385,7 @@ class AccountRecords(CrudCollection): String(64), nullable=False, comment="IBAN Number of Bank" ) 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( @@ -434,7 +434,7 @@ class AccountRecords(CrudCollection): Boolean, server_default="0" ) 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") 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" # ) # 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( # Numeric(20, 6), nullable=False, comment="Currency Value" diff --git a/databases/sql_models/account/iban.py b/databases/sql_models/account/iban.py index 8492ed2..e4b338f 100644 --- a/databases/sql_models/account/iban.py +++ b/databases/sql_models/account/iban.py @@ -16,11 +16,11 @@ class BuildIbans(CrudCollection): String(40), server_default="", nullable=False, comment="IBAN number" ) 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( - 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") xcomment: Mapped[str] = mapped_column(String(64), server_default="????") diff --git a/databases/sql_models/building/budget.py b/databases/sql_models/building/budget.py index 8e9ef98..389be28 100644 --- a/databases/sql_models/building/budget.py +++ b/databases/sql_models/building/budget.py @@ -125,7 +125,7 @@ class DecisionBookBudgets(CrudCollection): __exclude__fields__ = [] process_date: Mapped[TIMESTAMP] = mapped_column( - TIMESTAMP, nullable=False + TIMESTAMP(timezone=True), nullable=False ) # Başlangıç tarihi budget_codes_id: Mapped[int] = mapped_column( Integer, ForeignKey("decision_book_budget_codes.id"), nullable=False diff --git a/databases/sql_models/building/build.py b/databases/sql_models/building/build.py index 2dd58c5..ddbd251 100644 --- a/databases/sql_models/building/build.py +++ b/databases/sql_models/building/build.py @@ -151,10 +151,10 @@ class Build(CrudCollection, SelectActionWithEmployee): SmallInteger, server_default="0", nullable=False, comment="Underground Floor" ) 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( - TIMESTAMP, + TIMESTAMP(timezone=True), server_default="1900-01-01", comment="Building annual ordinary meeting period", ) diff --git a/databases/sql_models/building/decision_book.py b/databases/sql_models/building/decision_book.py index 8cc5373..e151056 100644 --- a/databases/sql_models/building/decision_book.py +++ b/databases/sql_models/building/decision_book.py @@ -53,12 +53,12 @@ class BuildDecisionBook(CrudCollection): ) # is_out_sourced: Mapped[bool] = mapped_column(Boolean, server_default="0") 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") meeting_is_completed: Mapped[bool] = mapped_column(Boolean, server_default="0") 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) @@ -267,10 +267,10 @@ class BuildDecisionBookInvitations(CrudCollection): Text, nullable=True, comment="Invitation Message" ) 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( - TIMESTAMP, nullable=False, comment="Planned Meeting Date Expires" + TIMESTAMP(timezone=True), nullable=False, comment="Planned Meeting Date Expires" ) __table_args__ = ( @@ -345,16 +345,16 @@ class BuildDecisionBookPerson(CrudCollection): 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_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( - TIMESTAMP, nullable=False, comment="Confirmation Date" + TIMESTAMP(timezone=True), nullable=False, comment="Confirmation Date" ) is_attending: Mapped[bool] = mapped_column( Boolean, server_default="0", comment="Occupant is Attending to invitation" ) 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( String, server_default="", comment="Invitation Token" @@ -844,7 +844,7 @@ class BuildDecisionBookPayments(CrudCollection): String(10), nullable=False, comment="Payment Plan Time Periods" ) 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( Numeric(16, 2), nullable=False, comment="Payment Amount" @@ -945,17 +945,17 @@ class BuildDecisionBookLegal(CrudCollection): __exclude__fields__ = [] 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( String, nullable=False, comment="Lawsuits Decision Number" ) 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( - 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( String, server_default="", nullable=True @@ -967,10 +967,10 @@ class BuildDecisionBookLegal(CrudCollection): String, server_default="", nullable=True ) 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( - 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_name: Mapped[str] = mapped_column(String(128)) @@ -1027,10 +1027,10 @@ class BuildDecisionBookProjects(CrudCollection): String, nullable=False, comment="Project Name" ) 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( - 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_note: Mapped[str] = mapped_column(Text) @@ -1048,7 +1048,7 @@ class BuildDecisionBookProjects(CrudCollection): is_out_sourced: Mapped[bool] = mapped_column(Boolean, server_default="0") 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") bid_price: Mapped[float] = mapped_column(Numeric(16, 4), server_default="0") diff --git a/databases/sql_models/core_mixin.py b/databases/sql_models/core_mixin.py index d9855c6..7b567f8 100644 --- a/databases/sql_models/core_mixin.py +++ b/databases/sql_models/core_mixin.py @@ -80,10 +80,10 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes): valid_record_args = lambda class_: [class_.active == True, class_.deleted == False] 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( - TIMESTAMP, default="2099-12-31", server_default="2099-12-31" + TIMESTAMP(timezone=True), default="2099-12-31", server_default="2099-12-31" ) @classmethod diff --git a/databases/sql_models/identity/identity.py b/databases/sql_models/identity/identity.py index 5d2c29a..992528e 100644 --- a/databases/sql_models/identity/identity.py +++ b/databases/sql_models/identity/identity.py @@ -37,7 +37,7 @@ class UsersTokens(CrudCollection): token: Mapped[str] = mapped_column(String, server_default="") domain: Mapped[str] = mapped_column(String, server_default="") 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]) @@ -92,7 +92,7 @@ class Users(CrudCollection, UserLoginModule, SelectAction): ) password_expiry_begins: Mapped[TIMESTAMP] = mapped_column( "expiry_begins", - TIMESTAMP, + TIMESTAMP(timezone=True), server_default=func.now(), comment="Timestamp when password expiry begins", ) @@ -321,7 +321,7 @@ class People(CrudCollection, SelectAction): String, server_default="", comment="Birth place of the person" ) 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( 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.", ) contract_date: Mapped[TIMESTAMP] = mapped_column( - TIMESTAMP, + TIMESTAMP(timezone=True), server_default="2099-12-31 23:59:59", 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.", diff --git a/service_app_banks/isbank/isbank_sender.py b/service_app_banks/isbank/isbank_sender.py index 233a42a..af1b339 100644 --- a/service_app_banks/isbank/isbank_sender.py +++ b/service_app_banks/isbank/isbank_sender.py @@ -67,15 +67,6 @@ def is_bank_retrieve_account_records(bank_data): new_record_list = [] 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 - 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["import_file_name"] = str(data_keys) data_dict = BankReceive(**data_dict).model_dump()