Cosechas

Las cosechas representan el producto obtenido de los cultivos. Esta API gestiona todo el proceso post-cosecha: secado, curado, control de calidad y almacenamiento final.


El modelo de Cosecha

  • Name
    id
    Type
    string
    Description

    Identificador unico.

  • Name
    name
    Type
    string
    Description

    Nombre del lote.

  • Name
    crop
    Type
    object
    Description

    Cultivo origen.

  • Name
    strain
    Type
    object
    Description

    Cepa del producto.

  • Name
    status
    Type
    HarvestStatus
    Description

    Estado actual del proceso.

  • Name
    harvestedAt
    Type
    timestamp
    Description

    Fecha de cosecha.

  • Name
    wetWeight
    Type
    number
    Description

    Peso humedo en gramos.

  • Name
    dryWeight
    Type
    number
    Description

    Peso seco en gramos.

  • Name
    trimmedWeight
    Type
    number
    Description

    Peso manicurado en gramos.

  • Name
    moisture
    Type
    number
    Description

    Porcentaje de humedad.

  • Name
    quality
    Type
    HarvestQuality
    Description

    Calificacion de calidad.

  • Name
    cannabinoids
    Type
    object
    Description

    Perfil de cannabinoides.

  • Name
    terpenes
    Type
    array
    Description

    Terpenos detectados.

  • Name
    batchNumber
    Type
    string
    Description

    Numero de lote.

  • Name
    storageLocation
    Type
    string
    Description

    Ubicacion de almacenamiento.

  • Name
    stages
    Type
    HarvestStageLog[]
    Description

    Historial de etapas.

Ejemplo de cosecha

{
  "id": "harvest-001",
  "name": "Blue Dream Lote #1",
  "crop": {
    "id": "crop-001",
    "name": "Blue Dream Indoor Batch A",
    "plantedAt": "2024-06-15T00:00:00Z"
  },
  "strain": {
    "id": "strain_blue_dream",
    "name": "Blue Dream",
    "type": "hybrid"
  },
  "status": "STOCKED",
  "harvestedAt": "2024-09-20T00:00:00Z",
  "wetWeight": 1200,
  "dryWeight": 280,
  "trimmedWeight": 250,
  "moisture": 62,
  "quality": "A_GRADE",
  "cannabinoids": {
    "thc": 21.5,
    "cbd": 0.2,
    "cbg": 0.8
  },
  "terpenes": ["Mirceno", "Pineno", "Cariofileno"],
  "batchNumber": "BD-2024-001",
  "storageLocation": "Bodega A - Estante 3",
  "stages": [
    { "status": "DRYING", "startedAt": "2024-09-20", "endedAt": "2024-09-30" },
    { "status": "CURING", "startedAt": "2024-09-30", "endedAt": "2024-10-14" },
    { "status": "STOCKED", "startedAt": "2024-10-14" }
  ]
}

Estados de Cosecha (HarvestStatus)

Loading diagram...
EstadoDescripcion
DRYINGSecado inicial (7-14 dias)
CURINGCurado en frascos (2-8 semanas)
TESTINGEn analisis de laboratorio
STOCKEDAlmacenado, listo para venta
SOLDVendido/dispensado
DISPOSEDDescartado

Calificaciones de Calidad

CalidadDescripcion
A_GRADECogollos premium, alta densidad y resina
B_GRADECogollos buenos, menores que A
C_GRADECogollos aceptables, menor calidad
TRIMMaterial de manicurado
SHAKEMaterial suelto, para extracciones

GET/api/stock/harvests

Listar cosechas

Parametros de Consulta

  • Name
    status
    Type
    HarvestStatus
    Description

    Filtrar por estado.

  • Name
    cropId
    Type
    string
    Description

    Filtrar por cultivo origen.

  • Name
    strainId
    Type
    string
    Description

    Filtrar por cepa.

  • Name
    quality
    Type
    HarvestQuality
    Description

    Filtrar por calidad.

  • Name
    startDate
    Type
    timestamp
    Description

    Fecha minima de cosecha.

  • Name
    endDate
    Type
    timestamp
    Description

    Fecha maxima de cosecha.

  • Name
    search
    Type
    string
    Description

    Busqueda por nombre o lote.

Request

GET
/api/stock/harvests
curl -G https://api.cannahub.tech/api/stock/harvests \
  -H "Authorization: Bearer {token}" \
  -d status=STOCKED \
  -d quality=A_GRADE

Response

{
  "harvests": [...],
  "count": 5,
  "filters": { "status": "STOCKED", "quality": "A_GRADE" }
}

POST/api/stock/harvests

Crear cosecha

Crea una nueva cosecha a partir de un cultivo.

