PedidoLocalCreateRequest: Dine-In Order Request Schema
Full schema reference for PedidoLocalCreateRequest — the Pydantic request model used to submit dine-in restaurant orders for DIAN electronic invoicing.
Use this file to discover all available pages before exploring further.
PedidoLocalCreateRequest is the Pydantic v2 model used as the request body for POST /api/v1/pedidos/consumo-local/. It captures all details of a restaurant’s dine-in order that are required to generate a DIAN-compliant electronic invoice, including line items with per-item tax breakdowns, buyer identification, payment methods, and pre-calculated totals that are validated against a strict business rule before the document is forwarded to DIAN via SOAP.
The following classes are defined in src/infrastructure/controllers/schemas/pedido_local_schema.py. They act as HTTP-layer DTOs that are kept intentionally separate from the domain entities so that REST-specific serialization concerns stay out of the core domain.
The unique order ID from the originating POS system. This is stored as id_pedido on the PedidoLocal domain entity and is used to correlate the DIAN submission back to the source transaction.Example:"POS-100"
Customer identification block. If omitted entirely, FacturarPedidoLocalUseCase defaults to an Adquirente() instance representing Consumidor Final — the anonymous buyer code required by DIAN for retail transactions where the customer does not provide identification.
Array of line items in the order. Must contain at least one item (min_length=1). Each element fully describes one product including its individual tax breakdown.
Pre-calculated monetary tax amount for this line item, in COP. The API does not recalculate this value — it trusts the POS to send a correct pre-computed amount.Example:1600.0 (= 2 × 10000 × 0.08)
Voluntary tip amount. Per Colombian tax regulation, tips are not part of the taxable base and are excluded from tax calculations. The use case validates that total_factura = subtotal + impuestos_totales + propina_voluntaria.Example:3000.0
Grand total of the invoice. Business rule enforced by FacturarPedidoLocalUseCase: this value must exactly equal subtotal + impuestos_totales + propina_voluntaria. A mismatch raises a ValueError before any DIAN call is made.Example:24600.0 (= 20000 + 1600 + 3000)
Amount settled with this payment method, in COP.Example:24600.0
Decimal types are used for all monetary values to avoid floating-point precision issues in tax calculations. Always send monetary amounts as JSON numbers with up to two decimal places (e.g., 10000.00), not as strings.
FacturarPedidoLocalUseCase.execute() maps the incoming PedidoLocalCreateRequest DTO to the PedidoLocal domain entity before performing any business logic. This separation ensures that REST-layer concerns (Pydantic field aliases, HTTP examples, JSON serialization) never leak into the domain model.The mapping produces the following domain entity (defined in src/domain/entities/pedido_local.py):
from decimal import Decimalfrom typing import Listfrom pydantic import BaseModel, Fieldclass ConceptoImpuesto(BaseModel): nombre: str = Field(..., description="Nombre del impuesto, e.g., INC, IVA") tasa: Decimal = Field(..., description="Tasa del impuesto, e.g., 0.08 para 8%") monto: Decimal = Field(..., description="Valor calculado del impuesto")class ItemPedido(BaseModel): id_producto: str descripcion: str cantidad: int precio_unitario: Decimal impuestos: List[ConceptoImpuesto] = Field(default_factory=list) total_item: Decimalclass MetodoPago(BaseModel): tipo: str = Field(..., description="Efectivo, Tarjeta, Transferencia, etc") monto: Decimalclass Adquirente(BaseModel): tipo_documento: str = Field(default="13", description="Tipo de documento (13=CC, 31=NIT, etc.)") numero_documento: str = Field(default="222222222222", description="Número de identificación") razon_social: str = Field(default="Consumidor Final", description="Nombre o Razón social")class PedidoLocal(BaseModel): id_pedido: str adquirente: Adquirente = Field(default_factory=Adquirente, description="Datos del cliente") items: List[ItemPedido] subtotal: Decimal propina_voluntaria: Decimal = Field( default=Decimal('0.00'), description="Propina, no hace parte de base gravable" ) impuestos_totales: Decimal total_factura: Decimal metodos_pago: List[MetodoPago] # Regla: puramente entidad de dominio, sin base de datos o lógica externa.
Notice the key field name difference: PedidoLocalCreateRequest.id_pedido_origen (the POS-originated ID) maps to PedidoLocal.id_pedido. All nested objects use domain-specific class names (ConceptoImpuesto instead of ImpuestoRequest, MetodoPago instead of PagoRequest) to keep the domain vocabulary clean and independent of HTTP concerns.