Module: Distributors & Wholesalers Management v1.0.0
What is Distributors & Wholesalers Management?
Complete distributors and wholesalers management — brands, products, warehouses, inventory, sales orders, and reports.
This module installs into modules/distributors_wholesalers/ and adds its own admin menus, permissions, and database tables — without editing Perfex CRM core files.
Who should use this module?
- Admins — activate the module, configure Settings, assign roles, and manage integrations.
- Operators / day-to-day staff — create and update records (orders, attendance, shipments, messages, etc.).
- Managers / approvers — review queues, approve workflows, and monitor dashboards/KPIs.
- Finance / compliance / ops leads — run reports, exports, and audit trails when the module supports them.
What you can achieve
- Keep all related work in one place inside Perfex CRM instead of spreadsheets.
- Control who can view, create, edit, approve, or export with role permissions.
- Use dashboards and reports to see status, bottlenecks, and history.
- Connect to other CRM data (customers, invoices, items, staff) where the module integrates.
Recommended learning path
- Read How to Install and activate the module.
- Skim Features so you know what screens exist.
- Complete the Quick Start checklist on this page (Settings → masters → first sample record).
- Open each screen guide under Screen-by-screen guides when you need step-by-step help.
- Check Version & Changelog after upgrades for new options.
Tip: Train one admin first, then create a limited role for operators so they only see the screens they need.
5-minute Quick Start
Follow this short path the first time you use Distributors & Wholesalers Management:
- Activate — Setup → Modules → activate Distributors & Wholesalers Management (run Upgrade if prompted).
- Permissions — Setup → Staff → Roles → enable view/create/edit (and approve/settings if needed) for this module.
- Settings — Open Distributors & Wholesalers Management → Settings and save company defaults, prefixes, and integrations.
- Master data — Create the first required masters (products, warehouses, templates, channels, accounts, routes, etc.).
- First transaction — Create one sample record end-to-end (save → submit/approve → complete) and confirm it appears in lists/reports.
- Cron — If the module uses alerts, sync, queues, or AI, confirm Perfex CRM cron is scheduled on the server.
Module documentation index
Start here — full guides for Distributors & Wholesalers Management:
- Overview & How to Use — what it is, who uses it, daily workflow
- Quick Start Guide — first 5 minutes + printable how-to
- How to Install — upload, activate, permissions, verify
- Features (Full Detail) — every capability explained
- FAQ & Tips — common questions and best practices
- Version & Changelog — version history
How to use in Perfex CRM (daily operations)
- Sign in to the admin area with a role that includes Distributors & Wholesalers Management permissions.
- Open Distributors Wholesalers (sidebar) or search for Distributors & Wholesalers Management in the admin menu.
- Start on the Dashboard (if available) to see open tasks, pending approvals, and KPIs.
- Review Settings after upgrades — new options may need defaults for your company.
- Create or import master data first; most modules block transactions until masters exist.
- Run the main business flow (create → submit → approve → post/complete) using the screens listed in Admin menu below.
- Use Reports / Analytics screens to reconcile stock, finance, compliance, or SLA metrics.
- For integrations (API, EDI, gateways, tax), confirm credentials in Settings and monitor logs or webhook delivery screens.
- Train staff with role-based access — give approvers approve permissions only, operators create/edit on their area.
- If something fails overnight, check Perfex CRM cron ran and open the module log / failed queue screen if present.
Admin menu — where to work
Open the Distributors & Wholesalers Management section in the admin sidebar. Screens your staff may use (depending on role):
- Account Statement
- Analytics
- Brands
- Categories
- Commissions
- Dashboard
- Delivery Routes
- Distributors
- Integrations
- Inventory
- Pick Lists
- Place Order
- Price Lists
- Product Catalog
- Products
- Promotions
- Quick Order
- Rebates
- Reports
- REST API
- Sales Orders
- Sales Returns
- Settings
- Shipments
- Territory Managers
- Transfer Requests
- Vans
- Van Sales
- Warehouses
- Webhooks
Detailed guide — features, workflows, API & FAQ
Module status
| Area | Status |
|---|---|
| ------ | -------- |
| Product master (brands, categories, products) | Complete |
| Multi-warehouse inventory & lot tracking | Complete |
| Distributor management & statements | Complete |
| Sales orders, returns, invoicing | Complete |
| Price lists, commissions, promotions, rebates | Complete |
| Pick/pack/ship, transfer requests | Complete |
| Barcode pick-list scanner | Complete |
| Tier auto-upgrade + rebate accrual cron | Complete |
| Report export rate limiting | Complete |
| Van sales, routes, mobile API | Complete |
| REST API with rate limiting | Complete |
| Client portal (orders, catalog, statement) | Complete |
| Webhooks with URL validation | Complete |
| Territory manager RBAC | Complete |
| Security hardening (MIME, SSRF, CSRF, territory scope) | Complete |
| CodeCanyon packaging (LICENSE, CHANGELOG, docs) | Complete |
| Complete uninstall cleanup | Complete |
Features
- Product master via Perfex CRM
Items+ module extension fields - Distributors via Perfex CRM
Clients+ credit limits, territories, customer tiers, statements - Multi-warehouse stock (internal engine or Nasbix Inventory Management)
- Sales order workflow: draft → approval → partial/full delivery → invoice
- Tiered & volume pricing via price lists
- Sales rep commission rules (calculated on delivery)
- Multi-currency sales orders
- REST API (Bearer token) for products, distributors, orders, stock
- Distributor client portal (orders, catalog, self-service ordering, statement, repeat order)
- Audit trail on sales orders and commission payouts
- Automatic credit hold on overdue invoices
- Commission payout workflow (approve / mark paid / export)
- Pick/pack/ship workflow with pick lists and shipment records
- Batch/lot tracking with FIFO consumption and expiry alerts
- Transfer requests with optional approval workflow
- Promotions & coupon codes with auto-apply and redemption tracking
- Volume rebate programs with tiered accruals and payout workflow
- Outbound webhooks with HMAC signatures, delivery log, and cron retry queue
- Analytics dashboard (KPIs, trends, promotion ROI, top distributors)
- Van sales with mobile stock, route stops, and cash collections
- Delivery routes with driver assignment, stop visits, and completion webhooks
- Dashboard/analytics query caching for scale
- REST API pagination (
limit,offset,since) - Sales returns with optional Perfex CRM credit notes
- 11 report types with Excel/PDF export
- Territory manager scoping for field teams
- Integration with Purchase Management (GRN, reorder PO)
Languages
English (source), French, Arabic, and Urdu. Rebuild translations from English:
php modules/distributors_wholesalers/language/build_locales.php --force
Permissions
| Permission | Description |
|---|---|
| ------------ | ------------- |
dw_brands | Brand management |
dw_products | Products |
dw_warehouses | Warehouses |
dw_inventory | Stock operations |
dw_distributors | Distributor master |
dw_sales_orders | Sales orders |
dw_sales_returns | Sales returns |
dw_price_lists | Price lists & customer tiers |
dw_commissions | Commission rules |
dw_promotions | Promotions & coupons |
dw_rebates | Rebate programs |
dw_webhooks | Outbound webhooks |
dw_analytics | Analytics dashboard |
dw_vans | Van fleet & van stock |
dw_routes | Delivery routes |
dw_van_sales | Field van sales |
dw_api | REST API keys |
dw_reports | Reports |
dw_territories | Territory assignments |
dw_settings | Module settings |
Finance rules (v1.8+)
- Ledger: Delivered orders count as receivable only when no Perfex CRM invoice is linked. Invoices are the receivable source once created.
- Receivables aging: Uninvoiced delivered orders + open invoice balances + opening balance. No double-counting.
- Tax mapping: Invoices and credit notes created from orders/returns include Perfex CRM line taxes from item tax settings, with fallback to calculated or default rate.
REST API (v1.8+)
Enable in module settings (dw_enable_rest_api). Create API keys under Distributors & Wholesalers → REST API.
Authentication uses the Authorization: Bearer {token} header only.
GET /distributors_wholesalers/api/products
GET /distributors_wholesalers/api/distributors
GET /distributors_wholesalers/api/orders
GET /distributors_wholesalers/api/orders/{id}
POST /distributors_wholesalers/api/orders
GET /distributors_wholesalers/api/stock
GET /distributors_wholesalers/api/vans?van_id={id}
GET /distributors_wholesalers/api/routes?date=YYYY-MM-DD
POST /distributors_wholesalers/api/van_sales
Authorization: Bearer {token}
Van/route endpoints require Enable van/route mobile API in module settings.
Client portal (v1.8+)
Distributor contacts see Sales Orders and Account Statement in the client area at /clients/dw/*.
Tests
Install dev dependencies once:
cd modules/distributors_wholesalers && composer install
Unit tests (no database):
composer test
Related modules
- Inventory Management — optional stock engine
- Purchase Management — GRN sync, reorder purchase orders
Extended module documentation
Table of contents
- [Overview](#overview)
- [Installation](#installation)
- [Menu & permissions](#menu--permissions)
- [Sales order workflow](#sales-order-workflow)
- [Finance & receivables](#finance--receivables)
- [REST API](#rest-api)
- [Client portal](#client-portal)
- [Webhooks](#webhooks)
- [Integrations](#integrations)
- [Security](#security)
- [Uninstall](#uninstall)
---
Overview
Distributors & Wholesalers extends Perfex CRM for wholesale and distribution operations:
| Area | Description |
|---|---|
| ------ | ------------- |
| Products | Perfex CRM Items + dw_product_details extension |
| Distributors | Perfex CRM Clients + dw_distributor_details extension |
| Stock | Multi-warehouse engine or Nasbix Inventory Management |
| Orders | Full order-to-cash with approval, delivery, invoicing |
| Field sales | Van stock, routes, mobile API |
Version 1.8.6 — all six implementation phases complete.
---
Menu & permissions
Admin path: Distributors & Wholesalers (sidebar)
| Permission | Feature |
|---|---|
| ------------ | --------- |
dw_brands / dw_categories / dw_products | Product master |
dw_warehouses / dw_inventory | Stock |
dw_distributors | Distributor master |
dw_sales_orders / dw_sales_returns | Order workflow |
dw_price_lists / dw_commissions | Pricing & incentives |
dw_promotions / dw_rebates | Promotions |
dw_webhooks / dw_api | Integrations |
dw_vans / dw_routes / dw_van_sales | Field sales |
dw_analytics / dw_reports | Reporting |
dw_territories | Field team scoping |
dw_settings | Module configuration |
Each permission supports: view, create, edit, delete, approve.
---
Sales order workflow
Statuses: draft → pending_approval → approved → partially_delivered → delivered → invoiced
- Create order (admin, quick order, or client portal).
- Credit limit and approval threshold checks on submit.
- Approve → pick list (optional auto-create) → ship → deliver.
- Create Perfex CRM invoice from delivered order.
- Commission calculated on delivery; promotions/rebates applied per settings.
---
Finance & receivables
- Delivered orders without invoice count as receivable.
- Once invoiced, Perfex CRM invoice is the receivable source (no double-count).
- Distributor statements combine ledger entries, open invoices, and uninvoiced deliveries.
- Credit hold blocks new orders when overdue threshold exceeded.
---
REST API
Enable in Settings (dw_enable_rest_api). Create keys under REST API.
Authorization: Bearer {token}
| Method | Endpoint |
|---|---|
| -------- | ---------- |
| GET | /distributors_wholesalers/api/products |
| GET | /distributors_wholesalers/api/distributors |
| GET/POST | /distributors_wholesalers/api/orders |
| GET | /distributors_wholesalers/api/stock |
| GET | /distributors_wholesalers/api/vans |
| GET | /distributors_wholesalers/api/routes |
| POST | /distributors_wholesalers/api/van_sales |
- Read/write scopes per key
- Rate limit per key (default 60/min; configurable)
- Bearer header only — query-string tokens are not accepted
- Pagination:
limit,offset,sinceon list endpoints
---
Client portal
Distributor contacts access /clients/dw/*:
- Order list and detail
- Product catalog and self-service ordering
- Repeat order from previous order
- Account statement (PDF)
Requires distributor flag on client record and portal ordering enabled in settings.
---
Webhooks
Configure under Distributors & Wholesalers → Webhooks.
Events: order.created, order.approved, order.delivered, order.partially_delivered, order.invoiced, shipment.created, van_sale.completed, route.completed.
- HMAC-SHA256 signature in
X-DW-Signatureheader - Only public HTTP/HTTPS URLs accepted (private/reserved IPs blocked)
- Delivery log with response codes
---
Integrations
| Module | Integration |
|---|---|
| -------- | ------------- |
| Inventory Management | Stock sync via warehouse mapping |
| Purchase Management | GRN posting, reorder PO from low-stock suggestions |
---
Security
| Control | Implementation |
|---|---|
| --------- | ---------------- |
| Admin auth | Perfex CRM AdminController session |
| Permissions | 20 feature groups with approve capability |
| Territory RBAC | Non-admin staff with territory assignments see scoped data only |
| API auth | SHA-256 hashed tokens, Bearer header, rate limits |
| CSRF | Perfex CRM forms + AJAX hash refresh |
| Uploads | Extension whitelist + MIME validation |
| Webhooks | URL validation, HMAC signatures |
| SQL/XSS | Parameterized queries, e() / html_escape() in views |
Run smoke tests:
php modules/distributors_wholesalers/tests/dw_logic_test.php
---
Extended module documentation
Table of contents
- [Overview](#overview)
- [Installation](#installation)
- [Menu & permissions](#menu--permissions)
- [Sales order workflow](#sales-order-workflow)
- [Finance & receivables](#finance--receivables)
- [REST API](#rest-api)
- [Client portal](#client-portal)
- [Webhooks](#webhooks)
- [Integrations](#integrations)
- [Security](#security)
- [Uninstall](#uninstall)
---
Overview
Distributors & Wholesalers extends Perfex CRM for wholesale and distribution operations:
| Area | Description |
|---|---|
| ------ | ------------- |
| Products | Perfex CRM Items + dw_product_details extension |
| Distributors | Perfex CRM Clients + dw_distributor_details extension |
| Stock | Multi-warehouse engine or Nasbix Inventory Management |
| Orders | Full order-to-cash with approval, delivery, invoicing |
| Field sales | Van stock, routes, mobile API |
Version 1.8.6 — all six implementation phases complete.
---
Menu & permissions
Admin path: Distributors & Wholesalers (sidebar)
| Permission | Feature |
|---|---|
| ------------ | --------- |
dw_brands / dw_categories / dw_products | Product master |
dw_warehouses / dw_inventory | Stock |
dw_distributors | Distributor master |
dw_sales_orders / dw_sales_returns | Order workflow |
dw_price_lists / dw_commissions | Pricing & incentives |
dw_promotions / dw_rebates | Promotions |
dw_webhooks / dw_api | Integrations |
dw_vans / dw_routes / dw_van_sales | Field sales |
dw_analytics / dw_reports | Reporting |
dw_territories | Field team scoping |
dw_settings | Module configuration |
Each permission supports: view, create, edit, delete, approve.
---
Sales order workflow
Statuses: draft → pending_approval → approved → partially_delivered → delivered → invoiced
- Create order (admin, quick order, or client portal).
- Credit limit and approval threshold checks on submit.
- Approve → pick list (optional auto-create) → ship → deliver.
- Create Perfex CRM invoice from delivered order.
- Commission calculated on delivery; promotions/rebates applied per settings.
---
Finance & receivables
- Delivered orders without invoice count as receivable.
- Once invoiced, Perfex CRM invoice is the receivable source (no double-count).
- Distributor statements combine ledger entries, open invoices, and uninvoiced deliveries.
- Credit hold blocks new orders when overdue threshold exceeded.
---
REST API
Enable in Settings (dw_enable_rest_api). Create keys under REST API.
Authorization: Bearer {token}
| Method | Endpoint |
|---|---|
| -------- | ---------- |
| GET | /distributors_wholesalers/api/products |
| GET | /distributors_wholesalers/api/distributors |
| GET/POST | /distributors_wholesalers/api/orders |
| GET | /distributors_wholesalers/api/stock |
| GET | /distributors_wholesalers/api/vans |
| GET | /distributors_wholesalers/api/routes |
| POST | /distributors_wholesalers/api/van_sales |
- Read/write scopes per key
- Rate limit per key (default 60/min; configurable)
- Bearer header only — query-string tokens are not accepted
- Pagination:
limit,offset,sinceon list endpoints
---
Client portal
Distributor contacts access /clients/dw/*:
- Order list and detail
- Product catalog and self-service ordering
- Repeat order from previous order
- Account statement (PDF)
Requires distributor flag on client record and portal ordering enabled in settings.
---
Webhooks
Configure under Distributors & Wholesalers → Webhooks.
Events: order.created, order.approved, order.delivered, order.partially_delivered, order.invoiced, shipment.created, van_sale.completed, route.completed.
- HMAC-SHA256 signature in
X-DW-Signatureheader - Only public HTTP/HTTPS URLs accepted (private/reserved IPs blocked)
- Delivery log with response codes
---
Integrations
| Module | Integration |
|---|---|
| -------- | ------------- |
| Inventory Management | Stock sync via warehouse mapping |
| Purchase Management | GRN posting, reorder PO from low-stock suggestions |
---
Security
| Control | Implementation |
|---|---|
| --------- | ---------------- |
| Admin auth | Perfex CRM AdminController session |
| Permissions | 20 feature groups with approve capability |
| Territory RBAC | Non-admin staff with territory assignments see scoped data only |
| API auth | SHA-256 hashed tokens, Bearer header, rate limits |
| CSRF | Perfex CRM forms + AJAX hash refresh |
| Uploads | Extension whitelist + MIME validation |
| Webhooks | URL validation, HMAC signatures |
| SQL/XSS | Parameterized queries, e() / html_escape() in views |
Run smoke tests:
php modules/distributors_wholesalers/tests/dw_logic_test.php
---
Features
Complete distributors and wholesalers management for Perfex CRM — by Nasbix Technologies.
- Product master via Perfex CRM Items + module extension fields
- Distributors via Perfex CRM Clients + credit limits, territories, customer tiers, statements
- Multi-warehouse stock (internal engine or Nasbix Inventory Management)
- Sales order workflow: draft → approval → partial/full delivery → invoice
- Tiered & volume pricing via price lists
- Sales rep commission rules (calculated on delivery)
- Multi-currency sales orders
- REST API (Bearer token) for products, distributors, orders, stock
- Distributor client portal (orders, catalog, self-service ordering, statement, repeat order)
- Audit trail on sales orders and commission payouts
- Automatic credit hold on overdue invoices
- Commission payout workflow (approve / mark paid / export)
- Pick/pack/ship workflow with pick lists, barcode scanner, and shipment records
- Distributor tier auto-upgrade from rolling sales (optional cron)
- Scheduled rebate accrual rebuild and report export rate limits
- Batch/lot tracking with FIFO consumption and expiry alerts
- Transfer requests with optional approval workflow
- Promotions & coupon codes with auto-apply and redemption tracking
- Volume rebate programs with tiered accruals and payout workflow
- Outbound webhooks with HMAC signatures, delivery log, and cron retry queue
- Analytics dashboard (KPIs, trends, promotion ROI, top distributors)
- Van sales with mobile stock, route stops, and cash collections
Permissions
Granular staff capabilities are registered on activation. Assign them under Setup → Staff → Roles for the Distributors & Wholesalers Management capability group.
Typical capabilities include view, create, edit, delete, plus module-specific actions (approve, export, settings, API access).
Cron Jobs
Background tasks (if enabled) run through Perfex CRM's main cron. Example crontab (every minute):
* * * * * php /path/to/perfex_crm/index.php cron/index > /dev/null 2>&1
Module cron hooks (via after_cron_run): low-stock alerts, webhook retry queue, rebate accrual rebuild, and distributor tier auto-upgrade. Toggle rebate and tier jobs under module Settings.
After activation — configuration checklist
- Go to Setup → Modules and activate Distributors & Wholesalers Management.
- If prompted, click Upgrade Database or reload admin — migrations run automatically.
- Assign permissions under Setup → Staff → Roles.
- Open the module menu and configure settings.
- Perfex CRM 3.0+
- PHP 7.4+ (8.1+ recommended)
- MySQL 5.7+ / MariaDB 10.3+ (InnoDB)
- PHP extensions: mysqli, json, mbstring, curl, fileinfo
One-time setup (first time only)
- Setup → Modules → activate Distributors & Wholesalers Management.
- Setup → Staff → Roles → assign Distributors & Wholesalers Management permissions (view, create, edit, delete, approve, export, settings as needed).
- Open Distributors & Wholesalers Management → Settings and complete company defaults, prefixes, integrations, and notification options.
- Create master data (warehouses, products, templates, accounts, routes, etc.) before processing live transactions.
- Enable Perfex CRM cron (
php /path/to/perfex/index.php cron/index) for sync, retries, alerts, and scheduled jobs. - Optionally enable REST API / webhooks in module settings if you integrate external systems.
Tips for success
- Always configure Settings before creating live transactions.
- Create master data (items, warehouses, templates, channels, accounts) first — most modules block incomplete records.
- Use a test/sample record before going live with real customers or production stock.
- Separate roles: operators create/edit; managers approve; finance/reporting get view/export only.
- After any module upgrade, reopen Settings and confirm new options have sensible defaults.
- If overnight jobs fail, verify Perfex CRM cron and check the module log / failed queue screen.
Common questions (FAQ)
Where do I find the module after activation?
In the admin sidebar look for Distributors & Wholesalers Management. If missing, your role may lack view permission — fix under Setup → Staff → Roles.
Do I need to edit core Perfex CRM files?
No. Keep all custom code under modules/distributors_wholesalers/. Activate/deactivate from Setup → Modules.
What happens if I uninstall?
Deactivate keeps data. Uninstall usually removes module tables/options (see the Install article). Core customers, invoices, and items are not deleted by well-built modules.
Why can't my staff see a screen?
Almost always a permissions issue. Give the role at least view on that feature, then ask the user to log out and back in.
Reports/export buttons do nothing
Confirm the role has export (or view reports) permission, and that filters return at least one row. Try PDF/CSV from a wider date range.
FAQ from module documentation
Support
Nasbix Technologies — module changes are scoped to modules/distributors_wholesalers/ only; core Perfex CRM files are not modified.
Support
Nasbix Technologies — module scoped to modules/distributors_wholesalers/ only.
See also: README.md, UPGRADE.md, CHANGELOG.md, docs/ROADMAP.md.
Support
Nasbix Technologies — module scoped to modules/distributors_wholesalers/ only.
See also: README.md, UPGRADE.md, CHANGELOG.md, docs/ROADMAP.md.
Perfex CRM Knowledge Base — detailed usage guide generated from module README, HOW_TO_USE, and documentation.