Campos Requeridos

  • Name
    name
    Type
    string
    Description

    Nombre del lote.

  • Name
    cropId
    Type
    string
    Description

    ID del cultivo origen.

  • Name
    wetWeight
    Type
    number
    Description

    Peso humedo en gramos.

Request

POST
/api/stock/harvests
curl -X POST https://api.cannahub.tech/api/stock/harvests \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "OG Kush Lote #3",
    "cropId": "crop-002",
    "cropName": "OG Kush Outdoor",
    "strainId": "strain_og_kush",
    "strainName": "OG Kush",
    "wetWeight": 2500,
    "quality": "A_GRADE",
    "notes": "Tricomas 30% ambar"
  }'

Response (201)

{
  "harvest": {
    "id": "harvest-1698765432100",
    "name": "OG Kush Lote #3",
    "status": "DRYING",
    "wetWeight": 2500,
    "quality": "A_GRADE",
    "batchNumber": "BATCH-1698765432100"
  }
}

GET/api/stock/harvests/:id

Obtener cosecha

Retorna detalles de una cosecha especifica.

Request

curl https://api.cannahub.tech/api/stock/harvests/harvest-001 \
  -H "Authorization: Bearer {token}"

PATCH/api/stock/harvests/:id

Actualizar cosecha

Actualiza datos de la cosecha, incluyendo cambio de estado.

Al cambiar el estado, automaticamente se registra en el historial de etapas.

Campos Actualizables

  • Name
    status
    Type
    HarvestStatus
    Description

    Nuevo estado (genera log automatico).

  • Name
    dryWeight
    Type
    number
    Description

    Peso seco (al terminar secado).

  • Name
    trimmedWeight
    Type
    number
    Description

    Peso manicurado.

  • Name
    moisture
    Type
    number
    Description

    Humedad actual.

  • Name
    cannabinoids
    Type
    object
    Description

    Resultados de lab.

  • Name
    storageLocation
    Type
    string
    Description

    Ubicacion de almacenamiento.

  • Name
    stageNotes
    Type
    string
    Description

    Notas para el cambio de estado.

Request

PATCH
/api/stock/harvests/:id
curl -X PATCH https://api.cannahub.tech/api/stock/harvests/harvest-001 \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "status": "CURING",
    "dryWeight": 580,
    "moisture": 58,
    "stageNotes": "Secado completado, tallos crujen"
  }'

DELETE/api/stock/harvests/:id

Eliminar cosecha

Elimina una cosecha del sistema.

Request

curl -X DELETE https://api.cannahub.tech/api/stock/harvests/harvest-001 \
  -H "Authorization: Bearer {token}"

Calculo de Rendimiento

Metricas tipicas de rendimiento:

MetricaFormulaValor Tipico
Ratio seco/humedodryWeight / wetWeight20-25%
Ratio trim/flortrimmedWeight / dryWeight85-95%
g/m2dryWeight / squareMeters400-600g
g/plantadryWeight / plantCount50-150g

React Query Hooks

Uso de hooks

import {
  useHarvestsQuery,
  useHarvestQuery,
  useCreateHarvestMutation,
  useUpdateHarvestMutation,
  useDeleteHarvestMutation,
  useTransferHarvestMutation
} from '@/features/Club/Harvests/hooks'

// Listar cosechas con filtros
const { data: harvests, isLoading } = useHarvestsQuery({
  status: 'CURING',
  quality: 'A_GRADE'
})

// Obtener una cosecha
const { data: harvest } = useHarvestQuery('harvest-001')

// Crear cosecha
const createMutation = useCreateHarvestMutation()
await createMutation.mutateAsync({
  name: 'Blue Dream Batch A - Cosecha 1',
  cropId: 'crop-001',
  wetWeight: 2500,
  quality: 'A_GRADE'
})

// Actualizar cosecha
const updateMutation = useUpdateHarvestMutation()
await updateMutation.mutateAsync({
  id: 'harvest-001',
  data: { dryWeight: 520, status: 'CURING' }
})

// Transferir a producto
const transferMutation = useTransferHarvestMutation()
await transferMutation.mutateAsync({
  id: 'harvest-001',
  data: { quantity: 100, productId: 'prod-001', locationId: 'loc-001' }
})

// Eliminar cosecha
const deleteMutation = useDeleteHarvestMutation()
await deleteMutation.mutateAsync('harvest-001')

Query Keys

harvestKeys = {
  all: ['harvests'],
  lists: () => ['harvests', 'list'],
  list: (filters) => ['harvests', 'list', filters],
  details: () => ['harvests', 'detail'],
  detail: (id) => ['harvests', 'detail', id]
}

Proximos Pasos

Was this page helpful?