latest version of apis event and cahce ablitites added
This commit is contained in:
124
Events/AllEvents/events/account/account_records.py
Normal file
124
Events/AllEvents/events/account/account_records.py
Normal file
@@ -0,0 +1,124 @@
|
||||
"""
|
||||
Account related API endpoints.
|
||||
"""
|
||||
|
||||
from typing import Any, Dict
|
||||
from fastapi import Request
|
||||
|
||||
from Events.Engine.abstract_class import MethodToEvent
|
||||
from Events.base_request_model import EndpointBaseRequestModel, ContextRetrievers
|
||||
from ApiLayers.Middleware.token_event_middleware import TokenEventMiddleware
|
||||
from ApiLayers.ApiValidations.Response.default_response import (
|
||||
EndpointSuccessListResponse,
|
||||
)
|
||||
|
||||
from .function_handlers import AccountListEventMethods
|
||||
from .api_events import SuperUserAccountEvents
|
||||
|
||||
|
||||
AccountRecordsListEventMethods = MethodToEvent(
|
||||
name="AccountRecordsListEventMethods",
|
||||
events={
|
||||
SuperUserAccountEvents.SuperUserListEvent.key: SuperUserAccountEvents.SuperUserListEvent,
|
||||
},
|
||||
headers=[],
|
||||
errors=[],
|
||||
decorators_list=[TokenEventMiddleware.event_required],
|
||||
url="/list",
|
||||
method="POST",
|
||||
summary="List all accounts by given previligous",
|
||||
description="List all accounts by given previligous",
|
||||
)
|
||||
|
||||
|
||||
def account_list_event_endpoint(
|
||||
request: Request, data: EndpointBaseRequestModel
|
||||
) -> Dict[str, Any]:
|
||||
context_retriever = ContextRetrievers(func=account_list_event_endpoint)
|
||||
event_2_catch = AccountRecordsListEventMethods.retrieve_event(
|
||||
event_function_code=f"{SuperUserAccountEvents.SuperUserListEvent.key}"
|
||||
)
|
||||
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||
AccountListEventMethods.context_retriever = context_retriever
|
||||
pagination_result = event_2_catch.endpoint_callable(data=data)
|
||||
return EndpointSuccessListResponse(
|
||||
code=event_2_catch.static_key, lang=context_retriever.token.lang
|
||||
).as_dict(
|
||||
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
|
||||
)
|
||||
|
||||
|
||||
AccountRecordsListEventMethods.endpoint_callable = account_list_event_endpoint
|
||||
|
||||
|
||||
AccountRecordsCreateEventMethods = MethodToEvent(
|
||||
name="AccountRecordsCreateEventMethods",
|
||||
events={
|
||||
SuperUserAccountEvents.SuperUserCreateEvent.key: SuperUserAccountEvents.SuperUserCreateEvent,
|
||||
},
|
||||
headers=[],
|
||||
errors=[],
|
||||
decorators_list=[TokenEventMiddleware.event_required],
|
||||
url="/create",
|
||||
method="POST",
|
||||
summary="Create Account via given data and previligous",
|
||||
description="Create Account via given data and previligous",
|
||||
)
|
||||
|
||||
|
||||
def account_create_event_endpoint(
|
||||
request: Request, data: EndpointBaseRequestModel
|
||||
) -> Dict[str, Any]:
|
||||
context_retriever = ContextRetrievers(func=account_create_event_endpoint)
|
||||
event_2_catch = AccountRecordsCreateEventMethods.retrieve_event(
|
||||
event_function_code=f"{SuperUserAccountEvents.SuperUserCreateEvent.key}"
|
||||
)
|
||||
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||
AccountListEventMethods.context_retriever = context_retriever
|
||||
pagination_result = event_2_catch.endpoint_callable(data=data)
|
||||
return EndpointSuccessListResponse(
|
||||
code=event_2_catch.static_key, lang=context_retriever.token.lang
|
||||
).as_dict(
|
||||
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
|
||||
)
|
||||
|
||||
|
||||
AccountRecordsCreateEventMethods.endpoint_callable = account_create_event_endpoint
|
||||
|
||||
|
||||
AccountRecordsUpdateEventMethods = MethodToEvent(
|
||||
name="AccountRecordsUpdateEventMethods",
|
||||
events={
|
||||
SuperUserAccountEvents.SuperUserUpdateEvent.key: SuperUserAccountEvents.SuperUserUpdateEvent,
|
||||
},
|
||||
headers=[],
|
||||
errors=[],
|
||||
decorators_list=[TokenEventMiddleware.event_required],
|
||||
url="/update",
|
||||
method="POST",
|
||||
summary="Update Account via given data and previligous",
|
||||
description="Update Account via given data and previligous",
|
||||
)
|
||||
|
||||
|
||||
def account_update_event_endpoint(
|
||||
request: Request, data: EndpointBaseRequestModel
|
||||
) -> Dict[str, Any]:
|
||||
context_retriever = ContextRetrievers(func=account_update_event_endpoint)
|
||||
event_2_catch = AccountRecordsUpdateEventMethods.retrieve_event(
|
||||
event_function_code=f"{SuperUserAccountEvents.SuperUserUpdateEvent.key}"
|
||||
)
|
||||
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||
AccountListEventMethods.context_retriever = context_retriever
|
||||
pagination_result = event_2_catch.endpoint_callable(data=data)
|
||||
return EndpointSuccessListResponse(
|
||||
code=event_2_catch.static_key, lang=context_retriever.token.lang
|
||||
).as_dict(
|
||||
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
|
||||
)
|
||||
|
||||
|
||||
AccountRecordsUpdateEventMethods.endpoint_callable = account_update_event_endpoint
|
||||
77
Events/AllEvents/events/account/api_events.py
Normal file
77
Events/AllEvents/events/account/api_events.py
Normal file
@@ -0,0 +1,77 @@
|
||||
from Events.Engine.abstract_class import Event
|
||||
|
||||
from .models import AccountRequestValidators
|
||||
from .function_handlers import (
|
||||
AccountListEventMethods,
|
||||
AccountCreateEventMethods,
|
||||
AccountUpdateEventMethods,
|
||||
)
|
||||
|
||||
|
||||
# class SelectResponseAccount(BaseModel):
|
||||
# """
|
||||
# Response model for account list.
|
||||
# """
|
||||
# neighborhood_code: str
|
||||
# neighborhood_name: str
|
||||
# type_code: str
|
||||
# type_description: str
|
||||
#
|
||||
|
||||
|
||||
# Auth Login
|
||||
account_list_super_user_event = Event(
|
||||
name="account_list_super_user_event",
|
||||
key="7192c2aa-5352-4e36-98b3-dafb7d036a3d",
|
||||
request_validator=AccountRequestValidators.ListAccountRecord,
|
||||
# response_validator=SelectResponseAccount,
|
||||
# language_models=[AccountRecords.__language_model__],
|
||||
language_models=[],
|
||||
statics="ACCOUNTS_LIST",
|
||||
description="List all types of accounts by validation list options and queries.",
|
||||
)
|
||||
|
||||
|
||||
account_list_super_user_event.endpoint_callable = (
|
||||
AccountListEventMethods.account_records_list
|
||||
)
|
||||
|
||||
|
||||
account_insert_super_user_event = Event(
|
||||
name="account_insert_super_user_event",
|
||||
key="31f4f32f-0cd4-4995-8a6a-f9f56335848a",
|
||||
request_validator=AccountRequestValidators.InsertAccountRecord,
|
||||
# response_validator=SelectResponseAccount,
|
||||
# language_models=[AccountRecords.__language_model__],
|
||||
language_models=[],
|
||||
statics="ACCOUNT_CREATED",
|
||||
description="Create a new account by validation list options and queries.",
|
||||
)
|
||||
|
||||
|
||||
account_insert_super_user_event.endpoint_callable = (
|
||||
AccountCreateEventMethods.account_records_create
|
||||
)
|
||||
|
||||
|
||||
account_update_super_user_event = Event(
|
||||
name="account_insert_super_user_event",
|
||||
key="208e6273-17ef-44f0-814a-8098f816b63a",
|
||||
request_validator=AccountRequestValidators.UpdateAccountRecord,
|
||||
# response_validator=SelectResponseAccount,
|
||||
# language_models=[AccountRecords.__language_model__],
|
||||
language_models=[],
|
||||
statics="ACCOUNT_UPDATED",
|
||||
description="Update a specific account by validation list options and queries.",
|
||||
)
|
||||
|
||||
|
||||
account_update_super_user_event.endpoint_callable = (
|
||||
AccountUpdateEventMethods.account_records_update
|
||||
)
|
||||
|
||||
|
||||
class SuperUserAccountEvents:
|
||||
SuperUserListEvent = account_list_super_user_event
|
||||
SuperUserCreateEvent = account_insert_super_user_event
|
||||
SuperUserUpdateEvent = account_update_super_user_event
|
||||
38
Events/AllEvents/events/account/bases.py
Normal file
38
Events/AllEvents/events/account/bases.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from Events.Engine.abstract_class import DefaultClusterName
|
||||
|
||||
|
||||
cluster_name = "AccountCluster"
|
||||
prefix = "/accounts"
|
||||
icon = "Building"
|
||||
|
||||
|
||||
# Keys for the cluster
|
||||
class KeyValidations:
|
||||
headers = "headers"
|
||||
data = "data"
|
||||
validation = "validations"
|
||||
|
||||
# Key URLS for the cluster
|
||||
class KeyURLs:
|
||||
validations = "/validations/validations"
|
||||
|
||||
# Keys for the cluster
|
||||
class KeyBases:
|
||||
create_key = f"{prefix}/create"
|
||||
update_key = f"{prefix}/update"
|
||||
list_key = f"{prefix}/list"
|
||||
|
||||
|
||||
# Page Variations of the cluster
|
||||
class PageBases:
|
||||
CREATE = f"/create?{DefaultClusterName}={cluster_name}"
|
||||
UPDATE = f"/update?{DefaultClusterName}={cluster_name}"
|
||||
DASHBOARD = f"/dashboard?{DefaultClusterName}={cluster_name}"
|
||||
|
||||
|
||||
# Match the keys with the pages
|
||||
page_2_keys = {
|
||||
KeyBases.create_key: PageBases.CREATE,
|
||||
KeyBases.update_key: PageBases.UPDATE,
|
||||
KeyBases.list_key: PageBases.DASHBOARD,
|
||||
}
|
||||
26
Events/AllEvents/events/account/cluster.py
Normal file
26
Events/AllEvents/events/account/cluster.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from Events.Engine.abstract_class import CategoryCluster
|
||||
from .account_records import (
|
||||
AccountRecordsListEventMethods,
|
||||
AccountRecordsCreateEventMethods,
|
||||
AccountRecordsUpdateEventMethods,
|
||||
)
|
||||
from .bases import cluster_name, prefix, page_2_keys
|
||||
from .info import page_infos
|
||||
|
||||
|
||||
AccountCluster = CategoryCluster(
|
||||
name=cluster_name,
|
||||
tags=["Account Records"],
|
||||
prefix=prefix,
|
||||
description="Account Cluster Actions",
|
||||
pageinfo=page_infos,
|
||||
endpoints={
|
||||
"AccountRecordsCreateEventMethods": AccountRecordsCreateEventMethods,
|
||||
"AccountRecordsUpdateEventMethods": AccountRecordsUpdateEventMethods,
|
||||
"AccountRecordsListEventMethods": AccountRecordsListEventMethods,
|
||||
},
|
||||
mapping=page_2_keys,
|
||||
include_in_schema=True,
|
||||
sub_category=[],
|
||||
is_client=True,
|
||||
)
|
||||
305
Events/AllEvents/events/account/function_handlers.py
Normal file
305
Events/AllEvents/events/account/function_handlers.py
Normal file
@@ -0,0 +1,305 @@
|
||||
"""
|
||||
Account records service implementation.
|
||||
"""
|
||||
|
||||
from typing import Any, Union, Optional
|
||||
|
||||
from ApiLayers.ApiLibrary import system_arrow
|
||||
from ApiLayers.ApiValidations.Custom.token_objects import (
|
||||
OccupantTokenObject,
|
||||
EmployeeTokenObject,
|
||||
)
|
||||
from ApiLayers.ApiValidations.Request import (
|
||||
InsertAccountRecord,
|
||||
UpdateAccountRecord,
|
||||
ListOptions,
|
||||
)
|
||||
from ApiLayers.Schemas import (
|
||||
BuildLivingSpace,
|
||||
BuildDecisionBookPayments,
|
||||
AccountRecords,
|
||||
BuildIbans,
|
||||
ApiEnumDropdown,
|
||||
)
|
||||
from ApiLayers.ApiValidations.Response import AccountRecordResponse
|
||||
|
||||
from Events.base_request_model import BaseRouteModel, ListOptionsBase
|
||||
from Services.PostgresDb.Models.pagination import PaginationResult
|
||||
|
||||
|
||||
class AccountListEventMethods(BaseRouteModel):
|
||||
"""
|
||||
Account records list by with full privileges.
|
||||
Accepts List Options
|
||||
{
|
||||
"data": {
|
||||
"page": 1,
|
||||
"size": 10,
|
||||
"order_field": ["uu_id",]
|
||||
"order_type": ["desc"],
|
||||
"query": {
|
||||
"process_date__gt": "2021-09-01",
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def account_records_list(
|
||||
cls, data: Optional[Union[dict, ListOptions]]
|
||||
) -> PaginationResult:
|
||||
list_options_base = ListOptionsBase(
|
||||
table=AccountRecords,
|
||||
list_options=data,
|
||||
model_query=None,
|
||||
)
|
||||
db_session, query_options = list_options_base.init_list_options()
|
||||
if cls.context_retriever.token.is_occupant:
|
||||
AccountRecords.pre_query = AccountRecords.filter_all(
|
||||
AccountRecords.company_id
|
||||
== cls.context_retriever.token.selected_occupant.responsible_company_id,
|
||||
db=db_session,
|
||||
).query
|
||||
elif cls.context_retriever.token.is_employee:
|
||||
AccountRecords.pre_query = AccountRecords.filter_all(
|
||||
AccountRecords.company_id
|
||||
== cls.context_retriever.token.selected_company.company_id,
|
||||
db=db_session,
|
||||
).query
|
||||
records = AccountRecords.filter_all(*query_options.convert(), db=db_session)
|
||||
return list_options_base.paginated_result(
|
||||
records=records,
|
||||
response_model=getattr(cls.context_retriever, "RESPONSE_VALIDATOR", None),
|
||||
)
|
||||
|
||||
|
||||
class AccountCreateEventMethods(BaseRouteModel):
|
||||
|
||||
@classmethod
|
||||
def account_records_create(cls, data: Any):
|
||||
data_dict = data.excluded_dump()
|
||||
db_session = AccountRecords.new_session()
|
||||
if cls.context_retriever.token.is_occupant:
|
||||
build_iban = BuildIbans.filter_one(
|
||||
BuildIbans.iban == data.iban,
|
||||
BuildIbans.build_id
|
||||
== cls.context_retriever.token.selected_occupant.build_id,
|
||||
db=db_session,
|
||||
).data
|
||||
if not build_iban:
|
||||
raise BuildIbans.raise_http_exception(
|
||||
status_code="HTTP_404_NOT_FOUND",
|
||||
error_case="UNAUTHORIZED",
|
||||
message=f"{data.iban} is not found in company related to your organization",
|
||||
data={"iban": data.iban},
|
||||
)
|
||||
account_record = AccountRecords.find_or_create(**data.excluded_dump())
|
||||
# return AlchemyJsonResponse(
|
||||
# completed=True,
|
||||
# message="Account record created successfully",
|
||||
# result=account_record,
|
||||
# )
|
||||
elif cls.context_retriever.token.is_employee:
|
||||
# Build.pre_query = Build.select_action(
|
||||
# employee_id=token_dict.selected_employee.employee_id,
|
||||
# )
|
||||
# build_ids_list = Build.filter_all(
|
||||
# )
|
||||
# build_iban = BuildIbans.filter_one(
|
||||
# BuildIbans.iban == data.iban,
|
||||
# BuildIbans.build_id.in_([build.id for build in build_ids_list.data]),
|
||||
# ).data
|
||||
# if not build_iban:
|
||||
# BuildIbans.raise_http_exception(
|
||||
# status_code="HTTP_404_NOT_FOUND",
|
||||
# error_case="UNAUTHORIZED",
|
||||
# message=f"{data.iban} is not found in company related to your organization",
|
||||
# data={
|
||||
# "iban": data.iban,
|
||||
# },
|
||||
# )
|
||||
bank_date = system_arrow.get(data.bank_date)
|
||||
data_dict["bank_date_w"] = bank_date.weekday()
|
||||
data_dict["bank_date_m"] = bank_date.month
|
||||
data_dict["bank_date_d"] = bank_date.day
|
||||
data_dict["bank_date_y"] = bank_date.year
|
||||
|
||||
if int(data.currency_value) < 0:
|
||||
debit_type = ApiEnumDropdown.filter_by_one(
|
||||
system=True, enum_class="DebitTypes", key="DT-D", db=db_session
|
||||
).data
|
||||
data_dict["receive_debit"] = debit_type.id
|
||||
data_dict["receive_debit_uu_id"] = str(debit_type.uu_id)
|
||||
else:
|
||||
debit_type = ApiEnumDropdown.filter_by_one(
|
||||
system=True, enum_class="DebitTypes", key="DT-R", db=db_session
|
||||
).data
|
||||
data_dict["receive_debit"] = debit_type.id
|
||||
data_dict["receive_debit_uu_id"] = str(debit_type.uu_id)
|
||||
|
||||
account_record = AccountRecords.find_or_create(
|
||||
data_dict, db=db_session
|
||||
).data
|
||||
# return AlchemyJsonResponse(
|
||||
# completed=True,
|
||||
# message="Account record created successfully",
|
||||
# result=account_record,
|
||||
# )
|
||||
|
||||
|
||||
class AccountUpdateEventMethods(BaseRouteModel):
|
||||
|
||||
@classmethod
|
||||
def account_records_update(cls, build_uu_id: str, data: Any):
|
||||
if cls.context_retriever.token.is_occupant:
|
||||
pass
|
||||
elif cls.context_retriever.token.is_employee:
|
||||
pass
|
||||
AccountRecords.build_parts_id = (
|
||||
cls.context_retriever.token.selected_occupant.build_part_id
|
||||
)
|
||||
|
||||
# return AlchemyJsonResponse(
|
||||
# completed=True,
|
||||
# message="Account record updated successfully",
|
||||
# result=account_record,
|
||||
# cls_object=AccountRecords,
|
||||
# response_model=UpdateAccountRecord,
|
||||
# )
|
||||
|
||||
|
||||
# @classmethod
|
||||
# def account_records_list_flt_res(cls, list_options: ListOptions) -> PaginationResult:
|
||||
# list_options_base = ListOptionsBase(
|
||||
# table=AccountRecords, list_options=list_options, model_query=None,
|
||||
# )
|
||||
# db_session, query_options = list_options_base.init_list_options()
|
||||
# if not cls.context_retriever.token.is_occupant:
|
||||
# raise AccountRecords.raise_http_exception(
|
||||
# status_code="HTTP_404_NOT_FOUND",
|
||||
# error_case="UNAUTHORIZED",
|
||||
# message="Only Occupant can see this data",
|
||||
# data={},
|
||||
# )
|
||||
#
|
||||
# return_list = []
|
||||
# living_space: BuildLivingSpace = BuildLivingSpace.filter_by_one(
|
||||
# id=cls.context_retriever.token.selected_occupant.living_space_id, db=db_session
|
||||
# ).data
|
||||
# if not living_space:
|
||||
# raise AccountRecords.raise_http_exception(
|
||||
# status_code="HTTP_404_NOT_FOUND",
|
||||
# error_case="UNAUTHORIZED",
|
||||
# message="Living space not found",
|
||||
# data={},
|
||||
# )
|
||||
#
|
||||
# if not list_options:
|
||||
# list_options = ListOptions()
|
||||
#
|
||||
# main_filters = [
|
||||
# AccountRecords.living_space_id
|
||||
# == cls.context_retriever.token.selected_occupant.living_space_id,
|
||||
# BuildDecisionBookPayments.process_date
|
||||
# >= str(system_arrow.now().shift(months=-3).date()),
|
||||
# BuildDecisionBookPayments.process_date
|
||||
# < str(system_arrow.find_last_day_of_month(living_space.expiry_ends)),
|
||||
# BuildDecisionBookPayments.process_date
|
||||
# >= str(system_arrow.get(living_space.expiry_starts)),
|
||||
# BuildDecisionBookPayments.is_confirmed == True,
|
||||
# AccountRecords.active == True,
|
||||
# ]
|
||||
# order_type = "desc"
|
||||
# if list_options.order_type:
|
||||
# order_type = "asc" if list_options.order_type[0] == "a" else "desc"
|
||||
#
|
||||
# order_by_list = BuildDecisionBookPayments.process_date.desc()
|
||||
# if list_options.order_field:
|
||||
# if list_options.order_field == "process_date":
|
||||
# order_by_list = (
|
||||
# BuildDecisionBookPayments.process_date.asc()
|
||||
# if order_type == "asc"
|
||||
# else BuildDecisionBookPayments.process_date.desc()
|
||||
# )
|
||||
# if list_options.order_field == "bank_date":
|
||||
# order_by_list = (
|
||||
# AccountRecords.bank_date.desc()
|
||||
# if order_type == "asc"
|
||||
# else AccountRecords.bank_date.asc()
|
||||
# )
|
||||
# if list_options.order_field == "currency_value":
|
||||
# order_by_list = (
|
||||
# AccountRecords.currency_value.desc()
|
||||
# if order_type == "asc"
|
||||
# else AccountRecords.currency_value.asc()
|
||||
# )
|
||||
# if list_options.order_field == "process_comment":
|
||||
# order_by_list = (
|
||||
# AccountRecords.process_comment.desc()
|
||||
# if order_type == "asc"
|
||||
# else AccountRecords.process_comment.asc()
|
||||
# )
|
||||
# if list_options.order_field == "payment_amount":
|
||||
# order_by_list = (
|
||||
# BuildDecisionBookPayments.payment_amount.desc()
|
||||
# if order_type == "asc"
|
||||
# else BuildDecisionBookPayments.payment_amount.asc()
|
||||
# )
|
||||
#
|
||||
# if list_options.query:
|
||||
# for key, value in list_options.query.items():
|
||||
# if key == "process_date":
|
||||
# main_filters.append(BuildDecisionBookPayments.process_date == value)
|
||||
# if key == "bank_date":
|
||||
# main_filters.append(AccountRecords.bank_date == value)
|
||||
# if key == "currency":
|
||||
# main_filters.append(BuildDecisionBookPayments.currency == value)
|
||||
# if key == "currency_value":
|
||||
# main_filters.append(AccountRecords.currency_value == value)
|
||||
# if key == "process_comment":
|
||||
# main_filters.append(AccountRecords.process_comment == value)
|
||||
# if key == "payment_amount":
|
||||
# main_filters.append(
|
||||
# BuildDecisionBookPayments.payment_amount == value
|
||||
# )
|
||||
#
|
||||
# query = (
|
||||
# AccountRecords.session.query(
|
||||
# BuildDecisionBookPayments.process_date,
|
||||
# BuildDecisionBookPayments.payment_amount,
|
||||
# BuildDecisionBookPayments.currency,
|
||||
# AccountRecords.bank_date,
|
||||
# AccountRecords.currency_value,
|
||||
# AccountRecords.process_comment,
|
||||
# BuildDecisionBookPayments.uu_id,
|
||||
# )
|
||||
# .join(
|
||||
# AccountRecords,
|
||||
# AccountRecords.id == BuildDecisionBookPayments.account_records_id,
|
||||
# )
|
||||
# .filter(*main_filters)
|
||||
# ).order_by(order_by_list)
|
||||
#
|
||||
# query.limit(list_options.size or 5).offset(
|
||||
# (list_options.page or 1 - 1) * list_options.size or 5
|
||||
# )
|
||||
# for list_of_values in query.all() or []:
|
||||
# return_list.append(
|
||||
# {
|
||||
# "process_date": list_of_values[0],
|
||||
# "payment_amount": list_of_values[1],
|
||||
# "currency": list_of_values[2],
|
||||
# "bank_date": list_of_values[3],
|
||||
# "currency_value": list_of_values[4],
|
||||
# "process_comment": list_of_values[5],
|
||||
# }
|
||||
# )
|
||||
# return AlchemyJsonResponse(
|
||||
# completed=True,
|
||||
# message="Account records listed successfully",
|
||||
# result=return_list,
|
||||
# cls_object=AccountRecords,
|
||||
# filter_attributes=list_options,
|
||||
# response_model=AccountRecordResponse,
|
||||
# )
|
||||
|
||||
140
Events/AllEvents/events/account/info.py
Normal file
140
Events/AllEvents/events/account/info.py
Normal file
@@ -0,0 +1,140 @@
|
||||
from Events.Engine.abstract_class import PageInfo
|
||||
from .bases import KeyValidations, cluster_name, KeyBases, PageBases, icon, KeyURLs
|
||||
from .account_records import (
|
||||
AccountRecordsUpdateEventMethods,
|
||||
AccountRecordsCreateEventMethods,
|
||||
AccountRecordsListEventMethods,
|
||||
)
|
||||
from .lang_models import (
|
||||
account_language_create_models_as_dict,
|
||||
account_language_model_as_dict,
|
||||
account_language_list_models_as_dict,
|
||||
account_language_created_models_as_dict,
|
||||
account_language_update_form_models_as_dict,
|
||||
)
|
||||
|
||||
|
||||
class ClustersPageInfo:
|
||||
|
||||
# Cluster Page Infos that are available for the client
|
||||
dashboard_page_info = PageInfo(
|
||||
name=f"{cluster_name}",
|
||||
url=PageBases.DASHBOARD,
|
||||
icon=icon,
|
||||
page_info={
|
||||
"en": {
|
||||
"page": "Account Records for reaching user all types account information",
|
||||
},
|
||||
"tr": {
|
||||
"page": "Kullanıcı tüm hesap bilgilerine ulaşmak için Hesap Kayıtları",
|
||||
},
|
||||
},
|
||||
instructions={
|
||||
str(KeyBases.list_key): {
|
||||
"headers": {
|
||||
"store": True,
|
||||
"url": KeyURLs.validations,
|
||||
"data": {"event_code": f"{KeyBases.list_key}", "asked_field": KeyValidations.headers},
|
||||
},
|
||||
"data": {
|
||||
"store": True,
|
||||
"url": f"{KeyBases.list_key}",
|
||||
"data": dict(page=1, limit=1),
|
||||
},
|
||||
},
|
||||
},
|
||||
endpoints={
|
||||
str(KeyBases.update_key): AccountRecordsUpdateEventMethods.retrieve_all_event_keys(),
|
||||
str(KeyBases.create_key): AccountRecordsCreateEventMethods.retrieve_all_event_keys(),
|
||||
str(KeyBases.list_key): AccountRecordsListEventMethods.retrieve_all_event_keys(),
|
||||
},
|
||||
language_models={
|
||||
str(KeyBases.list_key): {
|
||||
str(KeyBases.update_key): account_language_model_as_dict,
|
||||
str(KeyBases.create_key): account_language_created_models_as_dict,
|
||||
str(KeyBases.list_key): account_language_list_models_as_dict,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
create_page_info = PageInfo(
|
||||
name=f"{cluster_name}",
|
||||
url=PageBases.CREATE,
|
||||
icon=icon,
|
||||
instructions={
|
||||
str(KeyBases.create_key): {
|
||||
"validation": {
|
||||
"store": True,
|
||||
"url": KeyURLs.validations,
|
||||
"data": {"event_code": f"{KeyBases.create_key}", "asked_field": KeyValidations.validation },
|
||||
},
|
||||
"headers": {
|
||||
"store": True,
|
||||
"url": KeyURLs.validations,
|
||||
"data": {"event_code": f"{KeyBases.create_key}", "asked_field": KeyValidations.headers},
|
||||
},
|
||||
},
|
||||
},
|
||||
page_info={
|
||||
"en": {
|
||||
"page": "Create Account Records for reaching user all types account information",
|
||||
},
|
||||
"tr": {
|
||||
"page": "Kullanıcı tüm hesap bilgilerine ulaşmak için Hesap Kayıt Oluştur",
|
||||
},
|
||||
},
|
||||
endpoints={
|
||||
str(KeyBases.create_key): AccountRecordsCreateEventMethods.retrieve_all_event_keys(),
|
||||
},
|
||||
language_models={
|
||||
str(KeyBases.create_key): account_language_create_models_as_dict,
|
||||
},
|
||||
)
|
||||
|
||||
update_page_info = PageInfo(
|
||||
name=f"{cluster_name}",
|
||||
url=PageBases.UPDATE,
|
||||
icon=icon,
|
||||
instructions={
|
||||
str(KeyBases.update_key): {
|
||||
"validation": {
|
||||
"store": True,
|
||||
"url": KeyURLs.validations,
|
||||
"data": {"event_code": f"{KeyBases.update_key}", "asked_field": KeyValidations.validation},
|
||||
},
|
||||
"headers": {
|
||||
"store": True,
|
||||
"url": KeyURLs.validations,
|
||||
"data": {"event_code": f"{KeyBases.update_key}", "asked_field": KeyValidations.headers},
|
||||
},
|
||||
},
|
||||
},
|
||||
page_info={
|
||||
"en": {
|
||||
"page": "Update Account Records via all types account information",
|
||||
},
|
||||
"tr": {
|
||||
"page": "Tüm hesap bilgileri aracılığıyla Hesap Kayıtlarını Güncelle",
|
||||
},
|
||||
},
|
||||
endpoints={
|
||||
str(KeyBases.update_key): AccountRecordsUpdateEventMethods.retrieve_all_event_keys(),
|
||||
},
|
||||
language_models={
|
||||
str(KeyBases.update_key): account_language_update_form_models_as_dict,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
# Page Variations of the cluster
|
||||
page_infos = {
|
||||
ClustersPageInfo.dashboard_page_info.URL: ClustersPageInfo.dashboard_page_info,
|
||||
ClustersPageInfo.create_page_info.URL: ClustersPageInfo.create_page_info,
|
||||
ClustersPageInfo.update_page_info.URL: ClustersPageInfo.update_page_info,
|
||||
}
|
||||
|
||||
|
||||
# Check if all the page info is implemented in the mappings
|
||||
for t in [x for k, x in PageBases.__dict__.items() if not str(k).startswith("__")]:
|
||||
if t not in list(dict(page_infos).keys()):
|
||||
raise NotImplementedError(f"Page Info of : {t} is not implemented in mappings")
|
||||
78
Events/AllEvents/events/account/lang_models.py
Normal file
78
Events/AllEvents/events/account/lang_models.py
Normal file
@@ -0,0 +1,78 @@
|
||||
from Events.Engine.abstract_class import DefaultClusterName, LanguageModels
|
||||
from .bases import KeyBases, cluster_name
|
||||
|
||||
|
||||
account_language_update_models = LanguageModels()
|
||||
account_language_update_models.COMPONENT = "Link"
|
||||
account_language_update_models.SITE_URL = f"/update?{DefaultClusterName}={cluster_name}"
|
||||
account_language_update_models.PREFIX_URL = (
|
||||
KeyBases.update_key
|
||||
)
|
||||
account_language_update_models.PAGE_INFO = {
|
||||
"en": {
|
||||
"page": "Update Account Records",
|
||||
},
|
||||
"tr": {
|
||||
"page": "Hesap Kayıdı Güncelle",
|
||||
},
|
||||
}
|
||||
account_language_model_as_dict = account_language_update_models.as_dict()
|
||||
|
||||
|
||||
account_language_created_models = LanguageModels()
|
||||
account_language_created_models.COMPONENT = "Link"
|
||||
account_language_created_models.SITE_URL = f"/create?{DefaultClusterName}={cluster_name}"
|
||||
account_language_created_models.PREFIX_URL = (
|
||||
KeyBases.create_key
|
||||
)
|
||||
account_language_created_models.PAGE_INFO = {
|
||||
"en": {
|
||||
"page": "Create Account Records",
|
||||
},
|
||||
"tr": {"page": "Hesap Kayıdı Oluştur"},
|
||||
}
|
||||
account_language_created_models_as_dict = account_language_created_models.as_dict()
|
||||
|
||||
account_language_list_models = LanguageModels()
|
||||
account_language_list_models.COMPONENT = "Table"
|
||||
account_language_list_models.SITE_URL = f"/dashboard?{DefaultClusterName}={cluster_name}"
|
||||
account_language_list_models.PREFIX_URL = (
|
||||
KeyBases.list_key
|
||||
)
|
||||
account_language_list_models.PAGE_INFO = {
|
||||
"en": {
|
||||
"page": "List Account Records",
|
||||
},
|
||||
"tr": {
|
||||
"page": "Hesap Kayıtlarını Listele",
|
||||
},
|
||||
}
|
||||
|
||||
account_language_list_models_as_dict = account_language_list_models.as_dict()
|
||||
|
||||
account_language_create_form_models = LanguageModels()
|
||||
account_language_create_form_models.COMPONENT = "Form"
|
||||
account_language_create_form_models.SITE_URL = f"/create?{DefaultClusterName}={cluster_name}"
|
||||
account_language_create_form_models.PREFIX_URL = (
|
||||
KeyBases.create_key
|
||||
)
|
||||
account_language_create_form_models.PAGE_INFO = {
|
||||
"en": {"page": "List Account Records", "button:": "Create"},
|
||||
"tr": {"page": "Hesap Kayıtlarını Listele", "button:": "Oluştur"},
|
||||
}
|
||||
|
||||
account_language_create_models_as_dict = account_language_create_form_models.as_dict()
|
||||
|
||||
account_language_update_form_models = LanguageModels()
|
||||
account_language_update_form_models.COMPONENT = "Form"
|
||||
account_language_update_form_models.SITE_URL = f"/update?{DefaultClusterName}={cluster_name}"
|
||||
account_language_update_form_models.PREFIX_URL = (
|
||||
KeyBases.update_key
|
||||
)
|
||||
account_language_update_form_models.PAGE_INFO = {
|
||||
"en": {"page": "Update Account Records", "button:": "Update"},
|
||||
"tr": {"page": "Hesap Kayıdı Güncelle", "button:": "Güncelle"},
|
||||
}
|
||||
account_language_update_form_models_as_dict = (
|
||||
account_language_update_form_models.as_dict()
|
||||
)
|
||||
97
Events/AllEvents/events/account/models.py
Normal file
97
Events/AllEvents/events/account/models.py
Normal file
@@ -0,0 +1,97 @@
|
||||
"""
|
||||
Account records request and response models.
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from ApiLayers.ApiValidations.Request import PydanticBaseModel, ListOptions
|
||||
|
||||
|
||||
class InsertAccountRecord(PydanticBaseModel):
|
||||
|
||||
iban: str
|
||||
bank_date: str
|
||||
currency_value: float
|
||||
bank_balance: float
|
||||
currency: str
|
||||
additional_balance: float
|
||||
channel_branch: str
|
||||
process_name: str
|
||||
process_type: str
|
||||
process_comment: str
|
||||
bank_reference_code: str
|
||||
|
||||
add_comment_note: Optional[str] = None
|
||||
is_receipt_mail_send: Optional[bool] = None
|
||||
found_from: Optional[str] = None
|
||||
similarity: Optional[float] = None
|
||||
remainder_balance: Optional[float] = None
|
||||
bank_date_y: Optional[int] = None
|
||||
bank_date_m: Optional[int] = None
|
||||
bank_date_w: Optional[int] = None
|
||||
bank_date_d: Optional[int] = None
|
||||
approving_accounting_record: Optional[bool] = None
|
||||
accounting_receipt_date: Optional[str] = None
|
||||
accounting_receipt_number: Optional[int] = None
|
||||
approved_record: Optional[bool] = None
|
||||
import_file_name: Optional[str] = None
|
||||
# receive_debit_uu_id: Optional[str] = None
|
||||
budget_type_uu_id: Optional[str] = None
|
||||
company_uu_id: Optional[str] = None
|
||||
send_company_uu_id: Optional[str] = None
|
||||
customer_id: Optional[str] = None
|
||||
customer_uu_id: Optional[str] = None
|
||||
send_person_uu_id: Optional[str] = None
|
||||
approving_accounting_person_uu_id: Optional[str] = None
|
||||
build_parts_uu_id: Optional[str] = None
|
||||
build_decision_book_uu_id: Optional[str] = None
|
||||
|
||||
|
||||
class UpdateAccountRecord(PydanticBaseModel):
|
||||
|
||||
iban: Optional[str] = None
|
||||
bank_date: Optional[str] = None
|
||||
currency_value: Optional[float] = None
|
||||
bank_balance: Optional[float] = None
|
||||
currency: Optional[str] = None
|
||||
additional_balance: Optional[float] = None
|
||||
channel_branch: Optional[str] = None
|
||||
process_name: Optional[str] = None
|
||||
process_type: Optional[str] = None
|
||||
process_comment: Optional[str] = None
|
||||
bank_reference_code: Optional[str] = None
|
||||
|
||||
add_comment_note: Optional[str] = None
|
||||
is_receipt_mail_send: Optional[bool] = None
|
||||
found_from: Optional[str] = None
|
||||
similarity: Optional[float] = None
|
||||
remainder_balance: Optional[float] = None
|
||||
bank_date_y: Optional[int] = None
|
||||
bank_date_m: Optional[int] = None
|
||||
bank_date_w: Optional[int] = None
|
||||
bank_date_d: Optional[int] = None
|
||||
approving_accounting_record: Optional[bool] = None
|
||||
accounting_receipt_date: Optional[str] = None
|
||||
accounting_receipt_number: Optional[int] = None
|
||||
approved_record: Optional[bool] = None
|
||||
import_file_name: Optional[str] = None
|
||||
receive_debit_uu_id: Optional[str] = None
|
||||
budget_type_uu_id: Optional[str] = None
|
||||
company_uu_id: Optional[str] = None
|
||||
send_company_uu_id: Optional[str] = None
|
||||
customer_id: Optional[str] = None
|
||||
customer_uu_id: Optional[str] = None
|
||||
send_person_uu_id: Optional[str] = None
|
||||
approving_accounting_person_uu_id: Optional[str] = None
|
||||
build_parts_uu_id: Optional[str] = None
|
||||
build_decision_book_uu_id: Optional[str] = None
|
||||
|
||||
|
||||
class ListAccountRecord(ListOptions):
|
||||
pass
|
||||
|
||||
|
||||
class AccountRequestValidators:
|
||||
InsertAccountRecord = InsertAccountRecord
|
||||
UpdateAccountRecord = UpdateAccountRecord
|
||||
ListAccountRecord = ListAccountRecord
|
||||
Reference in New Issue
Block a user