Module: Purchase Management v1.1.0
Enterprise purchase and procurement management for BIXCRM
Screen-by-screen guides (each tab explained)
Click a menu item below for step-by-step instructions on that Purchase Management screen:
- Dashboard
- Suppliers
- Purchase Requests
- RFQ / Quotations
- Purchase Orders
- Goods Receipt
- Supplier Bills
- Payments
- Returns
- Approvals
- Reports
- Settings
How to use in BIXCRM (daily operations)
- Sign in to the admin area with a role that includes Purchase Management permissions.
- Open Purchase Management (sidebar) or search for Purchase 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 BIXCRM cron ran and open the module log / failed queue screen if present.
Admin menu — where to work
Open the Purchase Management section in the admin sidebar. Screens your staff may use (depending on role):
- Approvals
- Dashboard
- Goods Receipt
- Payments
- Purchase Orders
- Purchase Requests
- Purchasing
- Reports
- Returns
- RFQ / Quotations
- Settings
- Supplier Bills
- Suppliers
Detailed guide — features, workflows, API & FAQ
Status
| Area | Status |
|---|---|
| ------ | -------- |
| Core procurement workflow (PR → RFQ → PO → GRN → Bill → Payment → Return) | Complete |
| Approvals, dashboard, reports, settings | Complete |
| Security hardening (POST/CSRF, upload validation, rate limits, webhook URL validation) | Complete |
| Unit tests (helper, payment, extension logic) | Complete — 57 tests |
| CodeCanyon packaging (LICENSE, CHANGELOG, HTML docs, demo data) | Complete |
Production-ready for standard procurement use. See [docs/ROADMAP.md](docs/ROADMAP.md) for migration history and future ideas.
---
Features
Suppliers
- Supplier master with contacts, attachments, ledger, and statement PDF
- CSV and Excel export
- Opening balance and credit tracking
Purchase requests (PR)
- Draft → submit → approval workflow
- Line items (catalog or manual when enabled)
- Attachments and convert-to-PO
RFQ & quotations
- RFQ creation from PR or standalone
- Supplier quotation entry, comparison, and award
- Email invitation to suppliers
- RFQ PDF download
Purchase orders (PO)
- Tax, discount, shipping, terms
- Email with PDF attachment
- Receipt tracking (partial / full)
- Billing status — PO marked
billedonly when all lines are fully billed
Goods receipt (GRN)
- Warehouse integration modes:
auto,required,disabled - Stock movement hooks for Inventory Management module
- PDF export
Supplier bills
- Three-way match (PO qty/price vs GRN received qty)
- Partial billing support
- Approve / reject / cancel workflow
Payments
- Multi-bill split allocations (on-account supported)
- Void reverses all allocations and bill balances
- Payment receipt PDF
Returns
- Purchase return documents with approval workflow
- PDF export
Approvals
- Multi-level approval (configurable staff per level)
- Delegation sync across PR, PO, Bill, Return
- Dedicated approvals inbox
Dashboard & reports
- KPI dashboard and top suppliers widget
- 13 report types with CSV, Excel, and PDF export
- Supplier statement and aging
Security
- Destructive actions require POST (+ CSRF for module URLs)
- Upload MIME and
rel_typevalidation - Export rate limiting
- No generic admin bypass on assigned approval steps
---
Requirements
| Requirement | Notes |
|---|---|
| ------------- | ------- |
| BIXCRM | 2.3.x or later |
| PHP | 7.4+ (8.x supported) |
| MySQL / MariaDB | InnoDB |
| TCPDF | Bundled with BIXCRM (application/vendor/tecnickcom/tcpdf) |
| BIXCRM cron | Recommended — overdue bill checks |
| Inventory Management | Optional — GRN warehouse stock sync |
---
Permissions
| Feature key | Capabilities |
|---|---|
| ------------- | -------------- |
purchase_dashboard | view |
purchase_suppliers | view, create, edit, delete |
purchase_request | view, create, edit, delete, approve |
purchase_rfq | view, create, edit, delete |
purchase_order | view, create, edit, delete, approve |
purchase_grn | view, create, edit, delete |
purchase_bill | view, create, edit, delete, approve |
purchase_payment | view, create, edit, delete |
purchase_return | view, create, edit, delete, approve |
purchase_reports | view, export |
purchase_settings | view, edit, manage |
Approvals inbox: staff with purchase_dashboard view or document approve permissions (pm_can_access_approvals()).
---
Typical workflow
PR (optional) → RFQ (optional) → PO → GRN → Supplier Bill → Payment
↘ Return (optional)
Each document type supports draft, approval (when enabled), and status-specific actions. See [docs/DOCUMENTATION.md](docs/DOCUMENTATION.md) for step-by-step usage.
---
Documentation
| Document | Description |
|---|---|
| ---------- | ------------- |
| [docs/DOCUMENTATION.md](docs/DOCUMENTATION.md) | User guide, admin settings, reports, PDFs, integrations, security |
| [docs/ROADMAP.md](docs/ROADMAP.md) | Optional enhancements and known limitations |
---
Extended module documentation
Table of contents
- [Overview](#overview)
- [Menu & navigation](#menu--navigation)
- [Document workflow](#document-workflow)
- [Module settings](#module-settings)
- [Approvals](#approvals)
- [Payments & allocations](#payments--allocations)
- [Reports & exports](#reports--exports)
- [PDF documents](#pdf-documents)
- [Integrations](#integrations)
- [Security](#security)
- [Cron & automation](#cron--automation)
- [Database schema](#database-schema)
- [Developer reference](#developer-reference)
---
Overview
Purchase Management covers the full procure-to-pay cycle inside BIXCRM admin:
| Phase | Document | Purpose |
|---|---|---|
| ------- | ---------- | --------- |
| 1 | Suppliers | Vendor master data |
| 2 | Purchase Request (PR) | Internal requisition |
| 3 | RFQ | Request quotations from suppliers |
| 4 | Purchase Order (PO) | Commitment to supplier |
| 5 | GRN | Goods received note |
| 6 | Supplier Bill | Accounts payable invoice |
| 7 | Payment | Pay supplier (multi-bill split) |
| 8 | Return | Return goods to supplier |
All 17 implementation phases (foundation through testing) are complete. Post-phase polish (RFQ PDF, partial PO billing, supplier Excel export, deactivation logging) is also complete.
---
Menu & navigation
Admin path: Purchase Management (sidebar)
| Menu item | URL segment | Permission |
|---|---|---|
| ----------- | ------------- | ------------ |
| Dashboard | purchase_management | purchase_dashboard → view |
| Suppliers | .../suppliers | purchase_suppliers |
| Purchase Requests | .../requests | purchase_request |
| RFQ & Quotations | .../rfqs | purchase_rfq |
| Purchase Orders | .../orders | purchase_order |
| Goods Receipt | .../grn | purchase_grn |
| Supplier Bills | .../bills | purchase_bill |
| Payments | .../payments | purchase_payment |
| Returns | .../returns | purchase_return |
| Approvals | .../approvals | dashboard view or approve caps |
| Reports | .../reports | purchase_reports |
| Settings | .../settings | purchase_settings |
Routes are defined in config/routes.php.
---
Document workflow
Purchase request (PR)
Statuses: draft → submitted → pending_approval → approved / rejected → converted / cancelled
- Create PR with line items (catalog items or manual lines if
pm_allow_manual_itemsis enabled). - Upload attachments on the PR view page.
- Submit for approval (when
pm_require_approvalis on and amount exceeds limit). - Approved PR can be converted to PO or used as source for RFQ.
Actions on view: Edit (draft/rejected), Submit, Approve/Reject (inbox), Cancel, Convert to PO.
RFQ
Statuses: draft → sent → closed / cancelled
- Create RFQ manually or link from an approved PR.
- Add invited suppliers and line items (qty, UOM, specifications).
- Send — emails suppliers with quotation link (no PDF attachment; see [ROADMAP.md](ROADMAP.md)).
- Enter supplier quotations; use Compare to evaluate; Award winning quotation.
- Download PDF from list or view page.
Feature toggle: pm_enable_rfq in settings.
Purchase order (PO)
Statuses: draft → pending_approval → approved → sent → partially_received / fully_received → billed → closed / cancelled
- Create from PR, RFQ award, or directly (if
pm_allow_po_without_pr). - Set supplier, lines, tax, shipping, payment terms.
- Approve and Send — email includes PO PDF attachment.
- Create GRN against PO as goods arrive.
- PO billing status:
- Partial bill: PO stays at partially_received or fully_received.
- Full bill: All line billed_qty ≥ line quantity → status becomes billed.
GRN (Goods receipt)
Statuses: draft → posted / cancelled
- Select PO and received quantities per line.
- Warehouse field behaviour depends on
pm_warehouse_integration:
- auto — optional warehouse
- required — warehouse mandatory
- disabled — no warehouse validation; no stock sync
- Posting updates PO received quantities and may sync inventory (Inventory Management module).
Supplier bill
Statuses: draft → pending_approval → approved → partially_paid / paid / overdue / cancelled
- Create from PO (pulls unbilled quantities) or manually.
- Three-way match checks PO price/qty vs GRN received qty (unless
pm_allow_bill_without_grn). - On approval, PO line
billed_qtyincreases; PO billing status refreshes automatically. - Download bill PDF from list or document view.
Payment
- Record payment against one or more approved bills (allocation UI).
- On-account payments (no bill allocation) supported.
- Void reverses all allocations and restores bill balances/status.
- Payment receipt PDF available.
Database: allocations stored in pm_supplier_payment_allocations (migration 101).
Return
Statuses: draft → pending_approval → approved → posted / cancelled
Create return against GRN/bill context. Approval workflow and PDF export supported.
Feature toggle: pm_enable_returns.
---
Module settings
Path: Purchase Management → Settings
Prefix & numbering
| Setting | Default | Purpose |
|---|---|---|
| --------- | --------- | --------- |
pm_supplier_code_prefix | SUP- | Supplier code |
pm_pr_prefix | PR- | Purchase request |
pm_rfq_prefix | RFQ- | RFQ |
pm_po_prefix | PO- | Purchase order |
pm_grn_prefix | GRN- | Goods receipt |
pm_bill_prefix | BILL- | Supplier bill |
pm_payment_prefix | PAY- | Payment |
pm_return_prefix | PRN- | Return |
pm_number_padding | 6 | Numeric padding |
General
| Setting | Description |
|---|---|
| --------- | ------------- |
pm_default_currency | Default document currency |
pm_default_payment_terms | e.g. Net 30 |
pm_default_tax | Default tax name for lines |
pm_required_supplier_fields | Comma-separated required fields |
pm_warehouse_integration | auto / required / disabled |
pm_terms_conditions | Default PO terms |
pm_pdf_footer | Footer text on all module PDFs |
Approval
| Setting | Description |
|---|---|
| --------- | ------------- |
pm_require_approval | Enable approval workflows |
pm_approval_amount_limit | Amount threshold |
pm_approval_level1_staff | Level 1 approver (staff ID) |
pm_approval_level2_staff | Level 2 approver |
pm_approval_level3_staff | Level 3 approver |
pm_approval_routing_mode | staff or role |
pm_approval_level1_role | Level 1 BIXCRM role (when mode = role) |
pm_approval_level2_role | Level 2 BIXCRM role |
pm_approval_level3_role | Level 3 BIXCRM role |
When role mode is selected, any active staff member with the configured BIXCRM role can approve that step from the inbox.
API & webhooks
| Setting | Description |
|---|---|
| --------- | ------------- |
pm_api_enabled | Enable REST API |
pm_api_key | API authentication key |
pm_webhook_url | Webhook receiver URL |
pm_webhook_secret | HMAC signing secret |
Feature toggles
| Setting | Default | Description |
|---|---|---|
| --------- | --------- | ------------- |
pm_enable_purchase_requests | 1 | PR module |
pm_enable_rfq | 1 | RFQ module |
pm_enable_returns | 1 | Returns module |
pm_allow_manual_items | 1 | Free-text line items |
pm_allow_po_without_pr | 1 | Direct PO creation |
pm_allow_bill_without_grn | 0 | Skip GRN qty check on bills |
---
Approvals
Supported document types
- Purchase request (
purchase_request) - Purchase order (
purchase_order) - Supplier bill (
purchase_bill) - Purchase return (
purchase_return)
Inbox
Purchase Management → Approvals lists pending steps assigned to the current user.
Rules
- Assigned approver must hold the document's
approvepermission. - Generic admin bypass is disabled — only assigned approver or settings manager (
purchase_settings→ manage) on unassigned steps may act. - Delegation:
pm_delegate_approval_action()keeps document status in sync withApproval_model.
`approver_role` column
The pm_purchase_approval_steps.approver_role field stores role hints (manager, admin, staff) when fallback approvers are used. Settings UI assigns staff IDs, not roles. Role-based routing is partially implemented — see [ROADMAP.md](ROADMAP.md).
---
Payments & allocations
Recording a payment
- Open Payments → New payment.
- Select supplier and payment amount/method/date.
- Allocate amounts to one or more open bills (AJAX loads bill balances).
- Save — allocations inserted into
pm_supplier_payment_allocations; billpaid_amountand status updated.
Void
Voiding a payment:
- Deletes all allocation rows for that payment
- Reverses
paid_amounton each affected bill - Restores bill status (
unpaid,partially_paid, oroverdueif past due)
On-account
Payment with zero allocations is stored as supplier on-account credit (no bill linkage).
---
Reports & exports
Path: Purchase Management → Reports
| Report key | Name |
|---|---|
| ------------ | ------ |
supplier_statement | Supplier statement |
supplier_ledger | Supplier ledger |
po | Purchase orders |
grn | Goods receipts |
pending_receiving | Pending receiving |
bills | Supplier bills |
payments | Payments |
returns | Returns |
by_item | Purchases by item |
by_supplier | Purchases by supplier |
tax | Tax summary |
aging | AP aging |
approval_history | Approval history |
Export formats: CSV, Excel (.xls), PDF — via Pm_export library.
Suppliers list: CSV and Excel export from Suppliers → Export buttons.
Export endpoints use pm_export_rate_limit() to reduce abuse.
---
PDF documents
Generated via libraries/Pm_pdf.php (TCPDF + module view templates).
| Document | Template | Controller action |
|---|---|---|
| ---------- | ---------- | ------------------- |
| Purchase order | views/orders/pdf.php | orders/pdf/{id} |
| GRN | views/grn/pdf.php | grn/pdf/{id} |
| Supplier bill | views/bills/pdf.php | bills/pdf/{id} |
| Payment receipt | views/payments/pdf.php | payments/pdf/{id} |
| Return | views/returns/pdf.php | returns/pdf/{id} |
| Purchase request | views/requests/pdf.php | requests/pdf/{id} |
| RFQ | views/rfqs/pdf.php | rfqs/pdf/{id} |
| Supplier statement | views/suppliers/statement_pdf.php | via supplier view |
PO email send attaches PDF via Pm_pdf::save_purchase_order_file().
Optional query: ?output_type=I (inline) or D (download, default).
---
Integrations
Inventory Management
When pm_warehouse_integration is not disabled and the Inventory Management module is active:
- GRN post creates stock movements
- GRN cancel reverses movements
Setting: Settings → Warehouse integration.
BIXCRM items & taxes
Line items can reference BIXCRM catalog items (pm_get_items()). Tax rates resolve via pm_resolve_line_tax_rate() and BIXCRM tax settings.
RFQ send and PO send use pm_send_email(). Both include PDF attachments when sending.
---
REST API & webhooks
Configure under Settings → API & Webhooks.
| Setting | Purpose |
|---|---|
| --------- | --------- |
pm_api_enabled | Enable read-only REST API |
pm_api_key | Send as header X-PM-API-Key |
pm_webhook_url | Outbound webhook endpoint |
pm_webhook_secret | HMAC SHA256 signature in X-PM-Signature |
API endpoints
| Method | URL | Description |
|---|---|---|
| -------- | ----- | ------------- |
| GET | /purchase_management/api | API info |
| GET | /purchase_management/api/suppliers | Supplier list |
| GET | /purchase_management/api/purchase_orders/{id} | PO + lines |
| GET | /purchase_management/api/supplier_bills/{id} | Bill + lines |
| GET | /purchase_management/api/payments/{id} | Payment + allocations |
Webhook events
| Event | When |
|---|---|
| ------- | ------ |
rfq.sent | RFQ emailed to suppliers |
supplier_bill.approved | Bill approved |
supplier_bill.cancelled | Approved bill cancelled |
supplier_payment.recorded | Payment saved |
supplier_payment.voided | Payment voided |
---
Security
Implemented in Phase 15:
| Control | Implementation |
|---|---|
| --------- | ---------------- |
| POST-only destructive actions | pm_require_post(), pm_require_post_or_ajax() on delete/void/approve/reject/cancel/submit/send/post |
| CSRF on delete links | assets/js/purchase_management.js converts _delete links to POST with token |
| Upload validation | MIME check + pm_get_allowed_attachment_rel_types() whitelist |
| Approval integrity | pm_can_act_on_approval_step() — no admin bypass |
| Export throttling | pm_export_rate_limit() on reports and supplier export |
---
Cron & automation
Hook: after_cron_run → purchase_management_cron_tasks()
- Overdue bills:
Supplier_bill_model::check_overdue_bills()marks approved unpaid bills past due date asoverdue.
Ensure BIXCRM cron is configured and running.
---
Database schema
Prefix: {db_prefix}pm_*
DB version option: pm_db_version = 103
Tables (22)
| Table | Purpose |
|---|---|
| ------- | --------- |
pm_suppliers | Supplier master |
pm_supplier_contacts | Supplier contacts |
pm_supplier_attachments | Supplier files |
pm_purchase_requests | PR header |
pm_purchase_request_items | PR lines |
pm_rfqs | RFQ header |
pm_rfq_items | RFQ lines |
pm_supplier_quotations | Quotation header |
pm_supplier_quotation_items | Quotation lines |
pm_purchase_orders | PO header |
pm_purchase_order_items | PO lines |
pm_goods_receipts | GRN header |
pm_goods_receipt_items | GRN lines |
pm_supplier_bills | Bill header |
pm_supplier_bill_items | Bill lines |
pm_supplier_payments | Payment header |
pm_supplier_payment_allocations | Payment-to-bill splits (v101) |
pm_purchase_returns | Return header |
pm_purchase_return_items | Return lines |
pm_purchase_approvals | Approval header |
pm_purchase_approval_steps | Approval steps |
pm_purchase_logs | Audit log |
pm_purchase_settings | Module settings key/value |
pm_stock_movements | GRN stock movement log |
Foreign keys
Applied on install and migration 102 via pm_install_foreign_keys() for core parent/child tables. Failures are logged and skipped on restrictive hosts.
---
Developer reference
Key helpers (`helpers/purchase_management_helper.php`)
| Function | Purpose |
|---|---|
| ---------- | --------- |
pm_can() / pm_require_permission() | Permission checks |
pm_generate_number() | Document numbering |
pm_calculate_line_total() | Line math |
pm_resolve_po_billing_status() | PO billed vs partial logic |
pm_validate_catalog_item() | Manual item enforcement |
pm_validate_grn_warehouse() | Warehouse rules |
pm_get_configured_approvers() | Approval chain |
pm_can_act_on_approval_step() | Approval authorization |
pm_handle_upload() | Secure uploads |
pm_log() | Audit trail + activity log |
Libraries
Pm_pdf— TCPDF document generationPm_export— CSV/Excel/PDF report export
Migrations
Add new file migrations/XXX_version_XXX.php with function pm_run_migration_XXX($CI), register in pm_maybe_upgrade_database().
Tests
tests/
├── bootstrap.php # CI stubs, loads helper
├── LogicTest.php # 26 helper/security tests
├── PaymentLogicTest.php # 14 payment/billing tests
├── ExtensionTest.php # 12 API/role/cancel tests
├── IntegrationTest.php # Optional live DB verification
└── run_all.php
Hooks (module file)
| Hook | Function |
|---|---|
| ------ | ---------- |
admin_init | Menu + permissions + DB upgrade |
get_dashboard_widgets | Dashboard widget |
app_admin_head / app_admin_footer | Assets |
after_cron_run | Overdue bills |
---
Manual QA checklist (recommended)
Before go-live, verify:
- [ ] Activate module; confirm
pm_db_version= 101 - [ ] Role permissions assigned for each team
- [ ] Settings: prefixes, approvers, feature toggles
- [ ] Full cycle: PR → PO → GRN → Bill → Payment (partial + full bill)
- [ ] Multi-bill payment allocation and void
- [ ] Approval approve/reject on PR, PO, Bill
- [ ] Report CSV/Excel/PDF export
- [ ] RFQ send email + PDF download
- [ ] Supplier CSV/Excel export
- [ ] Cron marks overdue bills
- [ ] Run
php modules/purchase_management/tests/run_all.php
---
Nasbix Technologies — Purchase Management v1.1.0
Extended module documentation
Table of contents
- [Overview](#overview)
- [Menu & navigation](#menu--navigation)
- [Document workflow](#document-workflow)
- [Module settings](#module-settings)
- [Approvals](#approvals)
- [Payments & allocations](#payments--allocations)
- [Reports & exports](#reports--exports)
- [PDF documents](#pdf-documents)
- [Integrations](#integrations)
- [Security](#security)
- [Cron & automation](#cron--automation)
- [Database schema](#database-schema)
- [Developer reference](#developer-reference)
---
Overview
Purchase Management covers the full procure-to-pay cycle inside BIXCRM admin:
| Phase | Document | Purpose |
|---|---|---|
| ------- | ---------- | --------- |
| 1 | Suppliers | Vendor master data |
| 2 | Purchase Request (PR) | Internal requisition |
| 3 | RFQ | Request quotations from suppliers |
| 4 | Purchase Order (PO) | Commitment to supplier |
| 5 | GRN | Goods received note |
| 6 | Supplier Bill | Accounts payable invoice |
| 7 | Payment | Pay supplier (multi-bill split) |
| 8 | Return | Return goods to supplier |
All 17 implementation phases (foundation through testing) are complete. Post-phase polish (RFQ PDF, partial PO billing, supplier Excel export, deactivation logging) is also complete.
---
Menu & navigation
Admin path: Purchase Management (sidebar)
| Menu item | URL segment | Permission |
|---|---|---|
| ----------- | ------------- | ------------ |
| Dashboard | purchase_management | purchase_dashboard → view |
| Suppliers | .../suppliers | purchase_suppliers |
| Purchase Requests | .../requests | purchase_request |
| RFQ & Quotations | .../rfqs | purchase_rfq |
| Purchase Orders | .../orders | purchase_order |
| Goods Receipt | .../grn | purchase_grn |
| Supplier Bills | .../bills | purchase_bill |
| Payments | .../payments | purchase_payment |
| Returns | .../returns | purchase_return |
| Approvals | .../approvals | dashboard view or approve caps |
| Reports | .../reports | purchase_reports |
| Settings | .../settings | purchase_settings |
Routes are defined in config/routes.php.
---
Document workflow
Purchase request (PR)
Statuses: draft → submitted → pending_approval → approved / rejected → converted / cancelled
- Create PR with line items (catalog items or manual lines if
pm_allow_manual_itemsis enabled). - Upload attachments on the PR view page.
- Submit for approval (when
pm_require_approvalis on and amount exceeds limit). - Approved PR can be converted to PO or used as source for RFQ.
Actions on view: Edit (draft/rejected), Submit, Approve/Reject (inbox), Cancel, Convert to PO.
RFQ
Statuses: draft → sent → closed / cancelled
- Create RFQ manually or link from an approved PR.
- Add invited suppliers and line items (qty, UOM, specifications).
- Send — emails suppliers with quotation link (no PDF attachment; see [ROADMAP.md](ROADMAP.md)).
- Enter supplier quotations; use Compare to evaluate; Award winning quotation.
- Download PDF from list or view page.
Feature toggle: pm_enable_rfq in settings.
Purchase order (PO)
Statuses: draft → pending_approval → approved → sent → partially_received / fully_received → billed → closed / cancelled
- Create from PR, RFQ award, or directly (if
pm_allow_po_without_pr). - Set supplier, lines, tax, shipping, payment terms.
- Approve and Send — email includes PO PDF attachment.
- Create GRN against PO as goods arrive.
- PO billing status:
- Partial bill: PO stays at partially_received or fully_received.
- Full bill: All line billed_qty ≥ line quantity → status becomes billed.
GRN (Goods receipt)
Statuses: draft → posted / cancelled
- Select PO and received quantities per line.
- Warehouse field behaviour depends on
pm_warehouse_integration:
- auto — optional warehouse
- required — warehouse mandatory
- disabled — no warehouse validation; no stock sync
- Posting updates PO received quantities and may sync inventory (Inventory Management module).
Supplier bill
Statuses: draft → pending_approval → approved → partially_paid / paid / overdue / cancelled
- Create from PO (pulls unbilled quantities) or manually.
- Three-way match checks PO price/qty vs GRN received qty (unless
pm_allow_bill_without_grn). - On approval, PO line
billed_qtyincreases; PO billing status refreshes automatically. - Download bill PDF from list or document view.
Payment
- Record payment against one or more approved bills (allocation UI).
- On-account payments (no bill allocation) supported.
- Void reverses all allocations and restores bill balances/status.
- Payment receipt PDF available.
Database: allocations stored in pm_supplier_payment_allocations (migration 101).
Return
Statuses: draft → pending_approval → approved → posted / cancelled
Create return against GRN/bill context. Approval workflow and PDF export supported.
Feature toggle: pm_enable_returns.
---
Module settings
Path: Purchase Management → Settings
Prefix & numbering
| Setting | Default | Purpose |
|---|---|---|
| --------- | --------- | --------- |
pm_supplier_code_prefix | SUP- | Supplier code |
pm_pr_prefix | PR- | Purchase request |
pm_rfq_prefix | RFQ- | RFQ |
pm_po_prefix | PO- | Purchase order |
pm_grn_prefix | GRN- | Goods receipt |
pm_bill_prefix | BILL- | Supplier bill |
pm_payment_prefix | PAY- | Payment |
pm_return_prefix | PRN- | Return |
pm_number_padding | 6 | Numeric padding |
General
| Setting | Description |
|---|---|
| --------- | ------------- |
pm_default_currency | Default document currency |
pm_default_payment_terms | e.g. Net 30 |
pm_default_tax | Default tax name for lines |
pm_required_supplier_fields | Comma-separated required fields |
pm_warehouse_integration | auto / required / disabled |
pm_terms_conditions | Default PO terms |
pm_pdf_footer | Footer text on all module PDFs |
Approval
| Setting | Description |
|---|---|
| --------- | ------------- |
pm_require_approval | Enable approval workflows |
pm_approval_amount_limit | Amount threshold |
pm_approval_level1_staff | Level 1 approver (staff ID) |
pm_approval_level2_staff | Level 2 approver |
pm_approval_level3_staff | Level 3 approver |
pm_approval_routing_mode | staff or role |
pm_approval_level1_role | Level 1 BIXCRM role (when mode = role) |
pm_approval_level2_role | Level 2 BIXCRM role |
pm_approval_level3_role | Level 3 BIXCRM role |
When role mode is selected, any active staff member with the configured BIXCRM role can approve that step from the inbox.
API & webhooks
| Setting | Description |
|---|---|
| --------- | ------------- |
pm_api_enabled | Enable REST API |
pm_api_key | API authentication key |
pm_webhook_url | Webhook receiver URL |
pm_webhook_secret | HMAC signing secret |
Feature toggles
| Setting | Default | Description |
|---|---|---|
| --------- | --------- | ------------- |
pm_enable_purchase_requests | 1 | PR module |
pm_enable_rfq | 1 | RFQ module |
pm_enable_returns | 1 | Returns module |
pm_allow_manual_items | 1 | Free-text line items |
pm_allow_po_without_pr | 1 | Direct PO creation |
pm_allow_bill_without_grn | 0 | Skip GRN qty check on bills |
---
Approvals
Supported document types
- Purchase request (
purchase_request) - Purchase order (
purchase_order) - Supplier bill (
purchase_bill) - Purchase return (
purchase_return)
Inbox
Purchase Management → Approvals lists pending steps assigned to the current user.
Rules
- Assigned approver must hold the document's
approvepermission. - Generic admin bypass is disabled — only assigned approver or settings manager (
purchase_settings→ manage) on unassigned steps may act. - Delegation:
pm_delegate_approval_action()keeps document status in sync withApproval_model.
`approver_role` column
The pm_purchase_approval_steps.approver_role field stores role hints (manager, admin, staff) when fallback approvers are used. Settings UI assigns staff IDs, not roles. Role-based routing is partially implemented — see [ROADMAP.md](ROADMAP.md).
---
Payments & allocations
Recording a payment
- Open Payments → New payment.
- Select supplier and payment amount/method/date.
- Allocate amounts to one or more open bills (AJAX loads bill balances).
- Save — allocations inserted into
pm_supplier_payment_allocations; billpaid_amountand status updated.
Void
Voiding a payment:
- Deletes all allocation rows for that payment
- Reverses
paid_amounton each affected bill - Restores bill status (
unpaid,partially_paid, oroverdueif past due)
On-account
Payment with zero allocations is stored as supplier on-account credit (no bill linkage).
---
Reports & exports
Path: Purchase Management → Reports
| Report key | Name |
|---|---|
| ------------ | ------ |
supplier_statement | Supplier statement |
supplier_ledger | Supplier ledger |
po | Purchase orders |
grn | Goods receipts |
pending_receiving | Pending receiving |
bills | Supplier bills |
payments | Payments |
returns | Returns |
by_item | Purchases by item |
by_supplier | Purchases by supplier |
tax | Tax summary |
aging | AP aging |
approval_history | Approval history |
Export formats: CSV, Excel (.xls), PDF — via Pm_export library.
Suppliers list: CSV and Excel export from Suppliers → Export buttons.
Export endpoints use pm_export_rate_limit() to reduce abuse.
---
PDF documents
Generated via libraries/Pm_pdf.php (TCPDF + module view templates).
| Document | Template | Controller action |
|---|---|---|
| ---------- | ---------- | ------------------- |
| Purchase order | views/orders/pdf.php | orders/pdf/{id} |
| GRN | views/grn/pdf.php | grn/pdf/{id} |
| Supplier bill | views/bills/pdf.php | bills/pdf/{id} |
| Payment receipt | views/payments/pdf.php | payments/pdf/{id} |
| Return | views/returns/pdf.php | returns/pdf/{id} |
| Purchase request | views/requests/pdf.php | requests/pdf/{id} |
| RFQ | views/rfqs/pdf.php | rfqs/pdf/{id} |
| Supplier statement | views/suppliers/statement_pdf.php | via supplier view |
PO email send attaches PDF via Pm_pdf::save_purchase_order_file().
Optional query: ?output_type=I (inline) or D (download, default).
---
Integrations
Inventory Management
When pm_warehouse_integration is not disabled and the Inventory Management module is active:
- GRN post creates stock movements
- GRN cancel reverses movements
Setting: Settings → Warehouse integration.
BIXCRM items & taxes
Line items can reference BIXCRM catalog items (pm_get_items()). Tax rates resolve via pm_resolve_line_tax_rate() and BIXCRM tax settings.
RFQ send and PO send use pm_send_email(). Both include PDF attachments when sending.
---
REST API & webhooks
Configure under Settings → API & Webhooks.
| Setting | Purpose |
|---|---|
| --------- | --------- |
pm_api_enabled | Enable read-only REST API |
pm_api_key | Send as header X-PM-API-Key |
pm_webhook_url | Outbound webhook endpoint |
pm_webhook_secret | HMAC SHA256 signature in X-PM-Signature |
API endpoints
| Method | URL | Description |
|---|---|---|
| -------- | ----- | ------------- |
| GET | /purchase_management/api | API info |
| GET | /purchase_management/api/suppliers | Supplier list |
| GET | /purchase_management/api/purchase_orders/{id} | PO + lines |
| GET | /purchase_management/api/supplier_bills/{id} | Bill + lines |
| GET | /purchase_management/api/payments/{id} | Payment + allocations |
Webhook events
| Event | When |
|---|---|
| ------- | ------ |
rfq.sent | RFQ emailed to suppliers |
supplier_bill.approved | Bill approved |
supplier_bill.cancelled | Approved bill cancelled |
supplier_payment.recorded | Payment saved |
supplier_payment.voided | Payment voided |
---
Security
Implemented in Phase 15:
| Control | Implementation |
|---|---|
| --------- | ---------------- |
| POST-only destructive actions | pm_require_post(), pm_require_post_or_ajax() on delete/void/approve/reject/cancel/submit/send/post |
| CSRF on delete links | assets/js/purchase_management.js converts _delete links to POST with token |
| Upload validation | MIME check + pm_get_allowed_attachment_rel_types() whitelist |
| Approval integrity | pm_can_act_on_approval_step() — no admin bypass |
| Export throttling | pm_export_rate_limit() on reports and supplier export |
---
Cron & automation
Hook: after_cron_run → purchase_management_cron_tasks()
- Overdue bills:
Supplier_bill_model::check_overdue_bills()marks approved unpaid bills past due date asoverdue.
Ensure BIXCRM cron is configured and running.
---
Database schema
Prefix: {db_prefix}pm_*
DB version option: pm_db_version = 103
Tables (22)
| Table | Purpose |
|---|---|
| ------- | --------- |
pm_suppliers | Supplier master |
pm_supplier_contacts | Supplier contacts |
pm_supplier_attachments | Supplier files |
pm_purchase_requests | PR header |
pm_purchase_request_items | PR lines |
pm_rfqs | RFQ header |
pm_rfq_items | RFQ lines |
pm_supplier_quotations | Quotation header |
pm_supplier_quotation_items | Quotation lines |
pm_purchase_orders | PO header |
pm_purchase_order_items | PO lines |
pm_goods_receipts | GRN header |
pm_goods_receipt_items | GRN lines |
pm_supplier_bills | Bill header |
pm_supplier_bill_items | Bill lines |
pm_supplier_payments | Payment header |
pm_supplier_payment_allocations | Payment-to-bill splits (v101) |
pm_purchase_returns | Return header |
pm_purchase_return_items | Return lines |
pm_purchase_approvals | Approval header |
pm_purchase_approval_steps | Approval steps |
pm_purchase_logs | Audit log |
pm_purchase_settings | Module settings key/value |
pm_stock_movements | GRN stock movement log |
Foreign keys
Applied on install and migration 102 via pm_install_foreign_keys() for core parent/child tables. Failures are logged and skipped on restrictive hosts.
---
Developer reference
Key helpers (`helpers/purchase_management_helper.php`)
| Function | Purpose |
|---|---|
| ---------- | --------- |
pm_can() / pm_require_permission() | Permission checks |
pm_generate_number() | Document numbering |
pm_calculate_line_total() | Line math |
pm_resolve_po_billing_status() | PO billed vs partial logic |
pm_validate_catalog_item() | Manual item enforcement |
pm_validate_grn_warehouse() | Warehouse rules |
pm_get_configured_approvers() | Approval chain |
pm_can_act_on_approval_step() | Approval authorization |
pm_handle_upload() | Secure uploads |
pm_log() | Audit trail + activity log |
Libraries
Pm_pdf— TCPDF document generationPm_export— CSV/Excel/PDF report export
Migrations
Add new file migrations/XXX_version_XXX.php with function pm_run_migration_XXX($CI), register in pm_maybe_upgrade_database().
Tests
tests/
├── bootstrap.php # CI stubs, loads helper
├── LogicTest.php # 26 helper/security tests
├── PaymentLogicTest.php # 14 payment/billing tests
├── ExtensionTest.php # 12 API/role/cancel tests
├── IntegrationTest.php # Optional live DB verification
└── run_all.php
Hooks (module file)
| Hook | Function |
|---|---|
| ------ | ---------- |
admin_init | Menu + permissions + DB upgrade |
get_dashboard_widgets | Dashboard widget |
app_admin_head / app_admin_footer | Assets |
after_cron_run | Overdue bills |
---
Manual QA checklist (recommended)
Before go-live, verify:
- [ ] Activate module; confirm
pm_db_version= 101 - [ ] Role permissions assigned for each team
- [ ] Settings: prefixes, approvers, feature toggles
- [ ] Full cycle: PR → PO → GRN → Bill → Payment (partial + full bill)
- [ ] Multi-bill payment allocation and void
- [ ] Approval approve/reject on PR, PO, Bill
- [ ] Report CSV/Excel/PDF export
- [ ] RFQ send email + PDF download
- [ ] Supplier CSV/Excel export
- [ ] Cron marks overdue bills
- [ ] Run
php modules/purchase_management/tests/run_all.php
---
Nasbix Technologies — Purchase Management v1.1.0
Requirements
| Component | Minimum |
|---|---|
| BIXCRM | 2.3.0+ (tested on 3.x) |
| PHP | 7.4+ (recommended 8.1+) |
| MySQL / MariaDB | 5.7+ / 10.3+ |
| PHP extensions | mysqli, json, mbstring, curl |
| BIXCRM cron | Required for overdue bill checks |
Optional modules: Inventory Management (GRN stock sync), Accounting Pro (AP/GL sync), Supplier Portal (supplier linking).
Zero core modifications
Procure-to-Pay Workflow
PR (optional) → RFQ (optional) → PO → GRN → Supplier Bill → Payment
↘ Return (optional)
Document statuses
- PR / PO / Bill / Return: draft → pending approval → approved → (completed/cancelled)
- RFQ: draft → sent → quotations_received → awarded / cancelled
- GRN: draft → posted / cancelled
On create/edit forms, use Save Draft or the primary action button (Submit for Approval, Send, Post GRN) to save and trigger the workflow in one step.
Permissions
11 permission groups under Setup → Staff → Permissions → Purchase Management. Admins bypass all checks.
| Feature | Capabilities |
|---|---|
| Dashboard | view |
| Suppliers | view, create, edit, delete |
| Purchase Requests | view, create, edit, delete, approve |
| RFQ | view, create, edit, delete |
| Purchase Orders | view, create, edit, delete, approve |
| GRN | view, create, edit, delete |
| Supplier Bills | view, create, edit, delete, approve |
| Payments | view, create, edit, delete |
| Returns | view, create, edit, delete, approve |
| Reports | view, export |
| Settings | view, edit, manage |
Key Settings
| Setting | Description |
|---|---|
| Feature toggles | Enable/disable PR, RFQ, returns |
| Approval routing | Staff-based or role-based multi-level approvers |
| Warehouse integration | auto / required / disabled for GRN |
| REST API | Enable + API key (read-only endpoints) |
| Webhooks | Independent toggle + HTTPS endpoint URL + HMAC secret |
REST API
Read-only API. Enable in Settings, then send header X-PM-API-Key: your-key.
GET /purchase_management/api/suppliers
GET /purchase_management/api/purchase_orders/{id}
GET /purchase_management/api/supplier_bills/{id}
GET /purchase_management/api/payments/{id}
Rate limited (default 60 requests/minute). Returns JSON.
Outbound Webhooks
Enable webhooks separately from the API. Configure a public HTTPS endpoint URL and optional HMAC secret.
Events: rfq.sent, supplier_bill.approved, supplier_bill.cancelled, supplier_payment.recorded, supplier_payment.voided
Payload includes event, timestamp, and payload. Signature in X-PM-Signature header when secret is set.
Module Integrations
- Inventory Management — GRN posting increases stock; cancellation reverses
- Accounting Pro — Approved bills and payments sync to accounts payable
- Supplier Portal — Link PM suppliers to portal accounts (admin-side)
FAQ
Do I need to edit BIXCRM core files?
No. The module is fully self-contained under /modules/purchase_management/.
How do RFQ supplier invitations work?
Select invited suppliers when creating an RFQ. On send, only invited suppliers receive the email (with PDF). If none selected, all active suppliers with email addresses are notified. Quotations are entered by staff in the admin panel.
Can suppliers submit quotations online?
Staff enter quotations in admin. External supplier self-service is planned for the optional Supplier Portal module.
After activation — configuration checklist
- Go to Setup → Modules and click Activate.
- Open any Purchase menu — migrations run automatically (DB v103).
- Configure Purchase Management → Settings.
- Optional: click Load Demo Data in Settings to seed sample records.
- Assign permissions under Setup → Staff → Permissions.
One-time setup (first time only)
- Setup → Modules → activate Purchase Management.
- Setup → Staff → Roles → assign Purchase Management permissions (view, create, edit, delete, approve, export, settings as needed).
- Open Purchase 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 BIXCRM cron (
php /path/to/bixcrm/index.php cron/index) for sync, retries, alerts, and scheduled jobs. - Optionally enable REST API / webhooks in module settings if you integrate external systems.
BIXCRM Knowledge Base — usage guide generated from module README and documentation.