super_user and services updated

This commit is contained in:
2024-12-05 18:59:46 +03:00
parent 88f94c37c2
commit 88309eb49d
20 changed files with 317 additions and 116 deletions

View File

@@ -65,6 +65,8 @@ from databases.sql_models.event.event import (
Events,
Event2Occupant,
Event2Employee,
Event2OccupantExtra,
Event2EmployeeExtra,
)
from databases.sql_models.identity.identity import (
Addresses,
@@ -149,6 +151,8 @@ __all__ = [
"Events",
"Event2Occupant",
"Event2Employee",
"Event2OccupantExtra",
"Event2EmployeeExtra",
"Addresses",
"AddressCity",
"AddressStreet",

View File

@@ -368,6 +368,11 @@ class AccountDetail(CrudCollection):
class AccountRecords(CrudCollection):
"""
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
"""
__tablename__ = "account_records"
__exclude__fields__ = []
@@ -375,11 +380,47 @@ class AccountRecords(CrudCollection):
("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
"""
language = {
"tr": {
"iban": "IBAN Numarası",
"bank_date": "Bank Tarih",
"currency_value": "Para Değeri",
"bank_balance": "Banka Bakiye",
"currency": "Para Birimi",
"additional_balance": "Ek Bakiye",
"channel_branch": "Kanal Şubesi",
"process_name": "İşlem Adı",
"process_type": "İşlem Tipi",
"process_comment": "İşlem Yorum",
"bank_reference_code": "Banka Referans Kodu",
"add_comment_note": "Yorum Not",
"is_receipt_mail_send": "Fiş Mail Gönderildi",
"found_from": "Bulunduğu Yer",
"similarity": "Benzerlik",
"remainder_balance": "Kalan Bakiye",
"bank_date_y": "Bank Tarih Yıl",
"bank_date_m": "Bank Tarih Ay",
"bank_date_w": "Bank Tarih Hafta",
"bank_date_d": "Bank Tarih Gün",
"approving_accounting_record": "Onaylayan Muhasebe Kaydı",
"accounting_receipt_date": "Muhasebe Fiş Tarihi",
"accounting_receipt_number": "Muhasebe Fiş Numarası",
"approved_record": "Onaylanmış Kayıt",
"import_file_name": "İçe Aktarım Dosya Adı",
"receive_debit_uu_id": "Alacak UU ID",
"budget_type_uu_id": "Bütçe Tipi UU ID",
"company_uu_id": "Şirket UU ID",
"send_company_uu_id": "Gönderen Şirket UU ID",
"customer_id": "Müşteri ID",
"customer_uu_id": "Müşteri UU ID",
"send_person_uu_id": "Gönderen Kişi UU ID",
"approving_accounting_person_uu_id": "Onaylayan Muhasebe Kişi UU ID",
"build_parts_uu_id": "Daire UU ID",
"build_decision_book_uu_id": "Karar Defteri UU ID",
},
"en": {},
}
iban: Mapped[str] = mapped_column(
String(64), nullable=False, comment="IBAN Number of Bank"

View File

@@ -21,7 +21,9 @@ class Events(CrudCollection):
__tablename__ = "events"
__exclude__fields__ = []
event_type: Mapped[str] = mapped_column(String, nullable=False, comment="Event Type")
event_type: Mapped[str] = mapped_column(
String, nullable=False, comment="Event Type"
)
function_code: Mapped[str] = mapped_column(
String, nullable=False, comment="function code"
)
@@ -123,6 +125,62 @@ class Service2Events(CrudCollection):
__table_args__ = ({"comment": "Service2Events Information"},)
class Event2OccupantExtra(CrudCollection):
__tablename__ = "event2occupant_extra"
__exclude__fields__ = []
build_living_space_id: Mapped[int] = mapped_column(
ForeignKey("build_living_space.id"), nullable=False
)
build_living_space_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Build Living Space UUID"
)
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), nullable=False)
event_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Event UUID"
)
__table_args__ = (
Index(
"event2occupant_extra_bind_event_to_occupant",
build_living_space_id,
event_id,
unique=True,
),
{"comment": "Occupant2Event Information"},
)
class Event2EmployeeExtra(CrudCollection):
"""
Employee2Event class based on declarative_base and BaseMixin via session
"""
__tablename__ = "event2employee_extra"
__exclude__fields__ = []
employee_id: Mapped[int] = mapped_column(ForeignKey("employees.id"), nullable=False)
employee_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Employee UUID"
)
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), nullable=False)
event_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Event UUID"
)
__table_args__ = (
Index(
"event2employee_extra_employee_to_event",
employee_id,
event_id,
unique=True,
),
{"comment": "Employee to Event Information"},
)
class Event2Employee(CrudCollection):
"""
Employee2Event class based on declarative_base and BaseMixin via session
@@ -131,23 +189,41 @@ class Event2Employee(CrudCollection):
__tablename__ = "event2employee"
__exclude__fields__ = []
employee_id = mapped_column(ForeignKey("employees.id"), nullable=False)
employee_uu_id = mapped_column(String, nullable=False, comment="Employee UUID")
event_id = mapped_column(ForeignKey("events.id"), nullable=False)
event_uu_id = mapped_column(String, nullable=False, comment="Event UUID")
employee_id: Mapped[int] = mapped_column(ForeignKey("employees.id"), nullable=False)
employee_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Employee UUID"
)
event_service_id: Mapped[int] = mapped_column(
ForeignKey("services.id"), nullable=False
)
event_service_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Event Cluster UUID"
)
__table_args__ = (
Index("event2employee_employee_to_event", employee_id, event_id, unique=True),
Index(
"event2employee_employee_to_event",
employee_id,
event_service_id,
unique=True,
),
{"comment": "Employee to Event Information"},
)
@classmethod
def get_event_id_by_employee_id(cls, employee_id) -> (list, list):
active_events = cls.filter_all(cls.employee_id == employee_id)
active_events_id = [event.event_id for event in active_events.data]
active_events = Events.filter_all(Events.id.in_(active_events_id))
active_events_uu_id = [str(event.uu_id) for event in active_events.data]
return active_events_id, active_events_uu_id
def get_event_id_by_employee_id(cls, employee_id) -> list:
occupant_events = cls.filter_all(
cls.employee_id == employee_id,
).data
active_events = Service2Events.filter_all(
Service2Events.service_id.in_([event.event_service_id for event in occupant_events]), system=True
).data
active_events_id = [event.event_id for event in active_events]
if extra_events := Event2EmployeeExtra.filter_all(
Event2EmployeeExtra.employee_id == employee_id
).data:
active_events_id.extend([event.event_id for event in extra_events])
return active_events_id
class Event2Occupant(CrudCollection):
@@ -158,39 +234,47 @@ class Event2Occupant(CrudCollection):
__tablename__ = "event2occupant"
__exclude__fields__ = []
build_living_space_id = mapped_column(
build_living_space_id: Mapped[str] = mapped_column(
ForeignKey("build_living_space.id"), nullable=False
)
build_living_space_uu_id = mapped_column(
build_living_space_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Build Living Space UUID"
)
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), nullable=False)
event_uu_id = mapped_column(String, nullable=False, comment="Event UUID")
event_service_id: Mapped[int] = mapped_column(
ForeignKey("services.id"), nullable=False
)
event_service_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Event Cluster UUID"
)
# event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), nullable=False)
# event_uu_id = mapped_column(String, nullable=False, comment="Event UUID")
__table_args__ = (
Index(
"event2occupant_bind_event_to_occupant",
build_living_space_id,
event_id,
event_service_id,
unique=True,
),
{"comment": "Occupant2Event Information"},
)
@classmethod
def get_event_id_by_build_living_space_id(
cls, build_living_space_id
) -> (list, list):
active_events = cls.filter_all(
def get_event_id_by_build_living_space_id(cls, build_living_space_id) -> list:
occupant_events = cls.filter_all(
cls.build_living_space_id == build_living_space_id,
).data
active_events = Service2Events.filter_all(
Service2Events.service_id.in_([event.event_service_id for event in occupant_events]), system=True
).data
active_events_id = [event.event_id for event in active_events]
active_events = Events.filter_all(Events.id.in_(active_events_id)).data
active_events_uu_id = [str(event.uu_id) for event in active_events]
return active_events_id, active_events_uu_id
if extra_events := Event2OccupantExtra.filter_all(
Event2OccupantExtra.build_living_space_id == build_living_space_id
).data:
active_events_id.extend([event.event_id for event in extra_events])
return active_events_id
# Delete later code
class ModulePrice(CrudCollection):
"""
ModulePrice class based on declarative_base and BaseMixin via session
@@ -199,27 +283,34 @@ class ModulePrice(CrudCollection):
__tablename__ = "module_price"
__exclude__fields__ = []
campaign_code = mapped_column(String, nullable=False, comment="Campaign Code")
campaign_code: Mapped[str] = mapped_column(
String, nullable=False, comment="Campaign Code"
)
module_id: Mapped[int] = mapped_column(ForeignKey("modules.id"), nullable=False)
module_uu_id = mapped_column(String, nullable=False, comment="Module UUID")
module_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Module UUID"
)
service_id: Mapped[int] = mapped_column(ForeignKey("services.id"), nullable=False)
service_uu_id = mapped_column(String, nullable=False, comment="Service UUID")
service_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Service UUID"
)
event_id: Mapped[int] = mapped_column(ForeignKey("events.id"), nullable=False)
event_uu_id = mapped_column(String, nullable=False, comment="Event UUID")
event_uu_id: Mapped[str] = mapped_column(
String, nullable=False, comment="Event UUID"
)
is_counted_percentage: Mapped[float] = mapped_column(
Numeric(6, 2), server_default="0.00"
) # %22
discounted_price = mapped_column(
discounted_price: Mapped[float] = mapped_column(
Numeric(20, 2), server_default="0.00"
) # Normal: 78.00 TL
calculated_price = mapped_column(
calculated_price: Mapped[float] = mapped_column(
Numeric(20, 2), server_default="0.00"
) # sana düz 75.00 TL yapar
__table_args__ = ({"comment": "ModulePrice Information"},)
#
# class Modules2Occupant(CrudCollection):
# """
# ModulesOccupantPrices class based on declarative_base and BaseMixin via session