Skip to main content

Overview

The Direct Cost (CostosDirecto) model tracks all direct expenses associated with producing a specific batch. Each cost record captures a specific expense concept, amount, and optional notes.

TypeScript Definition

interface DirectCost {
  idCostoDirecto: string;
  concepto: 'insumos_basicos' | 'leche_cruda' | 'cuajo_y_fermentos' | 'refrigeracion';
  monto: number;
  observaciones: string | null;
  fechaCreacion: Date;
  idLote: string;
  lote?: ProductionBatch;
}

enum ConceptoCosto {
  insumos_basicos = 'insumos_basicos',
  leche_cruda = 'leche_cruda',
  cuajo_y_fermentos = 'cuajo_y_fermentos',
  refrigeracion = 'refrigeracion'
}

Fields

idCostoDirecto
string
required
Unique identifier for the cost record. Auto-generated UUID.Database: Primary key, UUID format
concepto
enum
required
Cost concept or category.Enum Values:
  • insumos_basicos - Basic supplies (salt, packaging, labels, etc.)
  • leche_cruda - Raw milk
  • cuajo_y_fermentos - Rennet and starter cultures
  • refrigeracion - Refrigeration and energy costs
Usage: Enables cost breakdown analysis by category
monto
decimal
required
Cost amount in the specified currency.Type: Decimal(13,2) - up to 13 digits with 2 decimal placesFormat: Stored as decimal, no currency symbolExample: 15000.00, 2500.50, 850.25Note: Currency type should be tracked at the establishment or system level
observaciones
string | null
Optional notes or details about the cost.Default: Empty string ("")Nullable: Can be null or emptyUsage: Provides context for the expense (quantities, rates, suppliers, etc.)Examples:
  • “500 litros a $30/litro”
  • “Cuajo líquido - Proveedor XYZ”
  • “Consumo eléctrico cámara de frío - 48 horas”
fechaCreacion
datetime
required
Timestamp when the cost record was created.Default: Current timestampFormat: ISO 8601 datetime stringUsage: Tracks when expenses were recorded
idLote
string
required
Foreign key reference to the production batch this cost applies to.Database: Foreign key to LoteProduccion(idLote)Relation: Many-to-One with ProductionBatch

Relationships

Example Response

{
  "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",
  "idLote": "b1c2d3e4-5678-90ab-cdef-1234567890ab",
  "lote": {
    "idLote": "b1c2d3e4-5678-90ab-cdef-1234567890ab",
    "numeroLote": 1001,
    "fechaProduccion": "2024-03-01T08:00:00.000Z",
    "cantidad": "250.50",
    "unidad": "kg",
    "producto": {
      "nombre": "Queso Mozzarella",
      "categoria": "quesos"
    }
  }
}

Example: Complete Cost Breakdown for a Batch

[
  {
    "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",
    "idLote": "b1c2d3e4-5678-90ab-cdef-1234567890ab"
  },
  {
    "idCostoDirecto": "c2d3e4f5-5678-90ab-cdef-1234567890ab",
    "concepto": "cuajo_y_fermentos",
    "monto": "2500.00",
    "observaciones": "Cuajo líquido y fermentos mesófilos",
    "fechaCreacion": "2024-03-01T08:20:00.000Z",
    "idLote": "b1c2d3e4-5678-90ab-cdef-1234567890ab"
  },
  {
    "idCostoDirecto": "c3d4e5f6-5678-90ab-cdef-1234567890ab",
    "concepto": "insumos_basicos",
    "monto": "1200.00",
    "observaciones": "Sal, calcio, envases y etiquetas",
    "fechaCreacion": "2024-03-01T09:00:00.000Z",
    "idLote": "b1c2d3e4-5678-90ab-cdef-1234567890ab"
  },
  {
    "idCostoDirecto": "c4d5e6f7-5678-90ab-cdef-1234567890ab",
    "concepto": "refrigeracion",
    "monto": "850.00",
    "observaciones": "Consumo eléctrico cámara de frío - 48 horas",
    "fechaCreacion": "2024-03-01T10:00:00.000Z",
    "idLote": "b1c2d3e4-5678-90ab-cdef-1234567890ab"
  }
]

Example: Minimal Response

