Agregar Cotización Web (UDO) para cliente Aberio
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f58f4292c3
commit
cdd4ffaff8
20 files changed
+1277
-17
No files matched your search
@@ -106,8 +106,10 @@ def make_crud_router(
|
||||
endpoint_path=resource,
|
||||
json_data=data,
|
||||
)
|
||||
created = resp.json()
|
||||
return {key_field: created[key_field]}
|
||||
# Se devuelve la respuesta completa de SAP (no solo key_field):
|
||||
# documentos tipo UDO necesitan, por ejemplo, el DocNum recién
|
||||
# asignado para mostrarlo en el frontend sin otra llamada.
|
||||
return resp.json()
|
||||
|
||||
if supports_patch:
|
||||
@router.patch(f"/api/{resource}/{{key}}", status_code=204, name=f"update_{resource}")
|
||||
|
||||
@@ -25,6 +25,7 @@ from routers.reports import router as reports_router
|
||||
from routers.series import router as series_router
|
||||
from routers.user_tables import router as user_tables_router
|
||||
from routers.inventory_transfer_requests import router as inventory_transfer_requests_router
|
||||
from routers.cotizacion_web import router as cotizacion_web_router
|
||||
|
||||
# ============================================================================
|
||||
load_dotenv(dotenv_path=".env")
|
||||
@@ -60,6 +61,7 @@ app.include_router(reports_router)
|
||||
app.include_router(series_router)
|
||||
app.include_router(user_tables_router)
|
||||
app.include_router(inventory_transfer_requests_router)
|
||||
app.include_router(cotizacion_web_router)
|
||||
|
||||
# ============================================================================
|
||||
@app.middleware("http")
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
"admin.demo@empresa.com": [
|
||||
"*"
|
||||
],
|
||||
"george": [
|
||||
"*"
|
||||
],
|
||||
"ventas.demo@empresa.com": [
|
||||
"/ventas/*",
|
||||
"/socios/clientes"
|
||||
|
||||
@@ -101,6 +101,49 @@ async def get_udf_valid_values(table_name: str, field_name: str):
|
||||
}
|
||||
|
||||
|
||||
@router.get("/api/PriceLists")
|
||||
async def get_price_lists():
|
||||
"""
|
||||
Listas de precio de SAP, normalizadas a {Code, Name} (PriceListNo /
|
||||
PriceListName) para poder reusar el hook useSapCatalog del frontend
|
||||
igual que con las tablas de usuario y los UDF.
|
||||
"""
|
||||
sap_params = {
|
||||
"$select": "PriceListNo,PriceListName",
|
||||
"$top": 200,
|
||||
}
|
||||
|
||||
response = forward_to_sapb1(
|
||||
method="GET",
|
||||
endpoint_path="PriceLists",
|
||||
params=sap_params,
|
||||
).json()
|
||||
|
||||
return {
|
||||
"value": [
|
||||
{"Code": pl["PriceListNo"], "Name": pl["PriceListName"]}
|
||||
for pl in response.get("value", [])
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@router.get("/api/CompanyService/DefaultWarehouse")
|
||||
async def get_default_warehouse():
|
||||
"""
|
||||
Almacén por defecto de la compañía (CompanyService_GetAdminInfo es un
|
||||
FunctionImport de Service Layer que, pese al nombre "Get", solo se
|
||||
invoca por POST). Se normaliza a un único campo para que el frontend no
|
||||
tenga que conocer el resto de AdminInfo.
|
||||
"""
|
||||
response = forward_to_sapb1(
|
||||
method="POST",
|
||||
endpoint_path="CompanyService_GetAdminInfo",
|
||||
json_data={},
|
||||
).json()
|
||||
|
||||
return {"DefaultWarehouse": response.get("DefaultWarehouse")}
|
||||
|
||||
|
||||
@router.get("/api/ItemGroups")
|
||||
async def get_item_groups():
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
from core.crud_router import make_crud_router
|
||||
|
||||
# CRUD genérico del objeto de usuario (UDO) "CotizacionWEB": documento propio
|
||||
# (cabecera @OQUT + detalle @UQT1) con la misma forma que cualquier
|
||||
# documento estándar de SAP expuesto por Service Layer (StockTransferLines,
|
||||
# DocumentLines, etc. son el mismo patrón): un array anidado, acá llamado
|
||||
# "QUT1Collection". El backend no transforma nada, el frontend arma el JSON
|
||||
# completo (campos U_* de la cabecera + QUT1Collection) y lo manda tal cual.
|
||||
router = make_crud_router(
|
||||
"CotizacionWEB",
|
||||
tags=["Cotización Web"],
|
||||
key_field="DocEntry",
|
||||
supports_orderby=True,
|
||||
)
|
||||
Reference in new issue
Block a user