20 lines
719 B
Python
20 lines
719 B
Python
|
from .helpers import grab_data
|
||
|
from core.registry import office_storage
|
||
|
from core.models.office.responses import JdeOfficeDetailResponse
|
||
|
from ...models.office.requests import UpdateOfficeRequest
|
||
|
|
||
|
|
||
|
async def list_offices_service() -> list[JdeOfficeDetailResponse]:
|
||
|
offices = await grab_data()
|
||
|
offices.sort(key=lambda x: x.code)
|
||
|
offices_additional_data = {data.code: data for data in office_storage.list_all_offices()}
|
||
|
response_data = [
|
||
|
JdeOfficeDetailResponse(**office.model_dump(), changeable_info=None or offices_additional_data.get(office.code)) for office in offices
|
||
|
]
|
||
|
|
||
|
return response_data
|
||
|
|
||
|
|
||
|
async def update_office(data: UpdateOfficeRequest):
|
||
|
office_storage.update_office(data)
|