{
  "idCostoDirecto": "c1d2e3f4-5678-90ab-cdef-1234567890ab",
  "concepto": "leche_cruda",
  "monto": "15000.00",
  "observaciones": "",
  "fechaCreacion": "2024-03-01T08:15:00.000Z",
  "idLote": "b1c2d3e4-5678-90ab-cdef-1234567890ab"
}

Cost Concepts Explained

Raw Milk (leche_cruda)

The primary raw material for all dairy production. Common Details to Track:
  • Volume purchased (liters)
  • Price per liter
  • Supplier information
  • Milk quality metrics (fat %, protein %)
  • Delivery date
Typical Range: Largest cost component (50-70% of total direct costs) Example Observations:
  • “500 litros a $30/litro - Proveedor La Pampa”
  • “750L @ $28/L - Calidad Premium (3.5% grasa)“

Rennet and Cultures (cuajo_y_fermentos)

Essential ingredients for cheese production. Includes:
  • Rennet (animal, vegetable, or microbial)
  • Starter cultures (mesophilic, thermophilic)
  • Mold cultures (for specialty cheeses)
  • Enzymes and coagulants
Typical Range: 5-15% of total direct costs Example Observations:
  • “Cuajo líquido 200ml - CHR Hansen”
  • “Fermento mesófilo 50g + cuajo microbiano”
  • “Cultivo Penicillium roqueforti para queso azul”

Basic Supplies (insumos_basicos)

Miscellaneous supplies and materials needed for production. Includes:
  • Salt and brine solutions
  • Calcium chloride
  • Citric acid
  • Packaging materials
  • Labels and stickers
  • Cleaning and sanitizing agents
  • Small tools and consumables
Typical Range: 5-10% of total direct costs Example Observations:
  • “Sal gruesa 25kg + cloruro de calcio 2kg”
  • “Envases plásticos x200 + etiquetas impresas”
  • “Material de empaque y sanitizantes”

Refrigeration (refrigeracion)

Energy costs for cooling and storage. Includes:
  • Electricity for cooling chambers
  • Freezer operation costs
  • Refrigerated storage during maturation
  • Cold chain maintenance
Typical Range: 10-20% of total direct costs Calculation Methods:
  • Metered electricity usage
  • Estimated based on hours of operation
  • Pro-rated from monthly utility bills
Example Observations:
  • “Cámara de frío 48 horas - 120 kWh @ $7/kWh”
  • “Refrigeración durante maduración - 7 días”
  • “Consumo eléctrico estimado - marzo 2024”

Usage Notes

Cost Tracking Workflow

  1. Production batch is created
  2. As expenses occur, cost records are added
  3. Each cost is categorized by concept
  4. Observations document details for audit trail
  5. Total batch costs calculated by summing all records
  6. Per-unit cost derived from total costs and quantity

Profitability Analysis

Total Direct Costs
Total = SUM(monto) for all costs in batch
Cost Per Unit
Cost per kg/liter = Total Direct Costs / Batch Quantity
Gross Margin
Gross Margin = (Selling Price - Cost per Unit) / Selling Price × 100%
Cost Breakdown by Concept
Concept % = (Concept Total / Total Direct Costs) × 100%

Multi-Currency Considerations

While the schema includes a Moneda enum (USD, EUR, ARS), the current cost model doesn’t explicitly store currency. Consider:
  • Standardizing all costs to a single currency
  • Adding a currency field if multi-currency support is needed
  • Converting historical costs when analyzing across time periods
  • Accounting for exchange rate fluctuations

Best Practices

Recording Costs:
  • Add costs as they occur during production
  • Include detailed observations for audit purposes
  • Use consistent units and calculation methods
  • Verify amounts before batch finalization
Cost Categories:
  • Use leche_cruda only for raw milk purchases
  • Group similar supplies under insumos_basicos
  • Separate cuajo_y_fermentos for cheese-specific analysis
  • Track refrigeracion separately to identify energy efficiency opportunities
Analysis and Reporting:
  • Compare costs across batches of the same product
  • Track cost trends over time
  • Identify cost reduction opportunities by concept
  • Calculate cost per unit for pricing decisions
  • Monitor raw milk prices for budget forecasting
Data Quality:
  • Always include meaningful observations
  • Document supplier information when relevant
  • Record quantities and unit prices for raw materials
  • Note any unusual expenses or one-time costs
  • Maintain consistency in how costs are categorized

Build docs developers (and LLMs) love