Skip to main content

Overview

The Production Batch (LoteProduccion) model represents individual production runs of dairy products. Each batch tracks the product type, quantity, associated costs, and waste for a specific production cycle.

TypeScript Definition

interface ProductionBatch {
  idLote: string;
  numeroLote: number;
  fechaProduccion: Date;
  idProducto: string;
  producto?: Product;
  cantidad: number;
  unidad: 'kg' | 'litros';
  idEstablecimiento: string;
  estado: boolean;
  establecimiento?: Establishment;
  mermas?: Waste[];
  costosDirectos?: DirectCost[];
}

enum Unidad {
  kg = 'kg',
  litros = 'litros'
}

Fields

idLote
string
required
Unique identifier for the production batch. Auto-generated UUID.Database: Primary key, UUID format
numeroLote
integer
required
Sequential batch number for human-readable identification.Database: Auto-incrementUsage: Display on labels, reports, and tracking systemsExample: 1001, 1002, 1003
fechaProduccion
datetime
required
Date and time when the production batch was created.Default: Current timestampFormat: ISO 8601 datetime stringUsage: Traceability and expiration date calculations
idProducto
string
required
Foreign key reference to the product being produced.Database: Foreign key to Producto(idProducto)Relation: Many-to-One with Product
cantidad
decimal
required
Quantity of product produced in this batch.Type: Decimal number for precise measurementsUsage: Used with unidad field for complete quantity specificationExample: 250.50, 1000.00, 45.75
unidad
enum
required
Unit of measurement for the quantity.Enum Values:
  • kg - Kilograms (for solid products like cheese)
  • litros - Liters (for liquid products like milk)
Example: “kg” for cheese, “litros” for pasteurized milk
idEstablecimiento
string
required
Foreign key reference to the establishment where production occurred.Database: Foreign key to Establecimiento(idEstablecimiento)Relation: Many-to-One with Establishment
estado
boolean
required
Status of the production batch.Default: falseValues:
  • false - In progress or pending
  • true - Completed/finalized
Usage: Indicates whether the batch can still be modified

Relationships

Example Response

{
  "idLote": "b1c2d3e4-5678-90ab-cdef-1234567890ab",
  "numeroLote": 1001,
  "fechaProduccion": "2024-03-01T08:00:00.000Z",
  "idProducto": "p1q2r3s4-5678-90ab-cdef-1234567890ab",
  "producto": {
    "idProducto": "p1q2r3s4-5678-90ab-cdef-1234567890ab",
    "nombre": "Queso Mozzarella",
    "categoria": "quesos"
  },
  "cantidad": "250.50",
  "unidad": "kg",
  "idEstablecimiento": "e1f2g3h4-5678-90ab-cdef-1234567890ab",
  "estado": true,
  "establecimiento": {
    "idEstablecimiento": "e1f2g3h4-5678-90ab-cdef-1234567890ab",
    "nombre": "La Esperanza",
    "localidad": "Rafaela",
    "provincia": "Santa Fe"
  },
  "mermas": [
    {
      "idMerma": "m1n2o3p4-5678-90ab-cdef-1234567890ab",
      "tipo": "Natural",
      "cantidad": "5.25",
      "observacion": "Evaporación durante proceso",
      "fechaCreacion": "2024-03-01T12:30:00.000Z"
    }
  ],
  "costosDirectos": [
    {
      "idCostoDirecto": "c1d2e3f4-5678-90ab-cdef-1234567890ab",
      "concepto": "leche_cruda",
      "monto": "15000.00",
      "observaciones": "500 litros a $30/litro",
      "fechaCreacion": "2024-03-01T08:15:00.000Z"
    },
    {
      "idCostoDirecto": "c2d3e4f5-5678-90ab-cdef-1234567890ab",
      "concepto": "cuajo_y_fermentos",
      "monto": "2500.00",
      "observaciones": "Cuajo líquido y fermentos",
      "fechaCreacion": "2024-03-01T08:20:00.000Z"
    }
  ]
}

Example: Minimal Response

{
  "idLote": "b1c2d3e4-5678-90ab-cdef-1234567890ab",
  "numeroLote": 1001,
  "fechaProduccion": "2024-03-01T08:00:00.000Z",
  "idProducto": "p1q2r3s4-5678-90ab-cdef-1234567890ab",
  "cantidad": "250.50",
  "unidad": "kg",
  "idEstablecimiento": "e1f2g3h4-5678-90ab-cdef-1234567890ab",
  "estado": true
}

Usage Notes

Batch Status Workflow

  1. Batch created with estado: false (in progress)
  2. Costs and waste are added during production
  3. Once finalized, estado is set to true
  4. Finalized batches should be immutable for audit purposes

Traceability

  • numeroLote provides human-readable batch identification
  • fechaProduccion enables chronological tracking
  • Links to establishment for location traceability
  • Links to product for product-specific tracking

Cost Analysis

  • Direct costs tracked via costosDirectos relationship
  • Waste/losses tracked via mermas relationship
  • Combined data enables accurate profitability calculations
  • Per-unit cost can be calculated from total costs and quantity

Unit Selection

  • Use kg for solid products (cheeses, butter)
  • Use litros for liquid products (milk, cream)
  • Ensures consistent measurement across production

Build docs developers (and LLMs) love