auth service up running
This commit is contained in:
parent
4eb95e4d9c
commit
03accfed1b
|
|
@ -30,19 +30,16 @@ class ActionsSchema(ABC):
|
|||
Raises:
|
||||
HTTPException: If endpoint is not found in database
|
||||
"""
|
||||
from databases import EndpointRestriction
|
||||
|
||||
endpoint_restriction = EndpointRestriction.filter_one(
|
||||
EndpointRestriction.endpoint_name.ilike(f"%{self.endpoint}%"),
|
||||
system=True
|
||||
).data
|
||||
|
||||
if not endpoint_restriction:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail=f"Endpoint {self.endpoint} not found in the database"
|
||||
)
|
||||
return endpoint_restriction
|
||||
# Temporarily return a dummy response to skip endpoint restriction checks
|
||||
return {
|
||||
"endpoint_name": self.endpoint,
|
||||
"endpoint_function": "dummy_function",
|
||||
"endpoint_method": "GET",
|
||||
"endpoint_desc": "Temporary endpoint",
|
||||
"endpoint_code": "dummy_code",
|
||||
"id": 1,
|
||||
"uu_id": "dummy_uuid"
|
||||
}
|
||||
|
||||
|
||||
class ActionsSchemaFactory:
|
||||
|
|
|
|||
|
|
@ -6,16 +6,11 @@ from api_validations.validations_request import (
|
|||
UpdateAccountRecord,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from ApiServices.api_handlers import AlchemyJsonResponse
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from api_validations.validations_response.account import AccountListResponse
|
||||
from api_validations.validations_response.account_responses import AccountRecordsListResponse
|
||||
from databases import (
|
||||
AccountRecords,
|
||||
BuildIbans,
|
||||
)
|
||||
from api_validations.validations_response import AccountRecordResponse
|
||||
from databases import AccountRecords, BuildIbans
|
||||
from databases.sql_models.building.build import BuildLivingSpace
|
||||
from databases.sql_models.building.decision_book import BuildDecisionBookPayments
|
||||
from databases.sql_models.others.enums import ApiEnumDropdown
|
||||
|
|
@ -32,8 +27,8 @@ class AccountRecordsListEventMethods(MethodToEvent):
|
|||
"208e6273-17ef-44f0-814a-8098f816b63a": "account_records_list_flt_res",
|
||||
}
|
||||
__event_validation__ = {
|
||||
"7192c2aa-5352-4e36-98b3-dafb7d036a3d": AccountRecordsListResponse,
|
||||
"208e6273-17ef-44f0-814a-8098f816b63a": AccountRecordsListResponse,
|
||||
"7192c2aa-5352-4e36-98b3-dafb7d036a3d": AccountRecordResponse,
|
||||
"208e6273-17ef-44f0-814a-8098f816b63a": AccountRecordResponse,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
@ -59,7 +54,7 @@ class AccountRecordsListEventMethods(MethodToEvent):
|
|||
result=records,
|
||||
cls_object=AccountRecords,
|
||||
filter_attributes=list_options,
|
||||
response_model=AccountRecordsListResponse
|
||||
response_model=AccountRecordResponse
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -1,17 +1,22 @@
|
|||
from typing import Union
|
||||
from typing import Union, Dict, Any, List
|
||||
|
||||
from fastapi.exceptions import HTTPException
|
||||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from api_validations.validations_response.address import (
|
||||
from api_validations.validations_response import (
|
||||
ListAddressResponse,
|
||||
AddressPostCodeResponse,
|
||||
)
|
||||
from databases import (
|
||||
AddressPostcode,
|
||||
Addresses,
|
||||
RelationshipEmployee2PostCode,
|
||||
AddressDistrict,
|
||||
AddressCity,
|
||||
AddressCountry,
|
||||
AddressStreet,
|
||||
AddressNeighborhood,
|
||||
AddressPostcode,
|
||||
# AddressCountryCode,
|
||||
RelationshipEmployee2PostCode,
|
||||
Addresses,
|
||||
)
|
||||
|
||||
from api_validations.validations_request import (
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ from api_validations.validations_request import (
|
|||
EmployeeSelection,
|
||||
)
|
||||
|
||||
from api_validations.validations_response.auth_responses import (
|
||||
from api_validations.validations_response import (
|
||||
AuthenticationLoginResponse,
|
||||
AuthenticationRefreshResponse,
|
||||
AuthenticationUserInfoResponse
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import typing
|
|||
from typing import Union
|
||||
|
||||
from fastapi import status, HTTPException
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from databases import (
|
||||
Build,
|
||||
|
|
@ -19,8 +18,7 @@ from api_validations.validations_request import (
|
|||
PatchRecord,
|
||||
ListOptions,
|
||||
)
|
||||
from api_validations.validations_response import ListBuildingResponse
|
||||
|
||||
from api_validations.validations_response import BuildResponse
|
||||
from ApiServices.api_handlers import AlchemyJsonResponse
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
|
@ -36,7 +34,7 @@ class BuildListEventMethods(MethodToEvent):
|
|||
"68b3b5ed-b74c-4a27-820f-3959214e94e9": "build_list",
|
||||
}
|
||||
__event_validation__ = {
|
||||
"68b3b5ed-b74c-4a27-820f-3959214e94e9": ListBuildingResponse,
|
||||
"68b3b5ed-b74c-4a27-820f-3959214e94e9": BuildResponse,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
@ -59,6 +57,9 @@ class BuildListEventMethods(MethodToEvent):
|
|||
completed=True,
|
||||
message="Building records listed successfully",
|
||||
result=records,
|
||||
cls_object=Build,
|
||||
filter_attributes=list_options,
|
||||
response_model=BuildResponse
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from api_validations.validations_request import (
|
|||
ListOptions,
|
||||
)
|
||||
|
||||
from api_validations.validations_response.building_responses import BuildAreaListResponse
|
||||
from api_validations.validations_response import BuildResponse, BuildAreaResponse
|
||||
|
||||
from ApiServices.api_handlers import AlchemyJsonResponse
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
|
|
@ -25,7 +25,7 @@ class BuildAreaListEventMethods(MethodToEvent):
|
|||
"0bb51845-65a2-4340-8872-a3b5aad95468": "build_area_list",
|
||||
}
|
||||
__event_validation__ = {
|
||||
"0bb51845-65a2-4340-8872-a3b5aad95468": BuildAreaListResponse,
|
||||
"0bb51845-65a2-4340-8872-a3b5aad95468": BuildAreaResponse,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
@ -56,7 +56,7 @@ class BuildAreaListEventMethods(MethodToEvent):
|
|||
result=records,
|
||||
cls_object=BuildArea,
|
||||
filter_attributes=list_options,
|
||||
response_model=BuildAreaListResponse
|
||||
response_model=BuildResponse
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,18 @@
|
|||
from typing import Union
|
||||
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi import status
|
||||
|
||||
from api_validations.validations_response.parts import BuildPartsListResponse
|
||||
from databases import (
|
||||
Build,
|
||||
BuildParts,
|
||||
)
|
||||
from ApiServices.api_handlers import AlchemyJsonResponse
|
||||
from api_validations.validations_response import BuildPartsListResponse
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
from ApiServices.api_handlers import AlchemyJsonResponse
|
||||
|
||||
from api_validations.validations_request import (
|
||||
InsertBuildParts,
|
||||
UpdateBuildParts,
|
||||
ListOptions,
|
||||
)
|
||||
|
||||
from databases import (
|
||||
Build,
|
||||
BuildParts,
|
||||
)
|
||||
|
||||
class BuildingBuildPartsListEventMethods(MethodToEvent):
|
||||
|
||||
|
|
@ -48,6 +43,9 @@ class BuildingBuildPartsListEventMethods(MethodToEvent):
|
|||
completed=True,
|
||||
message="Building parts listed successfully",
|
||||
result=records,
|
||||
cls_object=BuildParts,
|
||||
filter_attributes=list_options,
|
||||
response_model=BuildPartsListResponse,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from api_validations.validations_request import (
|
|||
ListOptions,
|
||||
)
|
||||
|
||||
from api_validations.validations_response.building_responses import BuildSitesListResponse
|
||||
from api_validations.validations_response import BuildSitesResponse
|
||||
|
||||
from ApiServices.api_handlers import AlchemyJsonResponse
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
|
|
@ -25,7 +25,7 @@ class BuildSitesListEventMethods(MethodToEvent):
|
|||
"6798414c-6c7d-47f0-9d8b-6935a0f51c2e": "build_sites_list",
|
||||
}
|
||||
__event_validation__ = {
|
||||
"6798414c-6c7d-47f0-9d8b-6935a0f51c2e": BuildSitesListResponse,
|
||||
"6798414c-6c7d-47f0-9d8b-6935a0f51c2e": BuildSitesResponse,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
@ -64,7 +64,7 @@ class BuildSitesListEventMethods(MethodToEvent):
|
|||
result=records,
|
||||
cls_object=BuildSites,
|
||||
filter_attributes=list_options,
|
||||
response_model=BuildSitesListResponse
|
||||
response_model=BuildSitesResponse
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from ApiServices.api_handlers import AlchemyJsonResponse
|
|||
from api_validations.validations_request import (
|
||||
ListOptions,
|
||||
)
|
||||
from api_validations.validations_response.building_responses import BuildTypesListResponse
|
||||
from api_validations.validations_response import BuildTypesResponse
|
||||
from databases.sql_models.building.build import BuildTypes
|
||||
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ class BuildTypesListEventMethods(MethodToEvent):
|
|||
"5344d03c-fc47-43ec-8c44-6c2acd7e5d9f": "build_types_list",
|
||||
}
|
||||
__event_validation__ = {
|
||||
"5344d03c-fc47-43ec-8c44-6c2acd7e5d9f": BuildTypesListResponse
|
||||
"5344d03c-fc47-43ec-8c44-6c2acd7e5d9f": BuildTypesResponse
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
@ -43,13 +43,10 @@ class BuildTypesListEventMethods(MethodToEvent):
|
|||
return AlchemyJsonResponse(
|
||||
completed=False,
|
||||
message="You are not authorized to access this endpoint",
|
||||
result=None
|
||||
)
|
||||
else:
|
||||
return AlchemyJsonResponse(
|
||||
completed=False,
|
||||
message="You are not authorized to access this endpoint",
|
||||
result=None
|
||||
result=None,
|
||||
cls_object=BuildTypes,
|
||||
filter_attributes=list_options,
|
||||
response_model=BuildTypesResponse
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ from api_validations.validations_request import (
|
|||
UpdateBuildLivingSpace,
|
||||
ListOptions,
|
||||
)
|
||||
from api_validations.validations_response.living_space import LivingSpaceListResponse
|
||||
from api_validations.validations_response import LivingSpaceListResponse
|
||||
from databases.sql_models.event.event import Services
|
||||
|
||||
|
||||
|
|
@ -108,7 +108,10 @@ class BuildingLivingSpacesListEventMethods(MethodToEvent):
|
|||
return AlchemyJsonResponse(
|
||||
completed=True,
|
||||
message="Living spaces listed successfully",
|
||||
result=records
|
||||
result=records,
|
||||
cls_object=BuildLivingSpace,
|
||||
filter_attributes=list_options,
|
||||
response_model=LivingSpaceListResponse,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from api_validations.validations_request import (
|
|||
PatchRecord,
|
||||
)
|
||||
|
||||
from api_validations.validations_response.company_responses import CompanyListResponse
|
||||
from api_validations.validations_response import CompanyListResponse
|
||||
|
||||
from api_events.events.abstract_class import MethodToEvent, ActionsSchema
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
|
@ -52,7 +52,7 @@ class CompanyListEventMethods(MethodToEvent):
|
|||
result=records,
|
||||
cls_object=Companies,
|
||||
filter_attributes=list_options,
|
||||
response_model=CompanyListResponse
|
||||
response_model=CompanyListResponse,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from typing import Union
|
||||
|
||||
from api_validations.validations_response.parts import BuildPartsListResponse
|
||||
from api_validations.validations_response import BuildPartsListResponse
|
||||
from databases import (
|
||||
BuildParts,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from typing import Union
|
|||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from api_validations.validations_response.people import PeopleListResponse
|
||||
from api_validations.validations_response import PeopleListResponse
|
||||
from databases import (
|
||||
People,
|
||||
Users,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,119 @@
|
|||
from .building import ListBuildingResponse
|
||||
from .building_responses import (
|
||||
BuildResponse,
|
||||
BuildLivingSpaceResponse,
|
||||
BuildLivingSpaceCollection,
|
||||
BuildAreaResponse,
|
||||
BuildAreaCollection,
|
||||
BuildTypesResponse,
|
||||
BuildTypesCollection,
|
||||
BuildPartsResponse,
|
||||
BuildPartsCollection,
|
||||
BuildSitesResponse,
|
||||
BuildSitesCollection,
|
||||
Part2EmployeeResponse,
|
||||
Part2EmployeeCollection,
|
||||
BuildPersonProvidingResponse,
|
||||
BuildPersonProvidingCollection,
|
||||
RelationshipEmployee2BuildResponse,
|
||||
RelationshipEmployee2BuildCollection,
|
||||
BuildCompaniesProvidingResponse,
|
||||
BuildCompaniesProvidingCollection,
|
||||
BuildManagementResponse,
|
||||
BuildManagementCollection
|
||||
)
|
||||
from .account_responses import (
|
||||
AccountRecordResponse,
|
||||
AccountRecordCollection,
|
||||
AccountRecordExchangeResponse,
|
||||
AccountRecordExchangeCollection
|
||||
)
|
||||
from .address_responses import ListAddressResponse, AddressPostCodeResponse
|
||||
from .auth_responses import (
|
||||
AuthenticationLoginResponse,
|
||||
AuthenticationRefreshResponse,
|
||||
AuthenticationUserInfoResponse
|
||||
)
|
||||
from .base_responses import BaseResponse, CrudCollection
|
||||
from .budget_responses import (
|
||||
DecisionBookBudgetBooksResponse,
|
||||
DecisionBookBudgetBooksCollection,
|
||||
DecisionBookBudgetCodesResponse,
|
||||
DecisionBookBudgetCodesCollection,
|
||||
DecisionBookBudgetMasterResponse,
|
||||
DecisionBookBudgetMasterCollection,
|
||||
DecisionBookBudgetsResponse,
|
||||
DecisionBookBudgetsCollection
|
||||
)
|
||||
from .company_responses import (
|
||||
CompanyListResponse,
|
||||
CompanyDepartmentListResponse,
|
||||
CompanyDutyListResponse,
|
||||
CompanyEmployeeListResponse
|
||||
)
|
||||
from .decision_book_responses import (
|
||||
BuildDecisionBookResponse,
|
||||
BuildDecisionBookCollection,
|
||||
BuildDecisionBookInvitationsResponse,
|
||||
BuildDecisionBookInvitationsCollection,
|
||||
BuildDecisionBookPersonResponse,
|
||||
BuildDecisionBookPersonCollection,
|
||||
BuildDecisionBookPersonOccupantsResponse,
|
||||
BuildDecisionBookPersonOccupantsCollection,
|
||||
BuildDecisionBookItemsResponse,
|
||||
BuildDecisionBookItemsCollection,
|
||||
BuildDecisionBookItemsUnapprovedResponse,
|
||||
BuildDecisionBookItemsUnapprovedCollection,
|
||||
BuildDecisionBookPaymentsResponse,
|
||||
BuildDecisionBookPaymentsCollection,
|
||||
BuildDecisionBookLegalResponse,
|
||||
BuildDecisionBookLegalCollection
|
||||
)
|
||||
from .living_space_responses import LivingSpaceListResponse
|
||||
from .parts_responses import BuildPartsListResponse
|
||||
from .people_responses import PeopleListResponse
|
||||
|
||||
__all__ = [
|
||||
"ListBuildingResponse",
|
||||
"BuildResponse",
|
||||
"AccountRecordResponse",
|
||||
"AccountRecordCollection",
|
||||
"AccountRecordExchangeResponse",
|
||||
"AccountRecordExchangeCollection",
|
||||
"ListAddressResponse",
|
||||
"AddressPostCodeResponse",
|
||||
"AuthenticationLoginResponse",
|
||||
"AuthenticationRefreshResponse",
|
||||
"AuthenticationUserInfoResponse",
|
||||
"BaseResponse",
|
||||
"CrudCollection",
|
||||
"DecisionBookBudgetBooksResponse",
|
||||
"DecisionBookBudgetBooksCollection",
|
||||
"DecisionBookBudgetCodesResponse",
|
||||
"DecisionBookBudgetCodesCollection",
|
||||
"DecisionBookBudgetMasterResponse",
|
||||
"DecisionBookBudgetMasterCollection",
|
||||
"DecisionBookBudgetsResponse",
|
||||
"DecisionBookBudgetsCollection",
|
||||
"CompanyListResponse",
|
||||
"CompanyDepartmentListResponse",
|
||||
"CompanyDutyListResponse",
|
||||
"CompanyEmployeeListResponse",
|
||||
"BuildDecisionBookResponse",
|
||||
"BuildDecisionBookCollection",
|
||||
"BuildDecisionBookInvitationsResponse",
|
||||
"BuildDecisionBookInvitationsCollection",
|
||||
"BuildDecisionBookPersonResponse",
|
||||
"BuildDecisionBookPersonCollection",
|
||||
"BuildDecisionBookPersonOccupantsResponse",
|
||||
"BuildDecisionBookPersonOccupantsCollection",
|
||||
"BuildDecisionBookItemsResponse",
|
||||
"BuildDecisionBookItemsCollection",
|
||||
"BuildDecisionBookItemsUnapprovedResponse",
|
||||
"BuildDecisionBookItemsUnapprovedCollection",
|
||||
"BuildDecisionBookPaymentsResponse",
|
||||
"BuildDecisionBookPaymentsCollection",
|
||||
"BuildDecisionBookLegalResponse",
|
||||
"BuildDecisionBookLegalCollection",
|
||||
"LivingSpaceListResponse",
|
||||
"BuildPartsListResponse",
|
||||
"PeopleListResponse"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -164,7 +164,48 @@ class AccountDetailCollection(CrudCollection[AccountDetailResponse]):
|
|||
|
||||
|
||||
class AccountRecordResponse(BaseResponse):
|
||||
"""Response model for account records"""
|
||||
"""Response model for account financial records.
|
||||
|
||||
This model represents a financial transaction record in the system,
|
||||
including bank transaction details, amounts, and related metadata.
|
||||
|
||||
Attributes:
|
||||
iban (str): International Bank Account Number
|
||||
bank_date (datetime): Date when the transaction occurred at the bank
|
||||
currency_value (Decimal): Original transaction amount
|
||||
bank_balance (Decimal): Account balance after the transaction
|
||||
currency (str): Currency code (e.g., "TRY", "USD")
|
||||
additional_balance (Decimal): Any additional balance adjustments
|
||||
channel_branch (str): Bank branch or channel where transaction occurred
|
||||
process_name (str): Name/type of the transaction
|
||||
process_type (str): Classification of the transaction
|
||||
process_comment (str): Additional transaction details or notes
|
||||
bank_reference_code (str): Bank's reference code for the transaction
|
||||
add_comment_note (Optional[str]): Additional internal notes
|
||||
is_receipt_mail_send (Optional[bool]): Whether receipt was emailed
|
||||
found_from (Optional[str]): Source of the transaction record
|
||||
similarity (Optional[float]): Matching confidence for duplicate detection
|
||||
remainder_balance (Optional[Decimal]): Remaining balance if partial
|
||||
bank_date_y (Optional[int]): Year of bank transaction
|
||||
bank_date_m (Optional[int]): Month of bank transaction
|
||||
bank_date_w (Optional[int]): Week of bank transaction
|
||||
bank_date_d (Optional[int]): Day of bank transaction
|
||||
approving_accounting_record (Optional[bool]): Accounting approval status
|
||||
accounting_receipt_date (Optional[datetime]): When receipt was processed
|
||||
accounting_receipt_number (Optional[int]): Receipt reference number
|
||||
approved_record (Optional[bool]): Whether record is approved
|
||||
import_file_name (Optional[str]): Source file if imported
|
||||
receive_debit_uu_id (Optional[str]): Related debit record ID
|
||||
budget_type_uu_id (Optional[str]): Associated budget type ID
|
||||
company_uu_id (Optional[str]): Associated company ID
|
||||
send_company_uu_id (Optional[str]): Sending company ID
|
||||
customer_id (Optional[str]): Associated customer ID
|
||||
customer_uu_id (Optional[str]): Associated customer UUID
|
||||
send_person_uu_id (Optional[str]): Sending person ID
|
||||
approving_accounting_person_uu_id (Optional[str]): Approver ID
|
||||
build_parts_uu_id (Optional[str]): Related building part ID
|
||||
build_decision_book_uu_id (Optional[str]): Related decision book ID
|
||||
"""
|
||||
iban: str
|
||||
bank_date: datetime
|
||||
currency_value: Decimal
|
||||
|
|
@ -203,12 +244,28 @@ class AccountRecordResponse(BaseResponse):
|
|||
|
||||
|
||||
class AccountRecordCollection(CrudCollection[AccountRecordResponse]):
|
||||
"""Collection of account records"""
|
||||
"""Collection of account financial records.
|
||||
|
||||
This model represents a paginated list of account records with
|
||||
sorting and pagination information.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class AccountRecordExchangeResponse(BaseResponse):
|
||||
"""Response model for account record exchanges"""
|
||||
"""Response model for currency exchange records.
|
||||
|
||||
This model represents a currency exchange transaction, tracking
|
||||
exchange rates and converted amounts for financial records.
|
||||
|
||||
Attributes:
|
||||
account_record_id (int): ID of the related account record
|
||||
account_record_uu_id (str): UUID of the related account record
|
||||
exchange_rate (Decimal): Applied exchange rate
|
||||
exchange_currency (str): Target currency code
|
||||
exchange_value (Decimal): Converted amount
|
||||
exchange_date (datetime): When the exchange was calculated
|
||||
"""
|
||||
account_record_id: int
|
||||
account_record_uu_id: str
|
||||
exchange_rate: Decimal
|
||||
|
|
@ -218,7 +275,11 @@ class AccountRecordExchangeResponse(BaseResponse):
|
|||
|
||||
|
||||
class AccountRecordExchangeCollection(CrudCollection[AccountRecordExchangeResponse]):
|
||||
"""Collection of account record exchanges"""
|
||||
"""Collection of currency exchange records.
|
||||
|
||||
This model represents a paginated list of currency exchange records
|
||||
with sorting and pagination information.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,27 @@ from uuid import UUID
|
|||
T = TypeVar('T')
|
||||
|
||||
class BaseResponse(BaseModel):
|
||||
"""Base response model that all other response models inherit from"""
|
||||
"""Base response model that all response models inherit from.
|
||||
|
||||
This model provides common fields that are present in all database records,
|
||||
including tracking information (created/updated timestamps), user actions
|
||||
(created by, updated by, confirmed by), and record status (active, deleted).
|
||||
|
||||
Attributes:
|
||||
uu_id (str): Unique identifier for the record, typically a UUID
|
||||
created_at (datetime): Timestamp when the record was created
|
||||
updated_at (Optional[datetime]): Timestamp when the record was last updated
|
||||
created_by (Optional[str]): Username or identifier of the user who created the record
|
||||
updated_by (Optional[str]): Username or identifier of the user who last updated the record
|
||||
confirmed_by (Optional[str]): Username or identifier of the user who confirmed the record
|
||||
is_confirmed (Optional[bool]): Whether the record has been confirmed/approved
|
||||
active (Optional[bool]): Whether the record is currently active
|
||||
deleted (Optional[bool]): Whether the record has been marked as deleted
|
||||
expiry_starts (Optional[datetime]): When the record becomes valid/active
|
||||
expiry_ends (Optional[datetime]): When the record expires/becomes inactive
|
||||
is_notification_send (Optional[bool]): Whether notifications have been sent for this record
|
||||
is_email_send (Optional[bool]): Whether emails have been sent for this record
|
||||
"""
|
||||
uu_id: str
|
||||
created_at: datetime
|
||||
updated_at: Optional[datetime]
|
||||
|
|
@ -22,11 +42,48 @@ class BaseResponse(BaseModel):
|
|||
is_email_send: Optional[bool] = False
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration for the base response model.
|
||||
|
||||
Attributes:
|
||||
from_attributes (bool): Enables ORM mode for SQLAlchemy integration
|
||||
"""
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class CrudCollection(BaseModel, Generic[T]):
|
||||
"""Base collection model for paginated responses"""
|
||||
"""Base collection model for paginated responses.
|
||||
|
||||
This model is used to return collections of items with pagination information.
|
||||
It is generic over the type of items in the collection, allowing it to be
|
||||
used with any response model.
|
||||
|
||||
Type Parameters:
|
||||
T: The type of items in the collection
|
||||
|
||||
Attributes:
|
||||
page (int): Current page number, 1-based indexing
|
||||
size (int): Number of items per page
|
||||
total (int): Total number of items across all pages
|
||||
order_field (str): Field used for sorting the collection
|
||||
order_type (str): Sort direction ('asc' or 'desc')
|
||||
items (List[T]): List of items in the current page
|
||||
|
||||
Example:
|
||||
```python
|
||||
class UserResponse(BaseResponse):
|
||||
name: str
|
||||
email: str
|
||||
|
||||
users = CrudCollection[UserResponse](
|
||||
page=1,
|
||||
size=10,
|
||||
total=100,
|
||||
order_field="name",
|
||||
order_type="asc",
|
||||
items=[...]
|
||||
)
|
||||
```
|
||||
"""
|
||||
page: int = 1
|
||||
size: int = 10
|
||||
total: int = 0
|
||||
|
|
@ -35,4 +92,9 @@ class CrudCollection(BaseModel, Generic[T]):
|
|||
items: List[T] = []
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration for the collection model.
|
||||
|
||||
Attributes:
|
||||
from_attributes (bool): Enables ORM mode for SQLAlchemy integration
|
||||
"""
|
||||
from_attributes = True
|
||||
|
|
|
|||
|
|
@ -1,24 +1,30 @@
|
|||
from datetime import datetime
|
||||
from typing import Optional, List, Union
|
||||
|
||||
from sqlalchemy.orm import mapped_column, Mapped
|
||||
from sqlalchemy import (
|
||||
String,
|
||||
Integer,
|
||||
Boolean,
|
||||
ForeignKey,
|
||||
Index,
|
||||
SmallInteger,
|
||||
Boolean,
|
||||
TIMESTAMP,
|
||||
func,
|
||||
Text,
|
||||
BigInteger,
|
||||
Numeric,
|
||||
UUID,
|
||||
SmallInteger,
|
||||
)
|
||||
|
||||
from databases.sql_models.core_mixin import CrudCollection
|
||||
from databases.language_models import (
|
||||
from databases.language_models.account.account import (
|
||||
AccountBooksLanguageModel,
|
||||
AccountDetailLanguageModel,
|
||||
AccountMasterLanguageModel,
|
||||
AccountRecordExchangesLanguageModel,
|
||||
AccountCodesLanguageModel,
|
||||
AccountRecordsLanguageModel,
|
||||
AccountRecordExchangesLanguageModel,
|
||||
AccountDetailLanguageModel,
|
||||
AccountCodeParserLanguageModel,
|
||||
AccountMasterLanguageModel,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -29,7 +35,7 @@ class AccountBooks(CrudCollection):
|
|||
__language_model__ = AccountBooksLanguageModel
|
||||
|
||||
country: Mapped[str] = mapped_column(String, nullable=False)
|
||||
branch_type: Mapped[str] = mapped_column(SmallInteger, server_default="0")
|
||||
branch_type: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
|
||||
company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"), nullable=False)
|
||||
company_uu_id: Mapped[str] = mapped_column(String, nullable=False)
|
||||
|
|
@ -79,7 +85,7 @@ class AccountCodes(CrudCollection):
|
|||
account_code_seperator: Mapped[str] = mapped_column(String(1), server_default=".")
|
||||
|
||||
system_id: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
locked: Mapped[bool] = mapped_column(SmallInteger, server_default="0")
|
||||
locked: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
|
||||
company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
||||
company_uu_id: Mapped[str] = mapped_column(
|
||||
|
|
@ -120,7 +126,7 @@ class AccountCodeParser(CrudCollection):
|
|||
|
||||
__tablename__ = "account_code_parser"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = AccountCodeParserLanguageModel
|
||||
__language_model__ = AccountCodesLanguageModel
|
||||
|
||||
account_code_1: Mapped[str] = mapped_column(String, nullable=False, comment="Order")
|
||||
account_code_2: Mapped[str] = mapped_column(String, nullable=False, comment="Order")
|
||||
|
|
@ -297,7 +303,7 @@ class AccountDetail(CrudCollection):
|
|||
canceled: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
cross_ref: Mapped[int] = mapped_column(Integer, server_default="0")
|
||||
data_center_id: Mapped[str] = mapped_column(String, server_default="")
|
||||
data_center_rec_num: Mapped[str] = mapped_column(Integer, server_default="0")
|
||||
data_center_rec_num: Mapped[int] = mapped_column(Integer, server_default="0")
|
||||
status_id: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
|
||||
plug_type_id: Mapped[int] = mapped_column(
|
||||
|
|
@ -728,7 +734,6 @@ class AccountRecords(CrudCollection):
|
|||
# ),
|
||||
# {"comment": "Account Record Decision Payment Closed Information"},
|
||||
# )
|
||||
#
|
||||
|
||||
|
||||
class AccountRecordExchanges(CrudCollection):
|
||||
|
|
|
|||
|
|
@ -1,35 +1,45 @@
|
|||
import typing
|
||||
from operator import or_
|
||||
from datetime import datetime, timedelta
|
||||
from platform import system
|
||||
from typing import List
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
from sqlalchemy.orm import mapped_column, relationship, Mapped
|
||||
from sqlalchemy import (
|
||||
String,
|
||||
Integer,
|
||||
Boolean,
|
||||
ForeignKey,
|
||||
Index,
|
||||
SmallInteger,
|
||||
Boolean,
|
||||
TIMESTAMP,
|
||||
func,
|
||||
Text,
|
||||
Numeric,
|
||||
or_,
|
||||
)
|
||||
|
||||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
from databases.sql_models.core_mixin import CrudCollection
|
||||
|
||||
from databases.extensions.selector_classes import SelectActionWithEmployee
|
||||
from api_validations.validations_request import (
|
||||
InsertBuildParts,
|
||||
InsertBuild,
|
||||
InsertBuildParts,
|
||||
InsertBuildLivingSpace,
|
||||
UpdateBuild,
|
||||
)
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
|
||||
|
||||
from databases.language_models.building.build import (
|
||||
BuildTypesLanguageModel,
|
||||
Part2EmployeeLanguageModel,
|
||||
BuildPartsLanguageModel,
|
||||
BuildSitesLanguageModel,
|
||||
RelationshipEmployee2BuildLanguageModel,
|
||||
BuildLanguageModel,
|
||||
BuildPartsLanguageModel,
|
||||
BuildLivingSpaceLanguageModel,
|
||||
BuildManagementLanguageModel,
|
||||
BuildAreaLanguageModel,
|
||||
BuildCompaniesProvidingLanguageModel,
|
||||
BuildPersonProvidingLanguageModel,
|
||||
)
|
||||
|
||||
class BuildTypes(CrudCollection):
|
||||
"""
|
||||
|
|
@ -39,6 +49,7 @@ class BuildTypes(CrudCollection):
|
|||
|
||||
__tablename__ = "build_types"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildTypesLanguageModel
|
||||
__include__fields__ = []
|
||||
|
||||
function_code: Mapped[str] = mapped_column(
|
||||
|
|
@ -68,6 +79,7 @@ class Part2Employee(CrudCollection):
|
|||
|
||||
__tablename__ = "part2employee"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = Part2EmployeeLanguageModel
|
||||
__include__fields__ = []
|
||||
|
||||
build_id: Mapped[int] = mapped_column(Integer, comment="Building ID")
|
||||
|
|
@ -93,6 +105,7 @@ class RelationshipEmployee2Build(CrudCollection):
|
|||
|
||||
__tablename__ = "relationship_employee2build"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = RelationshipEmployee2BuildLanguageModel
|
||||
|
||||
company_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("companies.id"), nullable=False
|
||||
|
|
@ -129,6 +142,7 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
|||
|
||||
__tablename__ = "build"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildLanguageModel
|
||||
__include__fields__ = []
|
||||
__access_by__ = []
|
||||
__many__table__ = RelationshipEmployee2Build
|
||||
|
|
@ -145,10 +159,10 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
|||
)
|
||||
|
||||
max_floor: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="1", nullable=False, comment="Max Floor"
|
||||
Integer, server_default="1", nullable=False, comment="Max Floor"
|
||||
)
|
||||
underground_floor: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="0", nullable=False, comment="Underground Floor"
|
||||
Integer, server_default="0", nullable=False, comment="Underground Floor"
|
||||
)
|
||||
build_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP(timezone=True), server_default="1900-01-01"
|
||||
|
|
@ -159,18 +173,18 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
|||
comment="Building annual ordinary meeting period",
|
||||
)
|
||||
tax_no: Mapped[str] = mapped_column(String(24), server_default="")
|
||||
lift_count: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
lift_count: Mapped[int] = mapped_column(Integer, server_default="0")
|
||||
heating_system: Mapped[bool] = mapped_column(Boolean, server_default="True")
|
||||
cooling_system: Mapped[bool] = mapped_column(Boolean, server_default="False")
|
||||
hot_water_system: Mapped[bool] = mapped_column(Boolean, server_default="False")
|
||||
block_service_man_count: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="0"
|
||||
Integer, server_default="0"
|
||||
)
|
||||
security_service_man_count: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="0"
|
||||
Integer, server_default="0"
|
||||
)
|
||||
garage_count: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="0", comment="Garage Count"
|
||||
Integer, server_default="0", comment="Garage Count"
|
||||
)
|
||||
management_room_id: Mapped[int] = mapped_column(
|
||||
Integer, nullable=True, comment="Management Room ID"
|
||||
|
|
@ -290,7 +304,7 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
|||
def top_flat(self):
|
||||
max_flat_no = 0
|
||||
for part in self.parts:
|
||||
if part.part_no > self.max_flat_no:
|
||||
if part.part_no > self.max_floor:
|
||||
max_flat_no = part.part_no
|
||||
return max_flat_no
|
||||
|
||||
|
|
@ -298,7 +312,7 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
|||
def bottom_flat(self):
|
||||
min_flat_no = 0
|
||||
for part in self.parts:
|
||||
if part.part_no < self.max_flat_no:
|
||||
if part.part_no < self.max_floor:
|
||||
min_flat_no = part.part_no
|
||||
return min_flat_no
|
||||
|
||||
|
|
@ -352,6 +366,7 @@ class BuildParts(CrudCollection):
|
|||
|
||||
__tablename__ = "build_parts"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildPartsLanguageModel
|
||||
__include__fields__ = []
|
||||
__enum_list__ = [("part_direction", "Directions", "NN")]
|
||||
|
||||
|
|
@ -361,10 +376,10 @@ class BuildParts(CrudCollection):
|
|||
)
|
||||
# part_name: Mapped[str] = mapped_column(String(24), server_default="", nullable=False, comment="Part Name")
|
||||
part_no: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="0", nullable=False, comment="Part Number"
|
||||
Integer, server_default="0", nullable=False, comment="Part Number"
|
||||
)
|
||||
part_level: Mapped[int] = mapped_column(
|
||||
SmallInteger, server_default="0", comment="Building Part Level"
|
||||
Integer, server_default="0", comment="Building Part Level"
|
||||
)
|
||||
part_code: Mapped[str] = mapped_column(
|
||||
String, server_default="", nullable=False, comment="Part Code"
|
||||
|
|
@ -496,6 +511,7 @@ class BuildLivingSpace(CrudCollection):
|
|||
|
||||
__tablename__ = "build_living_space"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildLivingSpaceLanguageModel
|
||||
__include__fields__ = []
|
||||
|
||||
fix_value: Mapped[float] = mapped_column(
|
||||
|
|
@ -513,7 +529,7 @@ class BuildLivingSpace(CrudCollection):
|
|||
String, server_default="", comment="Agreement No"
|
||||
)
|
||||
marketing_process: Mapped[bool] = mapped_column(Boolean, server_default="False")
|
||||
marketing_layer: Mapped[int] = mapped_column(SmallInteger, server_default="0")
|
||||
marketing_layer: Mapped[int] = mapped_column(Integer, server_default="0")
|
||||
|
||||
build_parts_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_parts.id"),
|
||||
|
|
@ -550,7 +566,7 @@ class BuildLivingSpace(CrudCollection):
|
|||
def create_action(
|
||||
cls,
|
||||
data: dict,
|
||||
token_dict: typing.Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
|
||||
):
|
||||
from databases import Services, OccupantTypes
|
||||
from api_events.events.events.events_bind_modules import (
|
||||
|
|
@ -601,6 +617,7 @@ class BuildManagement(CrudCollection):
|
|||
|
||||
__tablename__ = "build_management"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildManagementLanguageModel
|
||||
|
||||
discounted_percentage: Mapped[float] = mapped_column(
|
||||
Numeric(6, 2), server_default="0.00"
|
||||
|
|
@ -655,6 +672,7 @@ class BuildArea(CrudCollection):
|
|||
|
||||
__tablename__ = "build_area"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildAreaLanguageModel
|
||||
|
||||
area_name: Mapped[str] = mapped_column(String, server_default="")
|
||||
area_code: Mapped[str] = mapped_column(String, server_default="")
|
||||
|
|
@ -690,6 +708,7 @@ class BuildSites(CrudCollection):
|
|||
|
||||
__tablename__ = "build_sites"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildSitesLanguageModel
|
||||
__include__fields__ = []
|
||||
|
||||
site_name: Mapped[str] = mapped_column(String(24), nullable=False)
|
||||
|
|
@ -716,6 +735,7 @@ class BuildCompaniesProviding(CrudCollection):
|
|||
|
||||
__tablename__ = "build_companies_providing"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildCompaniesProvidingLanguageModel
|
||||
__include__fields__ = []
|
||||
|
||||
build_id = mapped_column(
|
||||
|
|
@ -755,6 +775,7 @@ class BuildPersonProviding(CrudCollection):
|
|||
|
||||
__tablename__ = "build_person_providing"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = BuildPersonProvidingLanguageModel
|
||||
__include__fields__ = []
|
||||
|
||||
build_id = mapped_column(
|
||||
|
|
@ -787,75 +808,3 @@ class BuildPersonProviding(CrudCollection):
|
|||
),
|
||||
{"comment": "People providing services for building"},
|
||||
)
|
||||
|
||||
|
||||
# owner_people: Mapped["People"] = relationship(
|
||||
# "People",
|
||||
# back_populates="owner_buildings",
|
||||
# foreign_keys=[current_owner_person_id],
|
||||
# )
|
||||
# tenant_people: Mapped["People"] = relationship(
|
||||
# "People",
|
||||
# back_populates="tenant_buildings",
|
||||
# foreign_keys=[current_tenant_person_id],
|
||||
# )
|
||||
# decision_book_management: Mapped[List["BuildDecisionBookManagement"]] = (
|
||||
# relationship(
|
||||
# "BuildDecisionBookManagement",
|
||||
# back_populates="buildings",
|
||||
# foreign_keys="BuildDecisionBookManagement.build_parts_id",
|
||||
# )
|
||||
# )
|
||||
# budget_records: Mapped[List["CompanyBudgetRecords"]] = relationship(
|
||||
# "CompanyBudgetRecords",
|
||||
# back_populates="parts",
|
||||
# foreign_keys="CompanyBudgetRecords.build_parts_id",
|
||||
# )
|
||||
# living_spaces: Mapped[List["BuildLivingSpace"]] = relationship(
|
||||
# "BuildLivingSpace",
|
||||
# back_populates="parts",
|
||||
# foreign_keys="BuildLivingSpace.build_parts_id",
|
||||
# )
|
||||
# decision_book_payment_master: Mapped[List["BuildDecisionBookPaymentsMaster"]] = (
|
||||
# relationship(
|
||||
# "BuildDecisionBookPaymentsMaster",
|
||||
# back_populates="parts",
|
||||
# foreign_keys="BuildDecisionBookPaymentsMaster.build_parts_id",
|
||||
# )
|
||||
# )
|
||||
# decision_book_project_payments_master: Mapped[
|
||||
# "BuildDecisionBookProjectPaymentsMaster"
|
||||
# ] = relationship(
|
||||
# "BuildDecisionBookProjectPaymentsMaster",
|
||||
# back_populates="parts",
|
||||
# foreign_keys="BuildDecisionBookProjectPaymentsMaster.build_parts_id",
|
||||
# )
|
||||
# search_iban_description: Mapped["BuildIbanDescription"] = relationship(
|
||||
# "BuildIbanDescription",
|
||||
# back_populates="parts",
|
||||
# foreign_keys="BuildIbanDescription.build_parts_id",
|
||||
# )
|
||||
|
||||
# parts: Mapped[List["BuildParts"]] = relationship(
|
||||
# "BuildParts", back_populates="living_spaces", foreign_keys=[build_parts_id]
|
||||
# )
|
||||
# owner_people: Mapped["People"] = relationship(
|
||||
# "People", back_populates="owner_living_spaces", foreign_keys=[owner_person_id]
|
||||
# )
|
||||
# life_people: Mapped["People"] = relationship(
|
||||
# "People", back_populates="life_living_spaces", foreign_keys=[life_person_id]
|
||||
# )
|
||||
# company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
||||
# response_company_id: Mapped[int] = mapped_column(ForeignKey("companies.id"))
|
||||
# person_id: Mapped[int] = mapped_column(ForeignKey("people.id"))
|
||||
|
||||
# companies: Mapped["Companies"] = relationship(
|
||||
# "Companies", back_populates="buildings", foreign_keys=[company_id]
|
||||
# )
|
||||
# @classmethod
|
||||
# def select_action(cls, duty_id, token=None):
|
||||
# from database_sql_models import Companies
|
||||
#
|
||||
# related_companies = Companies.select_action(duty_id=duty_id)
|
||||
# companies_ids = [company.id for company in related_companies.all()]
|
||||
# return cls.filter_all(cls.company_id.in_(companies_ids)).query
|
||||
|
|
|
|||
|
|
@ -977,7 +977,7 @@ class BuildDecisionBookLegal(CrudCollection):
|
|||
contact_agreement_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP(timezone=True), server_default="1900-01-01 00:00:00", nullable=True
|
||||
)
|
||||
meeting_date: Mapped[str] = mapped_column(
|
||||
meeting_date: Mapped[TIMESTAMP] = mapped_column(
|
||||
TIMESTAMP(timezone=True), server_default="1900-01-01 00:00:00"
|
||||
)
|
||||
lawsuits_type: Mapped[str] = mapped_column(String(1), server_default="C")
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ from fastapi.exceptions import HTTPException
|
|||
|
||||
from databases.sql_models.core_mixin import CrudCollection
|
||||
|
||||
from sqlalchemy import String, Integer, Boolean, ForeignKey, Index, Identity
|
||||
from sqlalchemy.orm import mapped_column, Mapped
|
||||
from sqlalchemy import String, Integer, Boolean, ForeignKey, Index, Identity, TIMESTAMP, func
|
||||
from sqlalchemy.orm import mapped_column, relationship, Mapped
|
||||
|
||||
from api_configs import RelationAccess
|
||||
from databases.extensions import SelectAction
|
||||
|
|
@ -13,6 +13,11 @@ from api_validations.validations_request import (
|
|||
MatchCompany2Company,
|
||||
)
|
||||
from api_objects.auth.token_objects import EmployeeTokenObject
|
||||
from databases.language_models.company.company import (
|
||||
RelationshipDutyCompanyLanguageModel,
|
||||
CompaniesLanguageModel,
|
||||
# CompanyDutiesLanguageModel,
|
||||
)
|
||||
|
||||
|
||||
class RelationshipDutyCompany(CrudCollection):
|
||||
|
|
@ -31,6 +36,7 @@ class RelationshipDutyCompany(CrudCollection):
|
|||
__tablename__ = "relationship_duty_company"
|
||||
__exclude__fields__ = []
|
||||
__access_by__ = RelationAccess.SuperAccessList
|
||||
__language_model__ = RelationshipDutyCompanyLanguageModel
|
||||
|
||||
owner_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("companies.id"), nullable=False
|
||||
|
|
@ -184,6 +190,7 @@ class Companies(CrudCollection, SelectAction):
|
|||
__exclude__fields__ = ["is_blacklist", "is_commercial"]
|
||||
__access_by__ = []
|
||||
__many__table__ = RelationshipDutyCompany
|
||||
__language_model__ = CompaniesLanguageModel
|
||||
# __explain__ = AbstractCompany()
|
||||
|
||||
formal_name: Mapped[str] = mapped_column(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,15 @@
|
|||
from databases.sql_models.core_mixin import CrudCollection
|
||||
from databases.language_models.event.event import (
|
||||
EventsLanguageModel,
|
||||
ModulesLanguageModel,
|
||||
ServicesLanguageModel,
|
||||
Service2EventsLanguageModel,
|
||||
Event2OccupantExtraLanguageModel,
|
||||
Event2EmployeeExtraLanguageModel,
|
||||
Event2EmployeeLanguageModel,
|
||||
Event2OccupantLanguageModel,
|
||||
ModulePriceLanguageModel,
|
||||
)
|
||||
|
||||
from sqlalchemy import (
|
||||
String,
|
||||
|
|
@ -20,6 +31,7 @@ class Events(CrudCollection):
|
|||
|
||||
__tablename__ = "events"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = EventsLanguageModel
|
||||
|
||||
event_type: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Event Type"
|
||||
|
|
@ -58,6 +70,7 @@ class Modules(CrudCollection):
|
|||
|
||||
__tablename__ = "modules"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = ModulesLanguageModel
|
||||
|
||||
module_name: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Module Name"
|
||||
|
|
@ -92,6 +105,7 @@ class Services(CrudCollection):
|
|||
|
||||
__tablename__ = "services"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = ServicesLanguageModel
|
||||
|
||||
module_id: Mapped[int] = mapped_column(ForeignKey("modules.id"), nullable=False)
|
||||
module_uu_id: Mapped[str] = mapped_column(
|
||||
|
|
@ -137,6 +151,7 @@ class Service2Events(CrudCollection):
|
|||
|
||||
__tablename__ = "services2events"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = Service2EventsLanguageModel
|
||||
|
||||
service_id: Mapped[int] = mapped_column(ForeignKey("services.id"), nullable=False)
|
||||
service_uu_id = mapped_column(String, nullable=False, comment="Service UUID")
|
||||
|
|
@ -150,6 +165,7 @@ class Event2OccupantExtra(CrudCollection):
|
|||
|
||||
__tablename__ = "event2occupant_extra"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = Event2OccupantExtraLanguageModel
|
||||
|
||||
build_living_space_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("build_living_space.id"), nullable=False
|
||||
|
|
@ -180,6 +196,7 @@ class Event2EmployeeExtra(CrudCollection):
|
|||
|
||||
__tablename__ = "event2employee_extra"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = Event2EmployeeExtraLanguageModel
|
||||
|
||||
employee_id: Mapped[int] = mapped_column(ForeignKey("employees.id"), nullable=False)
|
||||
employee_uu_id: Mapped[str] = mapped_column(
|
||||
|
|
@ -209,6 +226,7 @@ class Event2Employee(CrudCollection):
|
|||
|
||||
__tablename__ = "event2employee"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = Event2EmployeeLanguageModel
|
||||
|
||||
employee_id: Mapped[int] = mapped_column(ForeignKey("employees.id"), nullable=False)
|
||||
employee_uu_id: Mapped[str] = mapped_column(
|
||||
|
|
@ -257,6 +275,7 @@ class Event2Occupant(CrudCollection):
|
|||
|
||||
__tablename__ = "event2occupant"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = Event2OccupantLanguageModel
|
||||
|
||||
build_living_space_id: Mapped[str] = mapped_column(
|
||||
ForeignKey("build_living_space.id"), nullable=False
|
||||
|
|
@ -309,6 +328,7 @@ class ModulePrice(CrudCollection):
|
|||
|
||||
__tablename__ = "module_price"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = ModulePriceLanguageModel
|
||||
|
||||
campaign_code: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Campaign Code"
|
||||
|
|
@ -336,73 +356,3 @@ class ModulePrice(CrudCollection):
|
|||
) # 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
|
||||
# discounted_price - calculated_price = Pazarlamaya gider yazılır 3 TL
|
||||
# """
|
||||
#
|
||||
# __tablename__ = "modules2_occupant"
|
||||
#
|
||||
#
|
||||
# discounted_percentage: Mapped[float] = mapped_column(Numeric(6, 2), server_default="0.00") # %22
|
||||
# discounted_price = mapped_column(
|
||||
# Numeric(20, 2), server_default="0.00"
|
||||
# ) # Normal: 78.00 TL
|
||||
# calculated_price = mapped_column(
|
||||
# Numeric(20, 2), server_default="0.00"
|
||||
# ) # sana düz 75.00 TL yapar
|
||||
#
|
||||
# service_id = mapped_column(ForeignKey("services.id"), nullable=False)
|
||||
# build_living_space_id = mapped_column(
|
||||
# ForeignKey("build_living_space.id"), nullable=False, index=True
|
||||
# )
|
||||
#
|
||||
# __table_args__ = ({"comment": "ModulesOccupantPrices Information"},)
|
||||
#
|
||||
#
|
||||
# class Modules2Employee(CrudCollection):
|
||||
# """
|
||||
# Modules2EmployeeServices class based on declarative_base and BaseMixin via session
|
||||
# """
|
||||
#
|
||||
# __tablename__ = "modules2_employee"
|
||||
#
|
||||
# discounted_percentage: Mapped[float] = mapped_column(Numeric(6, 2), server_default="0.00") # %22
|
||||
# discounted_price = mapped_column(
|
||||
# Numeric(20, 2), server_default="0.00"
|
||||
# ) # Normal: 78.00 TL
|
||||
# calculated_price = mapped_column(
|
||||
# Numeric(20, 2), server_default="0.00"
|
||||
# ) # sana düz 75.00 TL yapar
|
||||
#
|
||||
# service_id = mapped_column(ForeignKey("services.id"), nullable=False)
|
||||
# employee_id = mapped_column(ForeignKey("employees.id"), nullable=False)
|
||||
#
|
||||
# __table_args__ = ({"comment": "Modules2EmployeeServices Information"},)
|
||||
# class Actions(CrudCollection):
|
||||
# """
|
||||
# Actions class based on declarative_base and BaseMixin via session
|
||||
# """
|
||||
#
|
||||
# __tablename__ = "actions"
|
||||
# __exclude__fields__ = []
|
||||
#
|
||||
# action_table = mapped_column(String, nullable=False, comment="Action Table")
|
||||
# action_type = mapped_column(String, nullable=False, comment="Action Type")
|
||||
# action_description = mapped_column(String, server_default="")
|
||||
# action_code = mapped_column(String, nullable=False, comment="Action Code")
|
||||
# endpoint_id = mapped_column(ForeignKey("endpoint_restriction.id"), nullable=True)
|
||||
# endpoint_uu_id = mapped_column(String, nullable=True, comment="Endpoint UUID")
|
||||
#
|
||||
# @property
|
||||
# def action_name(self):
|
||||
# return f"{self.action_table} {self.action_type}"
|
||||
#
|
||||
# @property
|
||||
# def total_cost(self):
|
||||
# return self.cost * self.unit_price
|
||||
#
|
||||
# __table_args__ = ({"comment": "Actions Information"},)
|
||||
|
|
|
|||
|
|
@ -1,35 +1,54 @@
|
|||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
from api_configs import Auth, ApiStatic, RelationAccess
|
||||
|
||||
from datetime import timedelta
|
||||
from typing import Optional, List
|
||||
|
||||
from fastapi import HTTPException
|
||||
|
||||
from databases.sql_models.core_mixin import CrudCollection
|
||||
from databases.extensions import SelectAction, SelectActionWithEmployee
|
||||
from databases.extensions.auth import UserLoginModule
|
||||
|
||||
from sqlalchemy import (
|
||||
String,
|
||||
Boolean,
|
||||
TIMESTAMP,
|
||||
ForeignKey,
|
||||
func,
|
||||
Numeric,
|
||||
Index,
|
||||
BigInteger,
|
||||
Integer,
|
||||
Boolean,
|
||||
ForeignKey,
|
||||
Index,
|
||||
TIMESTAMP,
|
||||
func,
|
||||
Text,
|
||||
BigInteger,
|
||||
Numeric,
|
||||
or_,
|
||||
)
|
||||
from sqlalchemy.orm import mapped_column, relationship, Mapped
|
||||
|
||||
from api_library.date_time_actions.date_functions import system_arrow
|
||||
from api_configs import Auth, ApiStatic, RelationAccess
|
||||
from databases.sql_models.core_mixin import CrudCollection
|
||||
from databases.extensions import SelectAction, SelectActionWithEmployee
|
||||
from databases.extensions.auth import UserLoginModule
|
||||
from api_validations.validations_request import InsertUsers, InsertPerson
|
||||
from databases.language_models.identity.identity import (
|
||||
UsersTokensLanguageModel,
|
||||
UsersLanguageModel,
|
||||
PeopleLanguageModel,
|
||||
RelationshipDutyPeopleLanguageModel,
|
||||
RelationshipEmployee2PostCodeLanguageModel,
|
||||
AddressPostcodeLanguageModel,
|
||||
AddressesLanguageModel,
|
||||
AddressGeographicLocationsLanguageModel,
|
||||
AddressCountryLanguageModel,
|
||||
AddressStateLanguageModel,
|
||||
AddressCityLanguageModel,
|
||||
AddressDistrictLanguageModel,
|
||||
AddressLocalityLanguageModel,
|
||||
AddressNeighborhoodLanguageModel,
|
||||
AddressStreetLanguageModel,
|
||||
OccupantTypesLanguageModel,
|
||||
ContractsLanguageModel,
|
||||
)
|
||||
|
||||
|
||||
class UsersTokens(CrudCollection):
|
||||
|
||||
__tablename__ = "users_tokens"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = UsersTokensLanguageModel
|
||||
|
||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), nullable=False)
|
||||
|
||||
|
|
@ -56,6 +75,7 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
|
|||
"expiry_begins",
|
||||
"related_company",
|
||||
]
|
||||
__language_model__ = UsersLanguageModel
|
||||
|
||||
user_tag: Mapped[str] = mapped_column(
|
||||
String(64), server_default="", comment="Unique tag for the user", index=True
|
||||
|
|
@ -85,10 +105,10 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
|
|||
Boolean, server_default="0", comment="Flag to remember user login"
|
||||
)
|
||||
|
||||
password_expires_day: Mapped[str] = mapped_column(
|
||||
password_expires_day: Mapped[int] = mapped_column(
|
||||
"expires_day",
|
||||
String,
|
||||
server_default=str(Auth.PASSWORD_EXPIRE_DAY),
|
||||
Integer,
|
||||
server_default=str(Auth.PASSWORD_EXPIRE_DAY.days),
|
||||
comment="Password expires in days",
|
||||
)
|
||||
password_expiry_begins: Mapped[TIMESTAMP] = mapped_column(
|
||||
|
|
@ -233,6 +253,7 @@ class RelationshipDutyPeople(CrudCollection):
|
|||
__tablename__ = "relationship_duty_people"
|
||||
__exclude__fields__ = []
|
||||
__access_by__ = RelationAccess.SuperAccessList
|
||||
__language_model__ = RelationshipDutyPeopleLanguageModel
|
||||
|
||||
company_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("companies.id"), nullable=False
|
||||
|
|
@ -285,6 +306,7 @@ class People(CrudCollection, SelectAction):
|
|||
"birth_date",
|
||||
"tax_no",
|
||||
]
|
||||
__language_model__ = PeopleLanguageModel
|
||||
|
||||
firstname: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="First name of the person"
|
||||
|
|
@ -395,6 +417,7 @@ class RelationshipEmployee2PostCode(CrudCollection):
|
|||
__tablename__ = "relationship_employee2postcode"
|
||||
__exclude__fields__ = []
|
||||
__include__fields__ = []
|
||||
__language_model__ = RelationshipEmployee2PostCodeLanguageModel
|
||||
|
||||
company_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("companies.id"), nullable=True
|
||||
|
|
@ -421,6 +444,7 @@ class AddressPostcode(CrudCollection, SelectActionWithEmployee):
|
|||
__exclude__fields__ = []
|
||||
__access_by__ = []
|
||||
__many__table__ = RelationshipEmployee2PostCode
|
||||
__language_model__ = AddressPostcodeLanguageModel
|
||||
|
||||
street_id: Mapped[int] = mapped_column(ForeignKey("address_street.id"))
|
||||
street_uu_id: Mapped[str] = mapped_column(
|
||||
|
|
@ -440,6 +464,7 @@ class Addresses(CrudCollection):
|
|||
|
||||
__tablename__ = "addresses"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = AddressesLanguageModel
|
||||
|
||||
build_number: Mapped[str] = mapped_column(
|
||||
String(24), nullable=False, comment="Build Number"
|
||||
|
|
@ -537,6 +562,7 @@ class AddressGeographicLocations(CrudCollection):
|
|||
|
||||
__tablename__ = "address_geographic_locations"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = AddressGeographicLocationsLanguageModel
|
||||
|
||||
geo_table: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Address Table Name"
|
||||
|
|
@ -588,6 +614,7 @@ class AddressCountry(CrudCollection):
|
|||
|
||||
__tablename__ = "address_country"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = AddressCountryLanguageModel
|
||||
|
||||
country_code: Mapped[str] = mapped_column(
|
||||
String(16), nullable=False, comment="Country Code"
|
||||
|
|
@ -619,6 +646,7 @@ class AddressState(CrudCollection):
|
|||
|
||||
__tablename__ = "address_state"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = AddressStateLanguageModel
|
||||
|
||||
state_code: Mapped[str] = mapped_column(
|
||||
String(16), nullable=False, comment="State Code"
|
||||
|
|
@ -662,6 +690,7 @@ class AddressCity(CrudCollection):
|
|||
|
||||
__tablename__ = "address_city"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = AddressCityLanguageModel
|
||||
|
||||
city_code: Mapped[str] = mapped_column(
|
||||
String(24), nullable=False, comment="City Code"
|
||||
|
|
@ -703,6 +732,7 @@ class AddressDistrict(CrudCollection):
|
|||
|
||||
__tablename__ = "address_district"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = AddressDistrictLanguageModel
|
||||
|
||||
district_code: Mapped[str] = mapped_column(
|
||||
String(16), nullable=False, comment="District Code"
|
||||
|
|
@ -745,6 +775,7 @@ class AddressLocality(CrudCollection):
|
|||
|
||||
__tablename__ = "address_locality"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = AddressLocalityLanguageModel
|
||||
|
||||
locality_code: Mapped[str] = mapped_column(
|
||||
String(16), nullable=False, comment="Locality Code"
|
||||
|
|
@ -789,6 +820,7 @@ class AddressNeighborhood(CrudCollection):
|
|||
|
||||
__tablename__ = "address_neighborhood"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = AddressNeighborhoodLanguageModel
|
||||
|
||||
neighborhood_code: Mapped[str] = mapped_column(
|
||||
String(16), nullable=False, comment="Neighborhood Code"
|
||||
|
|
@ -839,6 +871,7 @@ class AddressStreet(CrudCollection):
|
|||
|
||||
__tablename__ = "address_street"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = AddressStreetLanguageModel
|
||||
|
||||
street_code: Mapped[str] = mapped_column(
|
||||
String(16), nullable=False, comment="Street Code"
|
||||
|
|
@ -940,6 +973,7 @@ class OccupantTypes(CrudCollection):
|
|||
|
||||
__tablename__ = "occupant_types"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = OccupantTypesLanguageModel
|
||||
|
||||
occupant_type: Mapped[str] = mapped_column(
|
||||
String, nullable=False, comment="Occupant Type"
|
||||
|
|
@ -971,6 +1005,7 @@ class Contracts(CrudCollection):
|
|||
|
||||
__tablename__ = "contracts"
|
||||
__exclude__fields__ = []
|
||||
__language_model__ = ContractsLanguageModel
|
||||
|
||||
contract_type: Mapped[str] = mapped_column(
|
||||
String(5),
|
||||
|
|
@ -1021,49 +1056,3 @@ class Contracts(CrudCollection):
|
|||
Index("_contract_ndx_01", contract_code, unique=True),
|
||||
{"comment": "Contract Information"},
|
||||
)
|
||||
|
||||
|
||||
# def selected_employee_and_duty_details(self, selected_duty_uu_id):
|
||||
# from database_sql_models import (
|
||||
# Companies,
|
||||
# Employees,
|
||||
# Duties,
|
||||
# Departments,
|
||||
# )
|
||||
#
|
||||
# found_person = People.find_one(id=self.person_id)
|
||||
# found_employee = Employees.find_one(
|
||||
# people_id=found_person.id, is_confirmed=True
|
||||
# )
|
||||
# found_duty = Duties.find_one(uu_id=selected_duty_uu_id)
|
||||
# found_department = Departments.find_one(id=found_duty.department_id)
|
||||
# found_company = Companies.find_one(id=found_department.company_id)
|
||||
# return {
|
||||
# "duty_list": {
|
||||
# "duty_id": found_duty.id,
|
||||
# "duty_uu_id": found_duty.uu_id.__str__(),
|
||||
# "duty_code": found_duty.duty_code,
|
||||
# "duty_name": found_duty.duty_name,
|
||||
# "duty_description": found_duty.duty_description,
|
||||
# },
|
||||
# "employee_list": {
|
||||
# "employee_id": found_employee.id,
|
||||
# "employee_uu_id": found_employee.uu_id.__str__(),
|
||||
# "people_id": found_employee.people_id,
|
||||
# "duty_id": found_employee.duty_id,
|
||||
# "employee_description": found_employee.employee_description,
|
||||
# },
|
||||
# "department_list": {
|
||||
# "department_id": found_department.id,
|
||||
# "department_uu_id": found_department.uu_id.__str__(),
|
||||
# "company_id": found_department.company_id,
|
||||
# "department_name": found_department.department_name,
|
||||
# "department_description": found_department.department_description,
|
||||
# },
|
||||
# "companies_list": {
|
||||
# "company_id": found_company.id,
|
||||
# "company_uu_id": found_company.uu_id.__str__(),
|
||||
# "formal_name": found_company.formal_name,
|
||||
# "company_tag": found_company.company_tag,
|
||||
# },
|
||||
# }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "Stopping existing containers..."
|
||||
docker compose -f api-docker-compose.yml down
|
||||
|
||||
echo "Building and starting auth service..."
|
||||
docker compose -f api-docker-compose.yml up --build wag_management_auth_service
|
||||
Loading…
Reference in New Issue