Automatic weight calculation based on material quantities and approximate weights
CEDIS Pedidos automatically calculates order weights based on requested quantities and predefined material weights, ensuring accurate tracking and enforcement of weight limits.
Each material in the system has weight-related properties:
export interface Material { id: string codigo: string | null nombre: string categoria: Categoria unidad_base: string peso_aproximado: number | null // Weight per unit in kg envase: string | null orden: number activo: boolean}
Empty containers (envase_vacio) are tracked by quantity only and don’t contribute to the total weight limit. This is intentional since they represent returned containers.
The system uses typed data structures for weight tracking:
export interface DetalleLinea { material: Material cantidad_kilos: number | null // Calculated weight cantidad_solicitada: number | null // User input peso_total: number | null // Same as cantidad_kilos for most items}export interface PedidoDetalle { id: string pedido_id: string material_id: string cantidad_kilos: number | null cantidad_solicitada: number | null peso_total: number | null lote: string | null peso: number | null material?: Material}
If a material’s peso_aproximado is null, it’s treated as 0, resulting in cantidad_kilos = 0 regardless of requested quantity. Materials should always have a valid approximate weight configured.
Can I manually override the calculated weight?
No, the weight calculation is automatic and cannot be manually overridden in the order creation interface. To change the weight, you must update the material’s peso_aproximado value in the materials catalog.
Why do empty containers have zero weight?
Empty containers represent materials being returned to the warehouse, not new materials being delivered. They don’t consume truck capacity in the same way, so they’re tracked by count only and excluded from the weight limit.
Is the weight limit enforced in the database?
The primary enforcement is in the UI, which disables the submit button when over the limit. However, additional database-level validation may exist through triggers or functions for defense-in-depth.
What precision is used for weight calculations?
JavaScript’s standard number precision is used for calculations. Weights are displayed with 2 decimal places using toLocaleString, but the full precision is stored in the database as numeric values.