Purchase Management — Overview & How to Use

Module: Purchase Management v1.0.0

What is Purchase Management?

Enterprise purchase and procurement management for Perfex CRM

This module installs into modules/purchase_management/ 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

  1. Read How to Install and activate the module.
  2. Skim Features so you know what screens exist.
  3. Complete the Quick Start checklist on this page (Settings → masters → first sample record).
  4. Open each screen guide under Screen-by-screen guides when you need step-by-step help.
  5. 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 Purchase Management:

  1. Activate — Setup → Modules → activate Purchase Management (run Upgrade if prompted).
  2. Permissions — Setup → Staff → Roles → enable view/create/edit (and approve/settings if needed) for this module.
  3. Settings — Open Purchase Management → Settings and save company defaults, prefixes, and integrations.
  4. Master data — Create the first required masters (products, warehouses, templates, channels, accounts, routes, etc.).
  5. First transaction — Create one sample record end-to-end (save → submit/approve → complete) and confirm it appears in lists/reports.
  6. Cron — If the module uses alerts, sync, queues, or AI, confirm Perfex CRM cron is scheduled on the server.

Full how-to guide (from module package)

The steps below come from the module author's printable guide — follow them in order for best results.

HOW TO USE — Purchase Management v1.0.0

Author: Nasbix Technologies (https://nasbix.com)

For Perfex CRM 2.3+ (3.x recommended)

1. INSTALLATION

  1. Upload the "purchase_management" folder into your Perfex CRM /modules/ directory

(FTP / cPanel / Setup → Modules → Upload).

  1. Log in as administrator.
  2. Go to Setup → Modules.
  3. Find "Purchase Management" and click Activate.

5. On activate the module:

- Creates all pm_* database tables

- Adds default settings (prefixes, approvals, API key, etc.)

- Sets installed version to 1.0.0 / DB schema 100

2. ASSIGN PERMISSIONS

  1. Go to Setup → Staff → Roles (or edit a staff member).

2. Under permissions, enable the Purchase Management features your team needs:

- Dashboard, Suppliers, Purchase Requests, RFQ, Purchase Orders

- GRN, Supplier Bills, Payments, Returns, Reports, Settings

  1. Admins have full access automatically.

3. CONFIGURE SETTINGS

Path: Purchase Management → Settings

(or Setup → Modules → Purchase Management → Settings link)

Recommended first setup:

  • Document prefixes (SUP-, PR-, RFQ-, PO-, GRN-, BILL-, PAY-, PRN-)
  • Number padding
  • Default payment terms / tax
  • Enable or disable PR, RFQ, Returns
  • Approval routing: Staff-based OR Role-based (multi-level)
  • Warehouse integration mode: auto / required / disabled
  • Optional: REST API key + rate limit
  • Optional: Webhook URL + HMAC secret

Optional: click "Load Demo Data" to seed sample suppliers / PR / RFQ for testing.

4. TYPICAL WORKFLOW (PROCURE-TO-PAY)

1. Suppliers

- Create suppliers under Purchase Management → Suppliers

- Add contacts and attachments as needed

2. Purchase Request (optional)

- Create PR → Submit → Approve

- Convert approved PR to PO or RFQ

3. RFQ & Quotations (optional)

- Create RFQ, invite suppliers, send (email + PDF)

- Enter supplier quotations, compare, award

4. Purchase Order

- Create PO (from PR / RFQ / or standalone if allowed)

- Submit for approval → Approve → Send to supplier (email + PDF)

5. Goods Receipt (GRN)

- Receive against PO (partial or full)

- Post GRN (stock sync if Inventory Management is installed)

6. Supplier Bill

- Create bill from PO / GRN

- Three-way match → Approve

7. Payment

- Record payment (single bill or multi-bill allocation)

- Void reverses allocations if needed

8. Return (optional)

- Create purchase return → Approve → Complete

Approvals inbox: Purchase Management → Approvals

5. REPORTS

Purchase Management → Reports

Export CSV / Excel / PDF where available (requires export permission).

6. REST API & WEBHOOKS (OPTIONAL)

Enable in Settings:

  • REST API: send header X-PM-API-Key

Example: GET /purchase_management/api/suppliers

  • Webhooks: enable separately, set public HTTPS URL + optional secret

Signature header: X-PM-Signature (when secret is set)

7. UNINSTALL (REMOVES ALL MODULE DATA)

1. Setup → Modules → Purchase Management → Deactivate

2. Click Uninstall

3. This permanently removes:

- All pm_* database tables

- All pm_* options

- uploads/purchase_management/ files

Backup your database before uninstalling if you need to keep purchase data.

8. DOCUMENTATION

  • documentation/index.html (buyer-friendly HTML docs)
  • docs/DOCUMENTATION.md (developer / admin reference)
  • README.md (overview)
  • CHANGELOG.md (version history)

9. SUPPORT

Nasbix Technologies — 6 months support via CodeCanyon item comments.

Please include: purchase code, Perfex CRM version, PHP version, module version 1.0.0.

Perfex CRM is sold separately and is not included with this item.

Setup & usage notes from README

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.

---

Module documentation index

Start here — full guides for Purchase Management:

Screen-by-screen guides (each tab explained)

Click a menu item below for step-by-step instructions on that Purchase Management screen:

How to use in Perfex CRM (daily operations)

  1. Sign in to the admin area with a role that includes Purchase Management permissions.
  2. Open Purchase Management (sidebar) or search for Purchase Management in the admin menu.
  3. Start on the Dashboard (if available) to see open tasks, pending approvals, and KPIs.
  4. Review Settings after upgrades — new options may need defaults for your company.
  5. Create or import master data first; most modules block transactions until masters exist.
  6. Run the main business flow (create → submit → approve → post/complete) using the screens listed in Admin menu below.
  7. Use Reports / Analytics screens to reconcile stock, finance, compliance, or SLA metrics.
  8. For integrations (API, EDI, gateways, tax), confirm credentials in Settings and monitor logs or webhook delivery screens.
  9. Train staff with role-based access — give approvers approve permissions only, operators create/edit on their area.
  10. 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 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

Screens map — what each menu is for

These are the admin screens registered by Purchase Management. Click a name in the Knowledge Base for a full how-to, or open the path in admin.

#ScreenAdmin pathGuide
1Dashboardadmin/purchase_managementHow to use
2Suppliersadmin/purchase_management/purchase_management_suppliersHow to use
3Purchase Requestsadmin/purchase_management/purchase_management_requestsHow to use
4RFQ / Quotationsadmin/purchase_management/purchase_management_rfqsHow to use
5Purchase Ordersadmin/purchase_management/purchase_management_ordersHow to use
6Goods Receiptadmin/purchase_management/purchase_management_grnHow to use
7Supplier Billsadmin/purchase_management/purchase_management_billsHow to use
8Paymentsadmin/purchase_management/purchase_management_paymentsHow to use
9Returnsadmin/purchase_management/purchase_management_returnsHow to use
10Approvalsadmin/purchase_management/purchase_management_approvalsHow to use
11Reportsadmin/purchase_management/purchase_management_reportsHow to use
12Settingsadmin/purchase_management/purchase_management_settingsHow to use

Detailed guide — features, workflows, API & FAQ

Status

AreaStatus
--------------
Core procurement workflow (PR → RFQ → PO → GRN → Bill → Payment → Return)Complete
Approvals, dashboard, reports, settingsComplete
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 billed only 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_type validation
  • Export rate limiting
  • No generic admin bypass on assigned approval steps

---

Requirements

RequirementNotes
--------------------
Perfex CRM2.3.x or later
PHP7.4+ (8.x supported)
MySQL / MariaDBInnoDB
TCPDFBundled with Perfex CRM (application/vendor/tecnickcom/tcpdf)
Perfex CRM cronRecommended — overdue bill checks
Inventory ManagementOptional — GRN warehouse stock sync

---

Permissions

Feature keyCapabilities
---------------------------
purchase_dashboardview
purchase_suppliersview, create, edit, delete
purchase_requestview, create, edit, delete, approve
purchase_rfqview, create, edit, delete
purchase_orderview, create, edit, delete, approve
purchase_grnview, create, edit, delete
purchase_billview, create, edit, delete, approve
purchase_paymentview, create, edit, delete
purchase_returnview, create, edit, delete, approve
purchase_reportsview, export
purchase_settingsview, 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

DocumentDescription
-----------------------
[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

  1. [Overview](#overview)
  2. [Menu & navigation](#menu--navigation)
  3. [Document workflow](#document-workflow)
  4. [Module settings](#module-settings)
  5. [Approvals](#approvals)
  6. [Payments & allocations](#payments--allocations)
  7. [Reports & exports](#reports--exports)
  8. [PDF documents](#pdf-documents)
  9. [Integrations](#integrations)
  10. [Security](#security)
  11. [Cron & automation](#cron--automation)
  12. [Database schema](#database-schema)
  13. [Developer reference](#developer-reference)

---

Overview

Purchase Management covers the full procure-to-pay cycle inside Perfex CRM admin:

PhaseDocumentPurpose
--------------------------
1SuppliersVendor master data
2Purchase Request (PR)Internal requisition
3RFQRequest quotations from suppliers
4Purchase Order (PO)Commitment to supplier
5GRNGoods received note
6Supplier BillAccounts payable invoice
7PaymentPay supplier (multi-bill split)
8ReturnReturn 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 itemURL segmentPermission
------------------------------------
Dashboardpurchase_managementpurchase_dashboard → view
Suppliers.../supplierspurchase_suppliers
Purchase Requests.../requestspurchase_request
RFQ & Quotations.../rfqspurchase_rfq
Purchase Orders.../orderspurchase_order
Goods Receipt.../grnpurchase_grn
Supplier Bills.../billspurchase_bill
Payments.../paymentspurchase_payment
Returns.../returnspurchase_return
Approvals.../approvalsdashboard view or approve caps
Reports.../reportspurchase_reports
Settings.../settingspurchase_settings

Routes are defined in config/routes.php.

---

Document workflow

Purchase request (PR)

Statuses: draft → submitted → pending_approval → approved / rejected → converted / cancelled

  1. Create PR with line items (catalog items or manual lines if pm_allow_manual_items is enabled).
  2. Upload attachments on the PR view page.
  3. Submit for approval (when pm_require_approval is on and amount exceeds limit).
  4. 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

  1. Create RFQ manually or link from an approved PR.
  2. Add invited suppliers and line items (qty, UOM, specifications).
  3. Send — emails suppliers with quotation link (no PDF attachment; see [ROADMAP.md](ROADMAP.md)).
  4. Enter supplier quotations; use Compare to evaluate; Award winning quotation.
  5. 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

  1. Create from PR, RFQ award, or directly (if pm_allow_po_without_pr).
  2. Set supplier, lines, tax, shipping, payment terms.
  3. Approve and Send — email includes PO PDF attachment.
  4. Create GRN against PO as goods arrive.
  5. 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

  1. Select PO and received quantities per line.
  2. Warehouse field behaviour depends on pm_warehouse_integration:

- auto — optional warehouse

- required — warehouse mandatory

- disabled — no warehouse validation; no stock sync

  1. Posting updates PO received quantities and may sync inventory (Inventory Management module).

Supplier bill

Statuses: draft → pending_approval → approved → partially_paid / paid / overdue / cancelled

  1. Create from PO (pulls unbilled quantities) or manually.
  2. Three-way match checks PO price/qty vs GRN received qty (unless pm_allow_bill_without_grn).
  3. On approval, PO line billed_qty increases; PO billing status refreshes automatically.
  4. Download bill PDF from list or document view.

Payment

  1. Record payment against one or more approved bills (allocation UI).
  2. On-account payments (no bill allocation) supported.
  3. Void reverses all allocations and restores bill balances/status.
  4. 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

SettingDefaultPurpose
---------------------------
pm_supplier_code_prefixSUP-Supplier code
pm_pr_prefixPR-Purchase request
pm_rfq_prefixRFQ-RFQ
pm_po_prefixPO-Purchase order
pm_grn_prefixGRN-Goods receipt
pm_bill_prefixBILL-Supplier bill
pm_payment_prefixPAY-Payment
pm_return_prefixPRN-Return
pm_number_padding6Numeric padding

General

SettingDescription
----------------------
pm_default_currencyDefault document currency
pm_default_payment_termse.g. Net 30
pm_default_taxDefault tax name for lines
pm_required_supplier_fieldsComma-separated required fields
pm_warehouse_integrationauto / required / disabled
pm_terms_conditionsDefault PO terms
pm_pdf_footerFooter text on all module PDFs

Approval

SettingDescription
----------------------
pm_require_approvalEnable approval workflows
pm_approval_amount_limitAmount threshold
pm_approval_level1_staffLevel 1 approver (staff ID)
pm_approval_level2_staffLevel 2 approver
pm_approval_level3_staffLevel 3 approver
pm_approval_routing_modestaff or role
pm_approval_level1_roleLevel 1 Perfex CRM role (when mode = role)
pm_approval_level2_roleLevel 2 Perfex CRM role
pm_approval_level3_roleLevel 3 Perfex CRM role

When role mode is selected, any active staff member with the configured Perfex CRM role can approve that step from the inbox.

API & webhooks

SettingDescription
----------------------
pm_api_enabledEnable REST API
pm_api_keyAPI authentication key
pm_webhook_urlWebhook receiver URL
pm_webhook_secretHMAC signing secret

Feature toggles

SettingDefaultDescription
-------------------------------
pm_enable_purchase_requests1PR module
pm_enable_rfq1RFQ module
pm_enable_returns1Returns module
pm_allow_manual_items1Free-text line items
pm_allow_po_without_pr1Direct PO creation
pm_allow_bill_without_grn0Skip 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 approve permission.
  • 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 with Approval_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

  1. Open Payments → New payment.
  2. Select supplier and payment amount/method/date.
  3. Allocate amounts to one or more open bills (AJAX loads bill balances).
  4. Save — allocations inserted into pm_supplier_payment_allocations; bill paid_amount and status updated.

Void

Voiding a payment:

  • Deletes all allocation rows for that payment
  • Reverses paid_amount on each affected bill
  • Restores bill status (unpaid, partially_paid, or overdue if 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 keyName
------------------
supplier_statementSupplier statement
supplier_ledgerSupplier ledger
poPurchase orders
grnGoods receipts
pending_receivingPending receiving
billsSupplier bills
paymentsPayments
returnsReturns
by_itemPurchases by item
by_supplierPurchases by supplier
taxTax summary
agingAP aging
approval_historyApproval 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).

DocumentTemplateController action
---------------------------------------
Purchase orderviews/orders/pdf.phporders/pdf/{id}
GRNviews/grn/pdf.phpgrn/pdf/{id}
Supplier billviews/bills/pdf.phpbills/pdf/{id}
Payment receiptviews/payments/pdf.phppayments/pdf/{id}
Returnviews/returns/pdf.phpreturns/pdf/{id}
Purchase requestviews/requests/pdf.phprequests/pdf/{id}
RFQviews/rfqs/pdf.phprfqs/pdf/{id}
Supplier statementviews/suppliers/statement_pdf.phpvia 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.

Perfex CRM items & taxes

Line items can reference Perfex CRM catalog items (pm_get_items()). Tax rates resolve via pm_resolve_line_tax_rate() and Perfex CRM tax settings.

Email

RFQ send and PO send use pm_send_email(). Both include PDF attachments when sending.

---

REST API & webhooks

Configure under Settings → API & Webhooks.

SettingPurpose
------------------
pm_api_enabledEnable read-only REST API
pm_api_keySend as header X-PM-API-Key
pm_webhook_urlOutbound webhook endpoint
pm_webhook_secretHMAC SHA256 signature in X-PM-Signature

API endpoints

MethodURLDescription
--------------------------
GET/purchase_management/apiAPI info
GET/purchase_management/api/suppliersSupplier 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

EventWhen
-------------
rfq.sentRFQ emailed to suppliers
supplier_bill.approvedBill approved
supplier_bill.cancelledApproved bill cancelled
supplier_payment.recordedPayment saved
supplier_payment.voidedPayment voided

---

Security

Implemented in Phase 15:

ControlImplementation
-------------------------
POST-only destructive actionspm_require_post(), pm_require_post_or_ajax() on delete/void/approve/reject/cancel/submit/send/post
CSRF on delete linksassets/js/purchase_management.js converts _delete links to POST with token
Upload validationMIME check + pm_get_allowed_attachment_rel_types() whitelist
Approval integritypm_can_act_on_approval_step() — no admin bypass
Export throttlingpm_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 as overdue.

Ensure Perfex CRM cron is configured and running.

---

Database schema

Prefix: {db_prefix}pm_*

DB version option: pm_db_version = 100

Tables (25)

TablePurpose
----------------
pm_suppliersSupplier master
pm_supplier_contactsSupplier contacts
pm_supplier_attachmentsSupplier files
pm_purchase_requestsPR header
pm_purchase_request_itemsPR lines
pm_rfqsRFQ header
pm_rfq_itemsRFQ lines
pm_rfq_suppliersRFQ invited suppliers
pm_supplier_quotationsQuotation header
pm_supplier_quotation_itemsQuotation lines
pm_purchase_ordersPO header
pm_purchase_order_itemsPO lines
pm_goods_receiptsGRN header
pm_goods_receipt_itemsGRN lines
pm_supplier_billsBill header
pm_supplier_bill_itemsBill lines
pm_supplier_paymentsPayment header
pm_supplier_payment_allocationsPayment-to-bill splits
pm_purchase_returnsReturn header
pm_purchase_return_itemsReturn lines
pm_purchase_approvalsApproval header
pm_purchase_approval_stepsApproval steps
pm_purchase_logsAudit log
pm_purchase_settingsModule settings key/value
pm_stock_movementsGRN stock movement log

Foreign keys

Applied on install 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`)

FunctionPurpose
-------------------
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 generation
  • Pm_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)

HookFunction
----------------
admin_initMenu + permissions + DB upgrade
get_dashboard_widgetsDashboard widget
app_admin_head / app_admin_footerAssets
after_cron_runOverdue bills

---

Manual QA checklist (recommended)

Before go-live, verify:

  • [ ] Activate module; confirm pm_db_version = 100
  • [ ] 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.0.0

Extended module documentation

Table of contents

  1. [Overview](#overview)
  2. [Menu & navigation](#menu--navigation)
  3. [Document workflow](#document-workflow)
  4. [Module settings](#module-settings)
  5. [Approvals](#approvals)
  6. [Payments & allocations](#payments--allocations)
  7. [Reports & exports](#reports--exports)
  8. [PDF documents](#pdf-documents)
  9. [Integrations](#integrations)
  10. [Security](#security)
  11. [Cron & automation](#cron--automation)
  12. [Database schema](#database-schema)
  13. [Developer reference](#developer-reference)

---

Overview

Purchase Management covers the full procure-to-pay cycle inside Perfex CRM admin:

PhaseDocumentPurpose
--------------------------
1SuppliersVendor master data
2Purchase Request (PR)Internal requisition
3RFQRequest quotations from suppliers
4Purchase Order (PO)Commitment to supplier
5GRNGoods received note
6Supplier BillAccounts payable invoice
7PaymentPay supplier (multi-bill split)
8ReturnReturn 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 itemURL segmentPermission
------------------------------------
Dashboardpurchase_managementpurchase_dashboard → view
Suppliers.../supplierspurchase_suppliers
Purchase Requests.../requestspurchase_request
RFQ & Quotations.../rfqspurchase_rfq
Purchase Orders.../orderspurchase_order
Goods Receipt.../grnpurchase_grn
Supplier Bills.../billspurchase_bill
Payments.../paymentspurchase_payment
Returns.../returnspurchase_return
Approvals.../approvalsdashboard view or approve caps
Reports.../reportspurchase_reports
Settings.../settingspurchase_settings

Routes are defined in config/routes.php.

---

Document workflow

Purchase request (PR)

Statuses: draft → submitted → pending_approval → approved / rejected → converted / cancelled

  1. Create PR with line items (catalog items or manual lines if pm_allow_manual_items is enabled).
  2. Upload attachments on the PR view page.
  3. Submit for approval (when pm_require_approval is on and amount exceeds limit).
  4. 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

  1. Create RFQ manually or link from an approved PR.
  2. Add invited suppliers and line items (qty, UOM, specifications).
  3. Send — emails suppliers with quotation link (no PDF attachment; see [ROADMAP.md](ROADMAP.md)).
  4. Enter supplier quotations; use Compare to evaluate; Award winning quotation.
  5. 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

  1. Create from PR, RFQ award, or directly (if pm_allow_po_without_pr).
  2. Set supplier, lines, tax, shipping, payment terms.
  3. Approve and Send — email includes PO PDF attachment.
  4. Create GRN against PO as goods arrive.
  5. 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

  1. Select PO and received quantities per line.
  2. Warehouse field behaviour depends on pm_warehouse_integration:

- auto — optional warehouse

- required — warehouse mandatory

- disabled — no warehouse validation; no stock sync

  1. Posting updates PO received quantities and may sync inventory (Inventory Management module).

Supplier bill

Statuses: draft → pending_approval → approved → partially_paid / paid / overdue / cancelled

  1. Create from PO (pulls unbilled quantities) or manually.
  2. Three-way match checks PO price/qty vs GRN received qty (unless pm_allow_bill_without_grn).
  3. On approval, PO line billed_qty increases; PO billing status refreshes automatically.
  4. Download bill PDF from list or document view.

Payment

  1. Record payment against one or more approved bills (allocation UI).
  2. On-account payments (no bill allocation) supported.
  3. Void reverses all allocations and restores bill balances/status.
  4. 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

SettingDefaultPurpose
---------------------------
pm_supplier_code_prefixSUP-Supplier code
pm_pr_prefixPR-Purchase request
pm_rfq_prefixRFQ-RFQ
pm_po_prefixPO-Purchase order
pm_grn_prefixGRN-Goods receipt
pm_bill_prefixBILL-Supplier bill
pm_payment_prefixPAY-Payment
pm_return_prefixPRN-Return
pm_number_padding6Numeric padding

General

SettingDescription
----------------------
pm_default_currencyDefault document currency
pm_default_payment_termse.g. Net 30
pm_default_taxDefault tax name for lines
pm_required_supplier_fieldsComma-separated required fields
pm_warehouse_integrationauto / required / disabled
pm_terms_conditionsDefault PO terms
pm_pdf_footerFooter text on all module PDFs

Approval

SettingDescription
----------------------
pm_require_approvalEnable approval workflows
pm_approval_amount_limitAmount threshold
pm_approval_level1_staffLevel 1 approver (staff ID)
pm_approval_level2_staffLevel 2 approver
pm_approval_level3_staffLevel 3 approver
pm_approval_routing_modestaff or role
pm_approval_level1_roleLevel 1 Perfex CRM role (when mode = role)
pm_approval_level2_roleLevel 2 Perfex CRM role
pm_approval_level3_roleLevel 3 Perfex CRM role

When role mode is selected, any active staff member with the configured Perfex CRM role can approve that step from the inbox.

API & webhooks

SettingDescription
----------------------
pm_api_enabledEnable REST API
pm_api_keyAPI authentication key
pm_webhook_urlWebhook receiver URL
pm_webhook_secretHMAC signing secret

Feature toggles

SettingDefaultDescription
-------------------------------
pm_enable_purchase_requests1PR module
pm_enable_rfq1RFQ module
pm_enable_returns1Returns module
pm_allow_manual_items1Free-text line items
pm_allow_po_without_pr1Direct PO creation
pm_allow_bill_without_grn0Skip 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 approve permission.
  • 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 with Approval_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

  1. Open Payments → New payment.
  2. Select supplier and payment amount/method/date.
  3. Allocate amounts to one or more open bills (AJAX loads bill balances).
  4. Save — allocations inserted into pm_supplier_payment_allocations; bill paid_amount and status updated.

Void

Voiding a payment:

  • Deletes all allocation rows for that payment
  • Reverses paid_amount on each affected bill
  • Restores bill status (unpaid, partially_paid, or overdue if 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 keyName
------------------
supplier_statementSupplier statement
supplier_ledgerSupplier ledger
poPurchase orders
grnGoods receipts
pending_receivingPending receiving
billsSupplier bills
paymentsPayments
returnsReturns
by_itemPurchases by item
by_supplierPurchases by supplier
taxTax summary
agingAP aging
approval_historyApproval 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).

DocumentTemplateController action
---------------------------------------
Purchase orderviews/orders/pdf.phporders/pdf/{id}
GRNviews/grn/pdf.phpgrn/pdf/{id}
Supplier billviews/bills/pdf.phpbills/pdf/{id}
Payment receiptviews/payments/pdf.phppayments/pdf/{id}
Returnviews/returns/pdf.phpreturns/pdf/{id}
Purchase requestviews/requests/pdf.phprequests/pdf/{id}
RFQviews/rfqs/pdf.phprfqs/pdf/{id}
Supplier statementviews/suppliers/statement_pdf.phpvia 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.

Perfex CRM items & taxes

Line items can reference Perfex CRM catalog items (pm_get_items()). Tax rates resolve via pm_resolve_line_tax_rate() and Perfex CRM tax settings.

Email

RFQ send and PO send use pm_send_email(). Both include PDF attachments when sending.

---

REST API & webhooks

Configure under Settings → API & Webhooks.

SettingPurpose
------------------
pm_api_enabledEnable read-only REST API
pm_api_keySend as header X-PM-API-Key
pm_webhook_urlOutbound webhook endpoint
pm_webhook_secretHMAC SHA256 signature in X-PM-Signature

API endpoints

MethodURLDescription
--------------------------
GET/purchase_management/apiAPI info
GET/purchase_management/api/suppliersSupplier 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

EventWhen
-------------
rfq.sentRFQ emailed to suppliers
supplier_bill.approvedBill approved
supplier_bill.cancelledApproved bill cancelled
supplier_payment.recordedPayment saved
supplier_payment.voidedPayment voided

---

Security

Implemented in Phase 15:

ControlImplementation
-------------------------
POST-only destructive actionspm_require_post(), pm_require_post_or_ajax() on delete/void/approve/reject/cancel/submit/send/post
CSRF on delete linksassets/js/purchase_management.js converts _delete links to POST with token
Upload validationMIME check + pm_get_allowed_attachment_rel_types() whitelist
Approval integritypm_can_act_on_approval_step() — no admin bypass
Export throttlingpm_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 as overdue.

Ensure Perfex CRM cron is configured and running.

---

Database schema

Prefix: {db_prefix}pm_*

DB version option: pm_db_version = 100

Tables (25)

TablePurpose
----------------
pm_suppliersSupplier master
pm_supplier_contactsSupplier contacts
pm_supplier_attachmentsSupplier files
pm_purchase_requestsPR header
pm_purchase_request_itemsPR lines
pm_rfqsRFQ header
pm_rfq_itemsRFQ lines
pm_rfq_suppliersRFQ invited suppliers
pm_supplier_quotationsQuotation header
pm_supplier_quotation_itemsQuotation lines
pm_purchase_ordersPO header
pm_purchase_order_itemsPO lines
pm_goods_receiptsGRN header
pm_goods_receipt_itemsGRN lines
pm_supplier_billsBill header
pm_supplier_bill_itemsBill lines
pm_supplier_paymentsPayment header
pm_supplier_payment_allocationsPayment-to-bill splits
pm_purchase_returnsReturn header
pm_purchase_return_itemsReturn lines
pm_purchase_approvalsApproval header
pm_purchase_approval_stepsApproval steps
pm_purchase_logsAudit log
pm_purchase_settingsModule settings key/value
pm_stock_movementsGRN stock movement log

Foreign keys

Applied on install 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`)

FunctionPurpose
-------------------
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 generation
  • Pm_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)

HookFunction
----------------
admin_initMenu + permissions + DB upgrade
get_dashboard_widgetsDashboard widget
app_admin_head / app_admin_footerAssets
after_cron_runOverdue bills

---

Manual QA checklist (recommended)

Before go-live, verify:

  • [ ] Activate module; confirm pm_db_version = 100
  • [ ] 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.0.0

Requirements

ComponentMinimum
Perfex CRM2.3.0+ (tested on 3.x)
PHP7.4+ (recommended 8.1+)
MySQL / MariaDB5.7+ / 10.3+
PHP extensionsmysqli, json, mbstring, curl
Perfex CRM cronRequired 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.

FeatureCapabilities
Dashboardview
Suppliersview, create, edit, delete
Purchase Requestsview, create, edit, delete, approve
RFQview, create, edit, delete
Purchase Ordersview, create, edit, delete, approve
GRNview, create, edit, delete
Supplier Billsview, create, edit, delete, approve
Paymentsview, create, edit, delete
Returnsview, create, edit, delete, approve
Reportsview, export
Settingsview, edit, manage

Key Settings

SettingDescription
Feature togglesEnable/disable PR, RFQ, returns
Approval routingStaff-based or role-based multi-level approvers
Warehouse integrationauto / required / disabled for GRN
REST APIEnable + API key (read-only endpoints)
WebhooksIndependent 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 Perfex CRM core files?

No. The module is fully self-contained under /modules/purchase_management/.

What happens when I uninstall?

Uninstall drops all pm_* database tables, removes module options, and deletes uploads/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

  1. Go to Setup → Modules and click Activate.
  2. Open any Purchase menu — schema migration runs automatically (DB v100).
  3. Configure Purchase Management → Settings.
  4. Optional: click Load Demo Data in Settings to seed sample records.
  5. Assign permissions under Setup → Staff → Permissions.

Staff permissions (from module)

Assign under Setup → Staff → Roles. Each feature can expose different actions:

FeatureActions
Dashboard
purchase_dashboard
view
Suppliers
purchase_suppliers
view, create, edit, delete
Purchase Requests
purchase_request
view, create, edit, delete, approve
RFQ / Quotations
purchase_rfq
view, create, edit, delete
Purchase Orders
purchase_order
view, create, edit, delete, approve
Goods Receipt
purchase_grn
view, create, edit, delete
Supplier Bills
purchase_bill
view, create, edit, delete, approve
Payments
purchase_payment
view, create, edit, delete
Returns
purchase_return
view, create, edit, delete, approve
Reports
purchase_reports
view, export
Settings
purchase_settings
view, edit, manage

One-time setup (first time only)

  1. Setup → Modules → activate Purchase Management.
  2. Setup → Staff → Roles → assign Purchase Management permissions (view, create, edit, delete, approve, export, settings as needed).
  3. Open Purchase Management → Settings and complete company defaults, prefixes, integrations, and notification options.
  4. Create master data (warehouses, products, templates, accounts, routes, etc.) before processing live transactions.
  5. Enable Perfex CRM cron (php /path/to/perfex/index.php cron/index) for sync, retries, alerts, and scheduled jobs.
  6. 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 Purchase 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/purchase_management/. 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

For implementation questions, refer to docs/DOCUMENTATION.md and inline pm_* helper functions in helpers/purchase_management_helper.php.

Nasbix Technologies


Perfex CRM Knowledge Base — detailed usage guide generated from module README, HOW_TO_USE, and documentation.

Did you find this article useful?