Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/EdgarJr30/proyecto-de-grado-cms/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Stock Management provides real-time visibility into inventory quantities across all warehouses and bin locations. The system maintains three key quantity types: On-Hand, Reserved, and Available.

Stock Quantity Types

On-Hand Quantity

Physical stock present in the warehouse:
On-Hand = Total physical inventory in location
  • Updated by posted inventory documents
  • Represents actual parts in storage
  • Cannot be negative (enforced by system)

Reserved Quantity

Parts allocated to accepted work orders:
Reserved = Parts committed to accepted tickets
  • Set when reserving parts for work orders
  • Prevents double-allocation
  • Released when parts are issued or unreserved

Available Quantity

Parts available for consumption:
Available = On-Hand - Reserved
  • True consumable inventory
  • Used for reorder calculations
  • Can be negative (over-reserved)
Always check Available quantity before issuing parts. On-Hand may include reserved stock not available for general use.

Accessing Stock Views

The system provides two main stock views:

Availability View

Location: Inventory > Disponibilidad (/inventory/availability) Shows: v_available_stock view Columns:
  • Part code and name
  • Warehouse code and name
  • On-Hand quantity
  • Reserved quantity
  • Available quantity (calculated)
Features:
  • Filter by warehouse
  • Search by part or warehouse name
  • Toggle “Only Available” (available_qty > 0)
  • Toggle “Only Reserved” (reserved_qty > 0)
  • Summary statistics (totals)

Stock by Location View

Location: Inventory > Stock por ubicación (/inventory/stock-by-location) Shows: v_stock_by_location view Columns:
  • Part code and name
  • Warehouse
  • Bin location
  • Quantity on hand
  • Unit of measure
Features:
  • Filter by warehouse
  • Filter by bin
  • Search by part code/name
  • Drill-down to specific bins

Service Functions

Access stock data programmatically:
// Get available stock view
import { listAvailableStock } from '@/services/inventory';

const availableStock = await listAvailableStock(
  { warehouse_id: warehouseId },
  5000 // limit
);

// Result type: VAvailableStockRow[]
// Fields: part_id, part_code, part_name, warehouse_id,
//         warehouse_code, warehouse_name, on_hand_qty,
//         reserved_qty, available_qty

// Get stock on hand by part
import { getStockOnHandByPart } from '@/services/inventory';
const partStock = await getStockOnHandByPart(partId);

// Get stock on hand by warehouse
import { getStockOnHandByWarehouse } from '@/services/inventory';
const warehouseStock = await getStockOnHandByWarehouse(warehouseId);

Stock Movements

Stock quantities change through posted inventory documents:
Increases On-Hand
Before: On-Hand = 10
Receipt: +5 parts
After: On-Hand = 15
  • Adds to destination bin
  • Does not affect reservations
  • Creates positive ledger entry

Stock Reservations

Reserve parts for work orders to ensure availability:
1

Accept Work Order

Work order must be in ACCEPTED status to reserve parts.
2

Navigate to Reservations

Go to Inventory > Reservas por OT (/inventory/reservations).
3

Select Work Order

Choose from list of accepted work orders.
4

Add Part Request

Specify:
  • Part ID
  • Quantity needed
  • Warehouse/bin location
5

Reserve

System calls reserve_ticket_part RPC:
await inv().rpc('reserve_ticket_part', {
  p_ticket_id: ticketId,
  p_part_id: partId,
  p_warehouse_id: warehouseId,
  p_bin_id: binId,
  p_qty: quantity
});
6

Verify Reservation

Reserved quantity increases, available decreases:
Before: On-Hand = 20, Reserved = 5, Available = 15
Reserve 3: On-Hand = 20, Reserved = 8, Available = 12
Reservations do not physically move parts. They only allocate quantities to specific work orders.

Stock Validation Rules

The system enforces these constraints:

Issue/Transfer Validation

ISSUE and TRANSFER documents validate sufficient stock before posting.
Validation logic:
IF quantity_to_issue > on_hand_qty THEN
  RAISE EXCEPTION 'Insufficient stock in bin %', bin_code;
