language_models updated

This commit is contained in:
2025-01-09 14:57:30 +03:00
parent 4fe1f36006
commit f4f9e584ff
26 changed files with 2346 additions and 187 deletions

View File

@@ -1,7 +1,3 @@
from api_validations.validations_request import ListOptions
from databases.language_models.account.account import AccountBooksLanguageModel
from databases.sql_models.core_mixin import CrudCollection
from sqlalchemy.orm import mapped_column, Mapped
from sqlalchemy import (
String,
@@ -14,6 +10,16 @@ from sqlalchemy import (
Numeric,
UUID,
)
from databases.sql_models.core_mixin import CrudCollection
from databases.language_models import (
AccountBooksLanguageModel,
AccountDetailLanguageModel,
AccountMasterLanguageModel,
AccountRecordExchangesLanguageModel,
AccountCodesLanguageModel,
AccountRecordsLanguageModel,
AccountCodeParserLanguageModel,
)
class AccountBooks(CrudCollection):
@@ -53,12 +59,11 @@ class AccountBooks(CrudCollection):
)
class AccountCodes(CrudCollection):
__tablename__ = "account_codes"
__exclude__fields__ = []
__language_model__ = AccountCodesLanguageModel
account_code: Mapped[str] = mapped_column(
String(48), nullable=False, comment="Account Code"
@@ -115,6 +120,7 @@ class AccountCodeParser(CrudCollection):
__tablename__ = "account_code_parser"
__exclude__fields__ = []
__language_model__ = AccountCodeParserLanguageModel
account_code_1: Mapped[str] = mapped_column(String, nullable=False, comment="Order")
account_code_2: Mapped[str] = mapped_column(String, nullable=False, comment="Order")
@@ -159,6 +165,7 @@ class AccountMaster(CrudCollection):
__tablename__ = "account_master"
__exclude__fields__ = []
__language_model__ = AccountMasterLanguageModel
doc_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP(timezone=True), nullable=False, comment="Document Date"
@@ -246,6 +253,7 @@ class AccountDetail(CrudCollection):
__tablename__ = "account_detail"
__exclude__fields__ = []
__enum_list__ = [("plug_type", "AccountingReceiptTypes", "M")]
__language_model__ = AccountDetailLanguageModel
doc_date: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP(timezone=True), nullable=False, comment="Document Date"
@@ -385,6 +393,7 @@ class AccountRecords(CrudCollection):
("receive_debit", "DebitTypes", "D"),
("budget_type", "BudgetType", "B"),
]
__language_model__ = AccountRecordsLanguageModel
iban: Mapped[str] = mapped_column(
String(64), nullable=False, comment="IBAN Number of Bank"
@@ -723,8 +732,10 @@ class AccountRecords(CrudCollection):
class AccountRecordExchanges(CrudCollection):
__tablename__ = "account_record_exchanges"
__exclude__fields__ = []
__language_model__ = AccountRecordExchangesLanguageModel
are_currency: Mapped[str] = mapped_column(
String(5), nullable=False, comment="Unit of Currency"

View File

@@ -76,7 +76,7 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
client_arrow: DateTimeLocal = None # The arrow to use in the model.
valid_record_dict: dict = {"active": True, "deleted": False}
valid_record_args = lambda class_: [class_.active == True, class_.deleted == False]
metadata: dict = {}
meta_data: dict = {}
expiry_starts: Mapped[TIMESTAMP] = mapped_column(
TIMESTAMP(timezone=True), server_default=func.now(), nullable=False
@@ -173,20 +173,20 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
cls.pre_query = None
if already_record:
if already_record.deleted:
already_record.metadata = {
already_record.meta_data = {
"created": False,
"error_case": "DeletedRecord",
"message": "",
}
return already_record
elif already_record.is_confirmed:
already_record.metadata = {
already_record.meta_data = {
"created": False,
"error_case": "IsNotConfirmed",
"message": "",
}
return already_record
already_record.metadata = {
already_record.meta_data = {
"created": False,
"error_case": "AlreadyExists",
"message": "",
@@ -202,7 +202,7 @@ class CrudMixin(Base, SmartQueryMixin, SessionMixin, FilterAttributes):
cls.created_by_id = cls.creds.get("person_id", None)
cls.created_by = cls.creds.get("person_name", None)
created_record.flush()
already_record.metadata = {"created": True, "error_case": None, "message": ""}
already_record.meta_data = {"created": True, "error_case": None, "message": ""}
return created_record
@classmethod
@@ -410,6 +410,7 @@ class CrudCollection(BaseMixin, SmartQueryMixin):
for i in response_model.__annotations__.keys():
headers_and_validation[i] = getattr(__language_model__, i, "Lang Not found")
# all_arguments = [
# record
# for record in self.__class__.__dict__
@@ -431,4 +432,4 @@ class CrudCollection(BaseMixin, SmartQueryMixin):
# return_dict[all_argument] = (
# populate_arg.get_dict() if populate_arg else []
# )
# return dict(sorted(return_dict.items(), reverse=False))
# return dict(sorted(return_dict.items(), reverse=False))