Fertilizantes

Los fertilizantes representan los productos nutricionales utilizados en los cultivos. Esta API permite gestionar el inventario, composicion nutricional y programas de fertilizacion.


El modelo de Fertilizante

  • Name
    id
    Type
    string
    Description

    Identificador unico.

  • Name
    name
    Type
    string
    Description

    Nombre del producto.

  • Name
    brand
    Type
    string
    Description

    Marca comercial.

  • Name
    type
    Type
    FertilizerType
    Description

    Tipo de fertilizante.

  • Name
    nutrients
    Type
    FertilizerNutrient[]
    Description

    Nutrientes y porcentajes.

    • Name
      type
      Type
      NutrientType
      Description

      Tipo de nutriente.

    • Name
      percentage
      Type
      number
      Description

      Porcentaje en formula.

  • Name
    npk
    Type
    object
    Description

    Valores NPK.

    • Name
      nitrogen
      Type
      number
      Description

      Nitrogeno (N).

    • Name
      phosphorus
      Type
      number
      Description

      Fosforo (P).

    • Name
      potassium
      Type
      number
      Description

      Potasio (K).

  • Name
    organic
    Type
    boolean
    Description

    Si es organico.

  • Name
    concentration
    Type
    number
    Description

    Dosis recomendada (ml/L o g/L).

  • Name
    unit
    Type
    string
    Description

    Unidad de medida: ml o g.

  • Name
    stock
    Type
    number
    Description

    Cantidad en inventario.

  • Name
    stockUnit
    Type
    string
    Description

    Unidad de stock: ml, g, L, kg.

  • Name
    recommendedStages
    Type
    PlantStage[]
    Description

    Etapas recomendadas de uso.

Ejemplo de fertilizante

{
  "id": "fert-001",
  "name": "Bio Grow",
  "brand": "BioBizz",
  "type": "GROW",
  "nutrients": [
    { "type": "NITROGEN", "percentage": 4.0 },
    { "type": "PHOSPHORUS", "percentage": 3.0 },
    { "type": "POTASSIUM", "percentage": 6.0 }
  ],
  "npk": {
    "nitrogen": 4,
    "phosphorus": 3,
    "potassium": 6
  },
  "organic": true,
  "concentration": 4,
  "unit": "ml",
  "stock": 1000,
  "stockUnit": "ml",
  "pricePerUnit": 0.02,
  "recommendedStages": ["VEGETATIVE", "PRE_FLOWERING"],
  "description": "Fertilizante organico para crecimiento vegetativo",
  "instructions": "Usar 2-4ml por litro de agua",
  "createdAt": "2024-01-15T10:00:00Z",
  "updatedAt": "2024-10-01T14:30:00Z"
}

Tipos de Fertilizante (FertilizerType)

TipoDescripcionUso
BASENutriente baseTodo el ciclo
GROWCrecimientoVegetativo
BLOOMFloracionFloracion
BOOSTERPotenciadorFases especificas
SUPPLEMENTSuplementoComplementario
MICRONUTRIENTMicronutrientesDeficiencias
PH_ADJUSTERAjustador pHControl pH
ENZYMEEnzimasSalud raices
ROOT_STIMULATOREstimulador raicesTrasplantes
FOLIARFoliarAplicacion hojas

Tipos de Nutriente (NutrientType)

Macronutrientes Primarios

NutrienteSimboloFuncion
NITROGENNCrecimiento vegetativo
PHOSPHORUSPRaices y floracion
POTASSIUMKSalud general

Macronutrientes Secundarios

NutrienteSimboloFuncion
CALCIUMCaEstructura celular
MAGNESIUMMgClorofila
SULFURSProteinas

Micronutrientes

NutrienteSimboloFuncion
IRONFeTransporte oxigeno
MANGANESEMnFotosintesis
ZINCZnCrecimiento
COPPERCuEnzimas
BORONBDesarrollo floral
MOLYBDENUMMoMetabolismo N
SILICONSiResistencia

GET/api/stock/fertilizers

Listar fertilizantes

Parametros de Consulta

  • Name
    type
    Type
    FertilizerType
    Description

    Filtrar por tipo.

  • Name
    brand
    Type
    string
    Description

    Filtrar por marca.

  • Name
    organic
    Type
    boolean
    Description

    Solo organicos.

  • Name
    stage
    Type
    PlantStage
    Description

    Filtrar por etapa recomendada.

  • Name
    search
    Type
    string
    Description

    Busqueda por nombre.

  • Name
    page
    Type
    number
    Description

    Pagina (default: 1).

  • Name
    limit
    Type
    number
    Description

    Items por pagina (default: 20).

Request

GET
/api/stock/fertilizers
curl -G https://api.cannahub.tech/api/stock/fertilizers \
  -H "Authorization: Bearer {token}" \
  -d type=BLOOM \
  -d organic=true

Response

{
  "fertilizers": [...],
  "count": 4,
  "filters": { "type": "BLOOM", "organic": "true" }
}

POST/api/stock/fertilizers

Crear fertilizante

Registra un nuevo fertilizante en el inventario.

Campos Requeridos

  • Name
    name
    Type
    string
    Description

    Nombre del producto.

  • Name
    brand
    Type
    string
    Description

    Marca comercial.

  • Name
    type
    Type
    FertilizerType
    Description

    Tipo de fertilizante.

  • Name
    npk
    Type
    object
    Description

    Valores NPK (nitrogen, phosphorus, potassium).

  • Name
    organic
    Type
    boolean
    Description

    Si es organico.

  • Name
    unit
    Type
    string
    Description

    Unidad: ml o g.

  • Name
    stock
    Type
    number
    Description

    Cantidad inicial.

  • Name
    stockUnit
    Type
    string
    Description

    Unidad de stock.