END IF;
Error example:
Insufficient stock: Trying to issue 10 but only 7 available
in warehouse WH-01, bin A-01-05

Adjustment Validation

ADJUSTMENT quantities cannot be zero and cannot result in negative stock.
Validation logic:
IF adjustment_qty = 0 THEN
  RAISE EXCEPTION 'Adjustment quantity cannot be zero';
END IF;

IF (current_qty + adjustment_qty) < 0 THEN
  RAISE EXCEPTION 'Adjustment would result in negative stock';
END IF;

Cycle Counting Workflow

Regular physical inventory counts maintain accuracy:
1

Generate Count List

Export parts to count from stock by location view:
  • High-value parts
  • High-turnover items
  • ABC analysis categories
2

Perform Physical Count

Count actual parts in bins:
  • Verify part codes
  • Count quantities carefully
  • Note any discrepancies
  • Check for damage/obsolescence
3

Compare to System

Review system quantities:
  • On-Hand from v_stock_by_location
  • Note differences
  • Investigate large variances
4

Create Adjustment Documents

For each discrepancy:
  • Create ADJUSTMENT document
  • Set warehouse and bin
  • Enter adjustment quantity (+ or -)
  • Document reason in notes field
  • Post document
5

Review and Analyze

After adjustments:
  • Verify system matches physical
  • Analyze root causes
  • Implement corrective actions
  • Update procedures if needed

Stock Alerts

The system generates alerts based on stock levels:

Low Stock Alerts

When available_qty < min_stock_qty for a part:
  • Appears in reorder suggestions
  • Triggers procurement workflow
  • Considers reorder point if defined

Negative Available

When available_qty < 0 (over-reserved):
Negative available quantity indicates more parts are reserved than physically on-hand. This can happen if:
  • Stock was consumed without unreserving
  • Adjustments reduced on-hand below reservations
  • Multiple reservations on same stock
Action: Review reservations and cancel or issue as appropriate.

Zero On-Hand with Reservations

When on_hand_qty = 0 but reserved_qty > 0:
Ghost reservations exist without physical stock. Cancel these reservations or receive stock to fulfill them.

Reporting

Stock Valuation

Calculate total inventory value:
SELECT 
  p.code,
  p.name,
  s.on_hand_qty,
  pc.unit_cost,
  (s.on_hand_qty * pc.unit_cost) AS total_value
FROM stock_on_hand s
JOIN parts p ON s.part_id = p.id
JOIN part_costs pc ON p.id = pc.part_id
WHERE s.on_hand_qty > 0
ORDER BY total_value DESC;

Turnover Analysis

Identify slow-moving inventory:
SELECT 
  p.code,
  p.name,
  s.on_hand_qty,
  COUNT(l.id) AS movement_count,
  MAX(l.created_at) AS last_movement
FROM stock_on_hand s
JOIN parts p ON s.part_id = p.id
LEFT JOIN inventory_ledger l ON s.part_id = l.part_id
  AND l.created_at > NOW() - INTERVAL '90 days'
WHERE s.on_hand_qty > 0
GROUP BY p.code, p.name, s.on_hand_qty
HAVING COUNT(l.id) = 0
ORDER BY s.on_hand_qty DESC;

Best Practices

Regular Cycle Counts

Schedule periodic counts:
  • Critical parts: Monthly
  • High-value: Quarterly
  • Standard: Annually
  • Random samples: Weekly

Reserve Before Work

Always reserve parts for planned work:
  • Prevents shortages
  • Improves planning accuracy
  • Tracks true availability
  • Enables better procurement

Prompt Transaction Recording

Record movements immediately:
  • Don’t batch transactions
  • Use mobile devices for real-time entry
  • Verify bin locations during picks
  • Post documents same-day

Monitor Available Quantity

Focus on available, not on-hand:
  • Use availability view for decisions
  • Consider reservations in planning
  • Alert on low available (not just on-hand)
  • Review over-reserved situations

Documents

Process receipts, issues, and adjustments

Reservations

Manage work order part reservations

Reorder Policies

Automate reorder based on stock levels

Warehouses

Organize stock in locations

Build docs developers (and LLMs) love