payment re-arragend tru raw sql
This commit is contained in:
@@ -79,11 +79,11 @@ def super_build_create_callable(data, headers: CommonHeaders):
|
||||
|
||||
Build.set_session(db_session)
|
||||
Addresses.set_session(db_session)
|
||||
BuildTypes.set_session(db_session)
|
||||
ApiEnumDropdown.set_session(db_session)
|
||||
BuildSites.set_session(db_session)
|
||||
|
||||
address_id = Addresses.query.filter(Addresses.uu_id == data.address_uu_id).first()
|
||||
build_types_id = BuildTypes.query.filter(BuildTypes.uu_id == data.build_types_uu_id).first()
|
||||
build_types_id = ApiEnumDropdown.query.filter(ApiEnumDropdown.uu_id == data.build_types_uu_id).first()
|
||||
sites_id = BuildSites.query.filter(BuildSites.uu_id == data.site_uu_id).first()
|
||||
build = Build.create(**data.model_dump(), address_id=getattr(address_id, "id", None), build_types_id=getattr(build_types_id, "id", None), site_id=getattr(sites_id, "id", None))
|
||||
build.save()
|
||||
@@ -104,11 +104,11 @@ def super_build_update_callable(uu_id: str, data, headers: CommonHeaders):
|
||||
with Build.new_session() as db_session:
|
||||
Build.set_session(db_session)
|
||||
Addresses.set_session(db_session)
|
||||
BuildTypes.set_session(db_session)
|
||||
ApiEnumDropdown.set_session(db_session)
|
||||
BuildSites.set_session(db_session)
|
||||
|
||||
address_id = Addresses.query.filter(Addresses.uu_id == data.address_uu_id).first()
|
||||
build_types_id = BuildTypes.query.filter(BuildTypes.uu_id == data.build_types_uu_id).first()
|
||||
build_types_id = ApiEnumDropdown.query.filter(ApiEnumDropdown.uu_id == data.build_types_uu_id).first()
|
||||
sites_id = BuildSites.query.filter(BuildSites.uu_id == data.site_uu_id).first()
|
||||
|
||||
build = Build.query.filter(Build.uu_id == uu_id).first()
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
from pydantic import BaseModel
|
||||
from Schemas import BuildTypes, ApiEnumDropdown
|
||||
from Schemas import ApiEnumDropdown
|
||||
|
||||
|
||||
class InsertBuildTypes(BaseModel):
|
||||
function_code: str
|
||||
type_code: str
|
||||
lang: str
|
||||
type_name: str
|
||||
# class InsertBuildTypes(BaseModel):
|
||||
# function_code: str
|
||||
# type_code: str
|
||||
# lang: str
|
||||
# type_name: str
|
||||
|
||||
|
||||
def init_api_enums_build_types(db_session):
|
||||
|
||||
BuildTypes.set_session(db_session)
|
||||
# BuildTypes.set_session(db_session)
|
||||
ApiEnumDropdown.set_session(db_session)
|
||||
|
||||
insert_types = [
|
||||
@@ -71,24 +71,59 @@ def init_api_enums_build_types(db_session):
|
||||
},
|
||||
]
|
||||
|
||||
for insert_type in insert_types:
|
||||
build_types = InsertBuildTypes(
|
||||
function_code="EVYOS",
|
||||
lang=insert_type["lang"],
|
||||
type_code=str(insert_type["type_code"]).upper(),
|
||||
type_name=insert_type["type_name"],
|
||||
)
|
||||
created_build_type = BuildTypes.query.filter_by(
|
||||
function_code=build_types.function_code,
|
||||
type_code=build_types.type_code,
|
||||
).first()
|
||||
if not created_build_type:
|
||||
created_build_type = BuildTypes.find_or_create(
|
||||
**build_types.model_dump(), is_confirmed=True, db=db_session
|
||||
)
|
||||
created_build_type.save()
|
||||
# for insert_type in insert_types:
|
||||
# build_types = dict(enum_class="BuildTypes", key=insert_type["type_code"], value=insert_type["type_name"])
|
||||
# created_build_type = ApiEnumDropdown.query.filter_by(enum_class="BuildTypes", **build_types).first()
|
||||
# if not created_build_type:
|
||||
# created_build_type = ApiEnumDropdown.find_or_create(**build_types, is_confirmed=True, db=db_session)
|
||||
# created_build_type.save()
|
||||
|
||||
insert_enums = [
|
||||
{
|
||||
"enum_class": "BuildTypes",
|
||||
"type_code": "APT_KZN",
|
||||
"type_name": "Apartman Kazan Dairesi",
|
||||
},
|
||||
{
|
||||
"enum_class": "BuildTypes",
|
||||
"type_code": "APT_GRJ",
|
||||
"type_name": "Apartman Garaj",
|
||||
},
|
||||
{
|
||||
"enum_class": "BuildTypes",
|
||||
"type_code": "APT_DP",
|
||||
"type_name": "Apartman Depo",
|
||||
},
|
||||
{
|
||||
"enum_class": "BuildTypes",
|
||||
"type_code": "DAIRE",
|
||||
"type_name": "Apartman Dairesi",
|
||||
},
|
||||
{
|
||||
"enum_class": "BuildTypes",
|
||||
"type_code": "APT",
|
||||
"type_name": "Apartman Binası",
|
||||
},
|
||||
{
|
||||
"enum_class": "BuildTypes",
|
||||
"type_code": "APT_YNT",
|
||||
"type_name": "Apartman Yönetimi",
|
||||
},
|
||||
{
|
||||
"enum_class": "BuildTypes",
|
||||
"type_code": "APT_PRK",
|
||||
"type_name": "Apartman Açık Park Alanı",
|
||||
},
|
||||
{
|
||||
"enum_class": "BuildTypes",
|
||||
"type_code": "APT_YSL",
|
||||
"type_name": "Apartman Yeşil Alan",
|
||||
},
|
||||
{
|
||||
"enum_class": "BuildTypes",
|
||||
"type_code": "APT_YOL",
|
||||
"type_name": "Apartman Ara Yol",
|
||||
},
|
||||
{"enum_class": "BuildDuesTypes", "type_code": "BDT-D", "type_name": "Debit"},
|
||||
{
|
||||
"enum_class": "BuildDuesTypes",
|
||||
@@ -274,6 +309,7 @@ def init_api_enums_build_types(db_session):
|
||||
created_api_enum = ApiEnumDropdown.query.filter_by(
|
||||
enum_class=insert_enum["enum_class"],
|
||||
key=str(insert_enum["type_code"]).upper(),
|
||||
lang="tr",
|
||||
).first()
|
||||
if not created_api_enum:
|
||||
created_api_enum = ApiEnumDropdown.create(
|
||||
|
||||
@@ -8,7 +8,7 @@ from Schemas import (
|
||||
People,
|
||||
Build,
|
||||
BuildParts,
|
||||
BuildTypes,
|
||||
# BuildTypes,
|
||||
ApiEnumDropdown,
|
||||
Companies,
|
||||
OccupantTypes,
|
||||
@@ -23,7 +23,7 @@ def create_occupant_defaults(db_session):
|
||||
People.set_session(db_session)
|
||||
Build.set_session(db_session)
|
||||
BuildParts.set_session(db_session)
|
||||
BuildTypes.set_session(db_session)
|
||||
# BuildTypes.set_session(db_session)
|
||||
ApiEnumDropdown.set_session(db_session)
|
||||
Companies.set_session(db_session)
|
||||
OccupantTypes.set_session(db_session)
|
||||
@@ -34,7 +34,7 @@ def create_occupant_defaults(db_session):
|
||||
|
||||
company_id, company_uu_id = company_management.id, str(company_management.uu_id)
|
||||
active_row = dict(is_confirmed=True, active=True, deleted=False, is_notification_send=True)
|
||||
build_type = BuildTypes.query.filter_by(type_code = "APT").first()
|
||||
build_type = ApiEnumDropdown.query.filter_by(enum_class = "BuildTypes", key = "APT").first()
|
||||
address = Addresses.query.filter_by(letter_address = "Example Address").first()
|
||||
|
||||
created_build = Build.query.filter_by(build_name = "Build Example").first()
|
||||
@@ -52,8 +52,8 @@ def create_occupant_defaults(db_session):
|
||||
)
|
||||
created_list.append(created_build)
|
||||
|
||||
build_type_created = BuildTypes.query.filter_by(type_code = "APT").first()
|
||||
build_type_flat = BuildTypes.query.filter_by(type_code = "DAIRE").first()
|
||||
build_type_created = ApiEnumDropdown.query.filter_by(enum_class = "BuildTypes", key = "APT").first()
|
||||
build_type_flat = ApiEnumDropdown.query.filter_by(enum_class = "BuildTypes", key = "DAIRE").first()
|
||||
enum_dropdown = ApiEnumDropdown.query.filter_by(key = "NE", enum_class = "Directions").first()
|
||||
|
||||
occupant_type_prs = OccupantTypes.query.filter_by(occupant_code = "MT-PRS").first()
|
||||
|
||||
@@ -4,6 +4,19 @@ from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
class Configs(BaseSettings):
|
||||
"""
|
||||
Postgresql configuration settings.
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=password
|
||||
POSTGRES_DB=postgres
|
||||
POSTGRES_HOST=10.10.2.14
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_ENGINE=postgresql+psycopg2
|
||||
POSTGRES_POOL_PRE_PING=True
|
||||
POSTGRES_POOL_SIZE=20
|
||||
POSTGRES_MAX_OVERFLOW=10
|
||||
POSTGRES_POOL_RECYCLE=600
|
||||
POSTGRES_POOL_TIMEOUT=30
|
||||
POSTGRES_ECHO=True
|
||||
# "postgresql+psycopg2://postgres:password@10.10.2.14:5432/postgres"
|
||||
"""
|
||||
|
||||
DB: str = ""
|
||||
|
||||
@@ -26,7 +26,7 @@ from Schemas.address.address import (
|
||||
AddressStreet,
|
||||
)
|
||||
from Schemas.building.build import (
|
||||
BuildTypes,
|
||||
# BuildTypes,
|
||||
Part2Employee,
|
||||
RelationshipEmployee2Build,
|
||||
Build,
|
||||
@@ -139,7 +139,7 @@ __all__ = [
|
||||
"AddressLocality",
|
||||
"AddressNeighborhood",
|
||||
"AddressStreet",
|
||||
"BuildTypes",
|
||||
# "BuildTypes",
|
||||
"Part2Employee",
|
||||
"RelationshipEmployee2Build",
|
||||
"Build",
|
||||
|
||||
@@ -315,6 +315,7 @@ class AccountRecordExchanges(CrudCollection):
|
||||
)
|
||||
|
||||
|
||||
|
||||
class AccountDelayInterest(CrudCollection):
|
||||
|
||||
__tablename__ = "account_delay_interest"
|
||||
@@ -354,6 +355,44 @@ class AccountDelayInterest(CrudCollection):
|
||||
)
|
||||
|
||||
|
||||
class AccountRecordsModelTrain(CrudCollection):
|
||||
|
||||
__tablename__ = "account_records_model_train"
|
||||
__exclude__fields__ = []
|
||||
|
||||
start_index: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
end_index: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
search_text: Mapped[str] = mapped_column(String, nullable=False)
|
||||
|
||||
category_id: Mapped[int] = mapped_column(ForeignKey("api_enum_dropdown.id"), nullable=False)
|
||||
category_uu_id: Mapped[str] = mapped_column(String(100), nullable=False)
|
||||
account_records_id: Mapped[int] = mapped_column(ForeignKey("account_records.id"), nullable=False)
|
||||
account_records_uu_id: Mapped[str] = mapped_column(String(100), nullable=False)
|
||||
is_model_trained: Mapped[bool] = mapped_column(Boolean, server_default="0")
|
||||
trained_at: Mapped[TIMESTAMP] = mapped_column(TIMESTAMP(timezone=True), nullable=True)
|
||||
|
||||
|
||||
class AccountRecordsPredict(CrudCollection):
|
||||
"""
|
||||
prediction_model = tahmin eden model ismi
|
||||
prediction_result = tahmin edilen sonuc
|
||||
treshold = tahmin edilen sonucun yüzdesi
|
||||
is_first_prediction = account record da kullanılmak tahmin mi?
|
||||
"""
|
||||
__tablename__ = "account_records_predict"
|
||||
__exclude__fields__ = []
|
||||
|
||||
account_records_id: Mapped[int] = mapped_column(ForeignKey("account_records.id"), nullable=False)
|
||||
account_records_uu_id: Mapped[str] = mapped_column(String(100), nullable=False)
|
||||
prediction_model: Mapped[str] = mapped_column(String(10), nullable=False)
|
||||
prediction_result: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
prediction_field: Mapped[str] = mapped_column(String(10), nullable=False, server_default="")
|
||||
treshold: Mapped[float] = mapped_column(Numeric(18, 6), nullable=True)
|
||||
is_first_prediction: Mapped[bool] = mapped_column(Boolean, server_default="0")
|
||||
is_approved: Mapped[bool] = mapped_column(Boolean, server_default="0")
|
||||
approved_at: Mapped[TIMESTAMP] = mapped_column(TIMESTAMP(timezone=True), nullable=True)
|
||||
|
||||
|
||||
class AccountRecords(CrudCollection):
|
||||
"""
|
||||
build_decision_book_id = kaydın sorumlu olduğu karar defteri
|
||||
@@ -368,6 +407,7 @@ class AccountRecords(CrudCollection):
|
||||
iban: Mapped[str] = mapped_column(String(64), nullable=False, comment="IBAN Number of Bank")
|
||||
bank_date: Mapped[TIMESTAMP] = mapped_column(TIMESTAMP(timezone=True), nullable=False, comment="Bank Transaction Date")
|
||||
currency_value: Mapped[float] = mapped_column(Numeric(20, 6), nullable=False, comment="Currency Value")
|
||||
remainder_balance: Mapped[float] = mapped_column(Numeric(20, 6), server_default="0")
|
||||
bank_balance: Mapped[float] = mapped_column(Numeric(20, 6), nullable=False, comment="Bank Balance")
|
||||
currency: Mapped[str] = mapped_column(String(5), nullable=False, comment="Unit of Currency")
|
||||
additional_balance: Mapped[float] = mapped_column(Numeric(20, 6), nullable=False, comment="Additional Balance")
|
||||
@@ -377,12 +417,13 @@ class AccountRecords(CrudCollection):
|
||||
process_comment: Mapped[str] = mapped_column(String, nullable=False, comment="Transaction Record Comment")
|
||||
process_garbage: Mapped[str] = mapped_column(String, nullable=True, comment="Transaction Record Garbage")
|
||||
bank_reference_code: Mapped[str] = mapped_column(String, nullable=False, comment="Bank Reference Code")
|
||||
|
||||
add_comment_note: Mapped[str] = mapped_column(String, server_default="")
|
||||
is_receipt_mail_send: Mapped[bool] = mapped_column(Boolean, server_default="0")
|
||||
approved_record: Mapped[bool] = mapped_column(Boolean, server_default="0")
|
||||
|
||||
found_from = mapped_column(String, server_default="")
|
||||
similarity: Mapped[float] = mapped_column(Numeric(20, 6), server_default="0")
|
||||
remainder_balance: Mapped[float] = mapped_column(Numeric(20, 6), server_default="0")
|
||||
import_file_name: Mapped[str] = mapped_column(String, nullable=True, comment="XLS Key")
|
||||
|
||||
bank_date_y: Mapped[int] = mapped_column(Integer)
|
||||
bank_date_m: Mapped[int] = mapped_column(SmallInteger)
|
||||
@@ -394,8 +435,6 @@ class AccountRecords(CrudCollection):
|
||||
accounting_receipt_number: Mapped[int] = mapped_column(Integer, server_default="0")
|
||||
status_id: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
|
||||
approved_record: Mapped[bool] = mapped_column(Boolean, server_default="0")
|
||||
import_file_name: Mapped[str] = mapped_column(String, nullable=True, comment="XLS Key")
|
||||
receive_debit: Mapped[int] = mapped_column(ForeignKey("api_enum_dropdown.id"), nullable=True)
|
||||
receive_debit_uu_id: Mapped[str] = mapped_column(String, nullable=True, comment="Debit UU ID")
|
||||
budget_type: Mapped[int] = mapped_column(ForeignKey("api_enum_dropdown.id"), nullable=True)
|
||||
@@ -422,7 +461,7 @@ class AccountRecords(CrudCollection):
|
||||
payment_result_type: Mapped[int] = mapped_column(ForeignKey("api_enum_dropdown.id"), nullable=True)
|
||||
payment_result_type_uu_id: Mapped[str] = mapped_column(String, nullable=True, comment="Payment Result Type UU ID")
|
||||
is_commission_applied: Mapped[bool] = mapped_column(Boolean, server_default="0")
|
||||
|
||||
|
||||
__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),
|
||||
|
||||
@@ -148,7 +148,7 @@ class Build(CrudCollection):
|
||||
site_uu_id: Mapped[str] = mapped_column(String, comment="Site UUID", nullable=True)
|
||||
address_id: Mapped[int] = mapped_column(ForeignKey("addresses.id"), nullable=False)
|
||||
address_uu_id: Mapped[str] = mapped_column(String, comment="Address UUID", nullable=False)
|
||||
build_types_id: Mapped[int] = mapped_column(ForeignKey("build_types.id"), nullable=False, comment="Building Type")
|
||||
build_types_id: Mapped[int] = mapped_column(ForeignKey("api_enum_dropdown.id"), nullable=False, comment="Building Type")
|
||||
build_types_uu_id: Mapped[str] = mapped_column(String, comment="Building Type UUID")
|
||||
|
||||
parts: Mapped[List["BuildParts"]] = relationship("BuildParts", back_populates="buildings", foreign_keys="BuildParts.build_id")
|
||||
@@ -238,8 +238,8 @@ class Build(CrudCollection):
|
||||
building_types = None
|
||||
for part in self.parts:
|
||||
building_types = {}
|
||||
build_type = BuildTypes.query.filter(
|
||||
BuildTypes.id == part.build_part_type_id
|
||||
build_type = ApiEnumDropdown.query.filter(
|
||||
ApiEnumDropdown.id == part.part_type_id
|
||||
).first()
|
||||
if not build_type:
|
||||
raise HTTPException(
|
||||
@@ -316,7 +316,7 @@ class BuildParts(CrudCollection):
|
||||
String, nullable=True, comment="Part Direction UUID"
|
||||
)
|
||||
part_type_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_types.id"), nullable=False, comment="Building Part Type"
|
||||
ForeignKey("api_enum_dropdown.id"), nullable=False, comment="Building Part Type"
|
||||
)
|
||||
part_type_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Building Part Type UUID"
|
||||
@@ -332,9 +332,9 @@ class BuildParts(CrudCollection):
|
||||
)
|
||||
|
||||
def part_name(self, db):
|
||||
BuildTypes.set_session(db)
|
||||
if build_type := BuildTypes.query.filter(
|
||||
BuildTypes.id == self.part_type_id
|
||||
ApiEnumDropdown.set_session(db)
|
||||
if build_type := ApiEnumDropdown.query.filter(
|
||||
ApiEnumDropdown.id == self.part_type_id
|
||||
).first():
|
||||
return f"{str(build_type.type_name).upper()} : {str(self.part_no).upper()}"
|
||||
return f"Undefined:{str(build_type.type_name).upper()}"
|
||||
@@ -488,7 +488,7 @@ class BuildArea(CrudCollection):
|
||||
build_id: Mapped[int] = mapped_column(ForeignKey("build.id"))
|
||||
build_uu_id: Mapped[str] = mapped_column(String, comment="Building UUID")
|
||||
part_type_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_types.id"), nullable=True, comment="Building Part Type"
|
||||
ForeignKey("api_enum_dropdown.id"), nullable=True, comment="Building Part Type"
|
||||
)
|
||||
part_type_uu_id: Mapped[str] = mapped_column(
|
||||
String, nullable=True, comment="Building Part Type UUID"
|
||||
|
||||
@@ -17,6 +17,7 @@ class ApiEnumDropdown(CrudCollection):
|
||||
uu_id: Mapped[str] = mapped_column(
|
||||
UUID, server_default=text("gen_random_uuid()"), index=True, unique=True
|
||||
)
|
||||
lang: Mapped[str] = mapped_column(String, nullable=False, server_default="tr", comment="Language")
|
||||
enum_class: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Enum Constant Name"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user