Request

POST
/api/stock/fertilizers
curl -X POST https://api.cannahub.tech/api/stock/fertilizers \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Top Max",
    "brand": "BioBizz",
    "type": "BOOSTER",
    "npk": {
      "nitrogen": 0,
      "phosphorus": 1,
      "potassium": 3
    },
    "organic": true,
    "concentration": 4,
    "unit": "ml",
    "stock": 500,
    "stockUnit": "ml",
    "recommendedStages": ["FLOWERING"],
    "description": "Potenciador organico de floracion"
  }'

Response (201)

{
  "fertilizer": {
    "id": "fert-1698765432100",
    "name": "Top Max",
    "brand": "BioBizz",
    "type": "BOOSTER",
    "organic": true,
    "stock": 500
  }
}

GET/api/stock/fertilizers/:id

Obtener fertilizante

Retorna los detalles de un fertilizante.

Request

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

PATCH/api/stock/fertilizers/:id

Actualizar fertilizante

Actualiza datos del fertilizante.

Campos Actualizables

  • Name
    stock
    Type
    number
    Description

    Cantidad en inventario.

  • Name
    pricePerUnit
    Type
    number
    Description

    Precio por unidad.

  • Name
    concentration
    Type
    number
    Description

    Dosis recomendada.

  • Name
    description
    Type
    string
    Description

    Descripcion.

  • Name
    instructions
    Type
    string
    Description

    Instrucciones de uso.

  • Name
    notes
    Type
    string
    Description

    Notas adicionales.

Request

PATCH
/api/stock/fertilizers/:id
curl -X PATCH https://api.cannahub.tech/api/stock/fertilizers/fert-001 \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "stock": 800,
    "notes": "Restock 15/10/2024"
  }'

DELETE/api/stock/fertilizers/:id

Eliminar fertilizante

Elimina un fertilizante del inventario.

Request

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

GET/api/stock/fertilizers/schedule

Programa de Fertilizacion

Obtiene recomendaciones de fertilizacion por etapa del cultivo.

Parametros de Consulta

  • Name
    stage
    Type
    PlantStage
    Description

    Etapa especifica (devuelve todas si no se especifica).

Respuesta

Retorna un programa con fertilizantes recomendados, dosis y frecuencia para cada etapa.

Request

GET
/api/stock/fertilizers/schedule
curl -G https://api.cannahub.tech/api/stock/fertilizers/schedule \
  -H "Authorization: Bearer {token}" \
  -d stage=FLOWERING

Response

{
  "schedules": [
    {
      "stage": "FLOWERING",
      "fertilizers": [
        {
          "fertilizer": {
            "id": "fert-002",
            "name": "Bio Bloom",
            "brand": "BioBizz",
            "type": "BLOOM"
          },
          "dosage": 4,
          "unit": "ml/L",
          "frequency": "every_other_day"
        },
        {
          "fertilizer": {
            "id": "fert-003",
            "name": "Top Max",
            "brand": "BioBizz",
            "type": "BOOSTER"
          },
          "dosage": 4,
          "unit": "ml/L",
          "frequency": "weekly"
        }
      ],
      "notes": "Reducir N, aumentar P-K"
    }
  ],
  "totalStages": 1
}

Guia NPK por Etapa

Ratios NPK recomendados segun etapa del cultivo:

EtapaNPKNotas
Germinacion000Solo agua
Plantula212Muy diluido
Vegetativo312Alto N
Pre-floracion222Transicion
Floracion temprana122Reducir N
Floracion media033Alto P-K
Floracion tardia023Enfasis K
Lavado000Solo agua

Sintomas de Deficiencias

NutrienteSintomaSolucion
NitrogenoHojas amarillas (bajas)Fertilizante alto N
FosforoHojas purpuras, crecimiento lentoFertilizante alto P
PotasioBordes quemadosFertilizante alto K
CalcioManchas marronesCalMag
MagnesioAmarillamiento intervenalEpsom salt
HierroClorosis en hojas nuevasQuelato de hierro

React Query Hooks

Uso de hooks

import {
  useFertilizersQuery,
  useFertilizerQuery,
  useCreateFertilizerMutation,
  useUpdateFertilizerMutation,
  useDeleteFertilizerMutation
} from '@/features/Club/Fertilizers/hooks'

// Listar fertilizantes con filtros
const { data: fertilizers, isLoading } = useFertilizersQuery({
  type: 'BLOOM',
  organic: true
})

// Obtener un fertilizante
const { data: fertilizer } = useFertilizerQuery('fert-001')

// Crear fertilizante
const createMutation = useCreateFertilizerMutation()
await createMutation.mutateAsync({
  name: 'Bio Bloom',
  brand: 'BioBizz',
  type: 'BLOOM',
  npk: { nitrogen: 2, phosphorus: 6, potassium: 3.5 },
  organic: true,
  unit: 'ml',
  stock: 1000,
  stockUnit: 'ml',
  nutrients: ['PHOSPHORUS', 'POTASSIUM'],
  recommendedStages: ['FLOWERING']
})

// Actualizar fertilizante
const updateMutation = useUpdateFertilizerMutation()
await updateMutation.mutateAsync({
  id: 'fert-001',
  data: { stock: 800 }
})

// Eliminar fertilizante
const deleteMutation = useDeleteFertilizerMutation()
await deleteMutation.mutateAsync('fert-001')

Query Keys

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

Proximos Pasos

Was this page helpful?