Traceability Module

Track product lifecycle through processing stages with automatic CO₂ and distance aggregation.

Entities

ProductTraceability

FieldTypeDescription
idLongAuto PK
companyProductIdLongFK to CompanyProduct
totalDistanceKmDoubleSum of all stage distances (auto-recalculated)
totalCo2KgDoubleSum of all stage CO₂ values (auto-recalculated)
statusStringDRAFT, ACTIVE, ARCHIVED

ProcessingStage

FieldTypeDescription
idLongAuto PK
traceabilityIdLongFK to ProductTraceability
supplierIdLongSupplier performing this stage
stageNameStringe.g. Spinning, Dyeing, Cutting
stageOrderIntegerSequence position
countryCodeStringISO alpha-2
distanceKmDoubleTransport from previous stage
co2KgDoubleCO₂ for this stage
startDate / endDateLocalDateStage date range

Automatic Totals Recalculation

Whenever a ProcessingStage is added, updated, or deleted, ProcessingStageService automatically recalculates the parent ProductTraceability.totalDistanceKm and totalCo2Kg by summing all child stages.

See Traceability Tracking example →