Product Setup Module

Units

Units define measurement rules for products (for example: piece, box, kg) and optional conversion against a base unit.

How It Works

  1. The page loads unit records with pagination, search, and filter options.
  2. You can create a base unit (like Piece) or a derived unit (like Box).
  3. For derived units, you select a base unit and define conversion with operator and operation_value.
  4. When saved, the backend validates uniqueness and conversion fields, then stores the unit.
  5. From the list, you can edit unit info, change active/inactive status, or run bulk status updates.
  6. Delete is protected: a unit cannot be deleted if products use it or if another unit depends on it as base.

Backend API Routes

  • GET /api/v1/units - list units
  • POST /api/v1/unit/store - create unit
  • ANY /api/v1/unit/update/{id} - update unit
  • ANY /api/v1/unit/update-status/{id} - update single unit status
  • POST /api/v1/unit/status-update/multiple - bulk status update
  • DELETE /api/v1/unit/delete/{id} - delete single unit
  • DELETE /api/v1/unit/multiple-delete - bulk delete units

Feature Gate: all Unit endpoints are protected by feature.access:ftr_unit_setup.

Validation Rules

  • unit_name: required, max 191, unique
  • unit_code: required, max 191, unique
  • base_unit: nullable integer, minimum 0
  • operator: nullable, allowed * or /
  • operation_value: nullable numeric, must be greater than 0
  • is_active: nullable boolean

Important Business Rules

  • A unit cannot use itself as base unit.
  • If base_unit = 0, unit is treated as a base unit with operator=* and operation_value=1.
  • Deletion is blocked if the unit is already used by any product.
  • Deletion is blocked if the unit is used as a base by another unit.

Frontend Component

frontend-source/src/pages/product-setup/unit/Unit.jsx

  • Search, sort, and filters (status/base unit)
  • Create/edit modal form
  • Bulk status and delete operations

Screenshots

Unit Management
Unit management screen