Skip to content

1.8.0

Released: TBD

Highlights

  • Five new item-scoped analytics queries power the product inventory dashboard: a typed/filterable movement ledger, sales velocity & days-of-coverage, in-transit (open-PO) quantity, top clients, and a ranged stock-history series.
  • Inventory log rows are now self-describing: a source_type column classifies each movement (sale / purchase / credit / adjustment), enabling reference-number and counterparty resolution in the movement ledger.
  • Saved landing-page filter views: tenant-shared, named filter configurations (stored as JSONB) per landing page, with full CRUD so the frontend can offer reusable "saved views".

Added

  • itemMovements(itemId, locationId, types, limit, offset): ItemMovementPage! — paginated, filterable movement ledger; each row carries movementType (VENTA/COMPRA/AJUSTE/ DEVOLUCION/OTHER), referenceNumber, counterpartyName, quantityChange, balanceAfter (running balance), unitValue/totalValue, createdBy, occurredAt.
  • itemStockMetrics(itemId, windowDays, locationId): ItemStockMetrics!unitsSoldInWindow, dailyVelocity, availableQuantity, daysOfCoverage, projectedStockoutDate.
  • itemIncomingQuantity(itemId): Decimal! — quantity on open purchase orders not yet received.
  • itemTopClients(itemId, windowDays, limit): [ItemTopClient!]! — top clients by net units sold.
  • itemStockHistory(itemId, rangeDays, withEvents, locationId): ItemStockHistory! — daily stock points over a day-range with optional movement-event markers.
  • MovementType enum and InventoryLogSourceType.
  • See Item Inventory Analytics.
  • landingPageConfigs(landingPage): [LandingPageConfig!]! and landingPageConfig(id): LandingPageConfig — list/fetch tenant-shared saved filter configurations; createLandingPageConfig / updateLandingPageConfig (shared input, id: null creates) / deleteLandingPageConfig (write paths gated on the SETTINGS path permission).
  • LandingPage enum (one member per landing page) and the LandingPageConfig type.
  • See Saved Landing-Page Filters.

Changed

  • InventoryRepository.update_quantity takes an optional source_type; the invoice, credit, purchase-order and manual-adjustment write paths now populate it. The manual-adjustment path records the adjustment's source_id (was None).

Fixed

  • None.

Migrations

  • add_inv_log_source_type (20260603_add_source_type_to_inventory_logs.py, down_revision legal_status_int_credits) — adds the nullable inventory_logs.source_type integer column and backfills it from the legacy free-text method column. downgrade drops the column. No one-off scripts.
  • add_landing_page_configs (20260603_add_landing_page_configs.py, down_revision add_inv_log_source_type) — creates the landing_page_configs table (JSONB config, landing_page enum, name, nullable description, audit created_by_id) with an index on landing_page. downgrade drops the index and table. No one-off scripts.

Frontend impact

  • Stock metric cards (Velocidad / Cobertura): itemStockMetrics(itemId, windowDays: 30).
  • Posición de stock → "+N en tránsito": itemIncomingQuantity(itemId).
  • Movimientos recientes + tabs: itemMovements(itemId, types, limit, offset). movementType drives the Todos/Ventas/Compras/Ajustes/Devol. tabs; balanceAfter is the running-balance column; manual adjustments come back as AJUSTE with referenceNumber: null.
  • Top clientes (90d): itemTopClients(itemId, windowDays: 90, limit: 4).
  • Histórico de stock (7/30/60/90D): itemStockHistory(itemId, rangeDays, withEvents: true).
  • Static panels (Configuración de inventario, Stock actual/Físico/Disponible/Reservado, Reorden recomendado) keep using getItemById, availableQuantity, stockReservationsByItem.
  • Decimal values come back as strings; daysOfCoverage/projectedStockoutDate are null when velocity is 0 — render as "sin movimiento" rather than 0.
  • Saved filter views: persist the active landing-page filter payload via createLandingPageConfig(config) and re-apply by reading config back from landingPageConfigs(landingPage). Update is a full replace (send the whole object with its id); configs are shared across the tenant and createdById is display/audit only.

Versioning notes

  • MINOR bump (scripts/bump_version.py 1.8.0 --changelog-stub): additive queries, types and two new columns/tables. No breaking schema change. Deploy order: the migrations chain linearly — add_inv_log_source_type then add_landing_page_configs; run both before/with the deploy. The inventory-log backfill makes historical rows queryable immediately; the landing_page_configs table starts empty.