29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
from sqlalchemy.orm import Query
|
|
|
|
from televend_core.databases.base_load_options import LoadOptions
|
|
from televend_core.databases.common.load_options import joinload
|
|
from televend_core.databases.televend_repositories.cashbag_conform.model import CashBagConform
|
|
from televend_core.databases.televend_repositories.custom_user.model import CustomUser
|
|
|
|
|
|
class CashBagConformLoadOptions(LoadOptions):
|
|
model_cls = CashBagConform
|
|
|
|
load_cashflow_collection: bool = joinload(relations=["cashflow_collection"])
|
|
load_machine: bool = joinload(relations=["machine"])
|
|
load_cashbag: bool = joinload(relations=["cashbag"])
|
|
load_denominations: bool = joinload(relations=["denominations"])
|
|
|
|
load_count_user_auth_user: bool = False
|
|
|
|
def _apply_custom_joins(self, query: Query) -> Query:
|
|
if self.load_count_user_auth_user:
|
|
query = self._add_joins_to_options(
|
|
query=query,
|
|
fields=[
|
|
CashBagConform.count_user,
|
|
CustomUser.auth_user,
|
|
],
|
|
)
|
|
return query
|