@procurementexpress.com/mcp 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/bump-version/SKILL.md +77 -0
- package/.claude/skills/commit/SKILL.md +73 -0
- package/.claude/skills/npm-publish/SKILL.md +65 -0
- package/.claude/skills/pex-approval-flows/SKILL.md +122 -0
- package/.claude/skills/pex-approval-flows/references/conditions.md +90 -0
- package/.claude/skills/pex-auth/SKILL.md +80 -0
- package/.claude/skills/pex-budgets/SKILL.md +73 -0
- package/.claude/skills/pex-companies/SKILL.md +113 -0
- package/.claude/skills/pex-departments/SKILL.md +61 -0
- package/.claude/skills/pex-invoices/SKILL.md +125 -0
- package/.claude/skills/pex-invoices/references/line-items.md +55 -0
- package/.claude/skills/pex-payments/SKILL.md +79 -0
- package/.claude/skills/pex-purchase-orders/SKILL.md +167 -0
- package/.claude/skills/pex-purchase-orders/references/line-items.md +53 -0
- package/.claude/skills/pex-purchase-orders/references/workflows.md +74 -0
- package/.claude/skills/pex-settings/SKILL.md +128 -0
- package/.claude/skills/pex-suppliers/SKILL.md +113 -0
- package/README.md +118 -25
- package/dist/api-client.d.ts +1 -0
- package/dist/api-client.js +3 -0
- package/dist/tools/approval-flows.js +130 -25
- package/dist/tools/budgets.js +30 -20
- package/dist/tools/comments.js +4 -4
- package/dist/tools/companies.js +57 -7
- package/dist/tools/departments.js +6 -6
- package/dist/tools/invoices.js +100 -31
- package/dist/tools/payments.js +45 -13
- package/dist/tools/products.js +10 -5
- package/dist/tools/purchase-orders.js +178 -35
- package/dist/tools/supplementary.js +57 -14
- package/dist/tools/suppliers.js +38 -19
- package/dist/tools/tax-rates.js +15 -9
- package/dist/tools/users.js +8 -5
- package/dist/tools/webhooks.js +59 -9
- package/package.json +5 -4
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pex:companies
|
|
3
|
+
description: >
|
|
4
|
+
ProcurementExpress company management, employee listing, user invitations, and approver
|
|
5
|
+
queries. Use when listing companies, switching the active company, viewing company details
|
|
6
|
+
and settings, managing employees and user invitations, or querying approvers. Routes to MCP
|
|
7
|
+
tools: list_companies, get_company, get_company_details, set_active_company, list_approvers,
|
|
8
|
+
list_all_approvers, list_employees, invite_user, get_invite_limit, list_pending_invites,
|
|
9
|
+
cancel_invite, resend_invite. Triggers on: company, switch company, employees, invite user,
|
|
10
|
+
approvers, company settings, custom fields, payment terms.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# ProcurementExpress Companies
|
|
14
|
+
|
|
15
|
+
## Prerequisites
|
|
16
|
+
|
|
17
|
+
Authenticate first (pex-auth skill). Most tools require an active company set via `set_active_company`.
|
|
18
|
+
|
|
19
|
+
## Tools Reference
|
|
20
|
+
|
|
21
|
+
### set_active_company
|
|
22
|
+
Set the working company for all subsequent API calls. **Must be called before most operations.**
|
|
23
|
+
- **Params:** `company_id` (required, string)
|
|
24
|
+
- **Returns:** Confirmation text
|
|
25
|
+
- This is a client-side operation (no API call)
|
|
26
|
+
|
|
27
|
+
### list_companies
|
|
28
|
+
List all companies the authenticated user belongs to.
|
|
29
|
+
- **Params:** None
|
|
30
|
+
- **Returns:** `CompanyDetail[]`
|
|
31
|
+
|
|
32
|
+
### get_company
|
|
33
|
+
Get company details by ID including settings, custom fields, and supported currencies.
|
|
34
|
+
- **Params:** `id` (required, integer)
|
|
35
|
+
- **Returns:** `CompanyDetail`
|
|
36
|
+
|
|
37
|
+
### get_company_details
|
|
38
|
+
Get details for the currently active company.
|
|
39
|
+
- **Params:** None
|
|
40
|
+
- **Returns:** `CompanyDetail`
|
|
41
|
+
|
|
42
|
+
### list_employees
|
|
43
|
+
List all active employees of the current company with their roles.
|
|
44
|
+
- **Params:** None
|
|
45
|
+
- **Requires:** companyadmin role
|
|
46
|
+
- **Returns:** `Employee[]` — each has: id, email, name, roles[]
|
|
47
|
+
|
|
48
|
+
### list_approvers
|
|
49
|
+
List approvers for the current company. Returns empty if company uses approval flows.
|
|
50
|
+
- **Params:** `department_id` (optional, integer) — filter by department
|
|
51
|
+
- **Returns:** `Approver[]` — each has: id, email, name, approval_limit
|
|
52
|
+
|
|
53
|
+
### list_all_approvers
|
|
54
|
+
List all approvers regardless of auto-approval routing.
|
|
55
|
+
- **Params:** None
|
|
56
|
+
- **Returns:** `Approver[]`
|
|
57
|
+
|
|
58
|
+
### invite_user
|
|
59
|
+
Invite a user to the company.
|
|
60
|
+
- **Params:**
|
|
61
|
+
- `email` (required, email format)
|
|
62
|
+
- `name` (required, string)
|
|
63
|
+
- `roles` (required, array) — valid values: `"companyadmin"`, `"approver"`, `"finance"`, `"teammember"`
|
|
64
|
+
- `approval_limit` (optional, number, default: 0)
|
|
65
|
+
- `department_ids` (optional, integer array)
|
|
66
|
+
- **Requires:** Available invite slots (check with `get_invite_limit`)
|
|
67
|
+
- **Returns:** Invitation result
|
|
68
|
+
|
|
69
|
+
### get_invite_limit
|
|
70
|
+
Check remaining invite slots for the company plan.
|
|
71
|
+
- **Params:** None
|
|
72
|
+
- **Returns:** `{ invite_limit_left, active_users, allowed_users }`
|
|
73
|
+
|
|
74
|
+
### list_pending_invites
|
|
75
|
+
List pending user invitations.
|
|
76
|
+
- **Params:** None
|
|
77
|
+
- **Requires:** companyadmin role
|
|
78
|
+
- **Returns:** Array of pending invites (each has a `token` for cancel/resend)
|
|
79
|
+
|
|
80
|
+
### cancel_invite
|
|
81
|
+
Cancel a pending invitation.
|
|
82
|
+
- **Params:** `token` (required, string) — from pending invite
|
|
83
|
+
- **Requires:** companyadmin role
|
|
84
|
+
|
|
85
|
+
### resend_invite
|
|
86
|
+
Resend a pending invitation email.
|
|
87
|
+
- **Params:** `token` (required, string) — from pending invite
|
|
88
|
+
- **Requires:** companyadmin role
|
|
89
|
+
|
|
90
|
+
## CompanyDetail Response Fields
|
|
91
|
+
|
|
92
|
+
Key fields in `CompanyDetail`:
|
|
93
|
+
- `id`, `name`, `is_locked`, `in_trial`, `trial_expired`, `remaining_trial_days`
|
|
94
|
+
- `company_setting` — 40+ config fields including:
|
|
95
|
+
- `currency_id` — default currency
|
|
96
|
+
- `date_format` — date format used across all date fields in the API
|
|
97
|
+
- `gross_or_net` — whether amounts are gross or net
|
|
98
|
+
- `show_po_item_number`, `show_delivery_status`, `show_payment_status`
|
|
99
|
+
- `po_number_prefix`, `next_po_number`
|
|
100
|
+
- `invoice_enabled`, `invoice_approval_flow_enabled`
|
|
101
|
+
- `approval_flow_enabled` — whether approval flows are active
|
|
102
|
+
- `custom_fields[]` — company custom fields with type, options, placement flags
|
|
103
|
+
- `supported_currencies[]` — currencies enabled for this company
|
|
104
|
+
- `payment_terms[]` — payment terms with due_days, day_of_month, term_type
|
|
105
|
+
|
|
106
|
+
## User Roles
|
|
107
|
+
|
|
108
|
+
| Role | Permissions |
|
|
109
|
+
|------|------------|
|
|
110
|
+
| `companyadmin` | Full admin access, manage users, settings |
|
|
111
|
+
| `approver` | Approve/reject POs and invoices |
|
|
112
|
+
| `finance` | Financial operations, override approvals, archive |
|
|
113
|
+
| `teammember` | Create and view POs |
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pex:departments
|
|
3
|
+
description: >
|
|
4
|
+
ProcurementExpress department management. Use when listing, viewing, creating, or updating
|
|
5
|
+
departments (organizational units). Routes to MCP tools: list_departments, get_department,
|
|
6
|
+
create_department, update_department. Triggers on: department, division, organizational unit,
|
|
7
|
+
department users, department budgets.
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# ProcurementExpress Departments
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
Authenticate (pex-auth) and set active company (pex-companies) first.
|
|
15
|
+
|
|
16
|
+
## Tools Reference
|
|
17
|
+
|
|
18
|
+
### list_departments
|
|
19
|
+
List departments. By default returns only departments the current user has access to.
|
|
20
|
+
- **Params:**
|
|
21
|
+
- `archived` (optional, boolean, default: false)
|
|
22
|
+
- `company_specific` (optional, boolean) — true to list ALL company departments regardless of user access
|
|
23
|
+
- **Returns:** `Department[]`
|
|
24
|
+
|
|
25
|
+
### get_department
|
|
26
|
+
Get a specific department by ID.
|
|
27
|
+
- **Params:** `id` (required, integer)
|
|
28
|
+
- **Returns:** `Department`
|
|
29
|
+
|
|
30
|
+
### create_department
|
|
31
|
+
Create a new department.
|
|
32
|
+
- **Params:**
|
|
33
|
+
- `name` (required, string)
|
|
34
|
+
- `contact_person` (optional, string)
|
|
35
|
+
- `phone_number` (optional, string)
|
|
36
|
+
- `email` (optional, string)
|
|
37
|
+
- `address` (optional, string)
|
|
38
|
+
- `tax_number` (optional, string)
|
|
39
|
+
- `budget_ids` (optional, integer array) — budgets to associate
|
|
40
|
+
- `user_ids` (optional, integer array) — users to assign
|
|
41
|
+
- **Returns:** `Department`
|
|
42
|
+
|
|
43
|
+
### update_department
|
|
44
|
+
Update an existing department.
|
|
45
|
+
- **Params:** `id` (required) + any create_department params + `archived` (optional, boolean)
|
|
46
|
+
- **Returns:** `Department`
|
|
47
|
+
|
|
48
|
+
## Department Response Fields
|
|
49
|
+
|
|
50
|
+
- `id`, `name`, `company_id`, `archived`
|
|
51
|
+
- `contact_person`, `tax_number`, `phone_number`, `address`, `email`
|
|
52
|
+
- `supplier_ids[]` — associated supplier IDs
|
|
53
|
+
- `budget_ids[]` — associated budget IDs
|
|
54
|
+
- `created_at`, `updated_at`
|
|
55
|
+
|
|
56
|
+
## Relationships
|
|
57
|
+
|
|
58
|
+
- Departments contain users and budgets
|
|
59
|
+
- Departments can restrict which suppliers are available
|
|
60
|
+
- POs and invoices can be filtered by department
|
|
61
|
+
- Approvers can be filtered by department (pex-companies `list_approvers`)
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pex:invoices
|
|
3
|
+
description: >
|
|
4
|
+
ProcurementExpress invoice management. Covers creating, updating, accepting, approving,
|
|
5
|
+
rejecting, cancelling, archiving invoices, and adding comments. Handles the full invoice
|
|
6
|
+
lifecycle from receipt through approval to settlement. Routes to MCP tools: list_invoices,
|
|
7
|
+
get_invoice, create_invoice, update_invoice, accept_invoice, approve_invoice, reject_invoice,
|
|
8
|
+
cancel_invoice, archive_invoice, dearchive_invoice, rerun_invoice_approval_flow,
|
|
9
|
+
add_invoice_comment. Triggers on: invoice, bill, invoice approval, invoice status,
|
|
10
|
+
awaiting review, outstanding invoice, ready to pay, invoice comment, invoice line items.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# ProcurementExpress Invoices
|
|
14
|
+
|
|
15
|
+
## Prerequisites
|
|
16
|
+
|
|
17
|
+
Authenticate (pex-auth) and set active company (pex-companies) first.
|
|
18
|
+
Invoices must be enabled for the company (`company_setting.invoice_enabled`).
|
|
19
|
+
|
|
20
|
+
## Core Tools
|
|
21
|
+
|
|
22
|
+
### list_invoices
|
|
23
|
+
List invoices with pagination and filters.
|
|
24
|
+
- **Params:**
|
|
25
|
+
- `page` (optional, integer, default: 1)
|
|
26
|
+
- `per_page` (optional, integer) — allowed: 10, 20, 50, 100
|
|
27
|
+
- `search` (optional) — matches invoice number, supplier name
|
|
28
|
+
- `invoice_statuses_filter` (optional) — `"awaiting_review"`, `"outstanding"`, `"ready_to_pay"`, `"settled"`, `"cancelled"`
|
|
29
|
+
- `supplier_id`, `requester_id`, `approver_id`, `department_id` (all optional, integer)
|
|
30
|
+
- `archived` (optional, boolean, default: false)
|
|
31
|
+
- `invoice_date_filter` (optional) — `"last 7days"`, `"last 30days"`, `"last 60days"`, `"last 90days"`, `"last 180days"`, `"last 1year"`, `"current_month"`, `"current_year"`, `"last_month"`, `"last_year"`
|
|
32
|
+
- `sage_exported` (optional, boolean) — filter by Sage export status
|
|
33
|
+
- `sort` (optional), `direction` (optional, `"asc"` or `"desc"`)
|
|
34
|
+
- **Returns:** `{ invoices: Invoice[], meta: PaginationMeta }`
|
|
35
|
+
|
|
36
|
+
### get_invoice
|
|
37
|
+
Get invoice details including line items, linked POs, comments, and payment history.
|
|
38
|
+
- **Params:** `id` (required, integer)
|
|
39
|
+
- **Returns:** `Invoice`
|
|
40
|
+
|
|
41
|
+
### create_invoice
|
|
42
|
+
Create a new invoice. If company has "create invoice in awaiting review" enabled, starts in awaiting_review status.
|
|
43
|
+
- **Params:**
|
|
44
|
+
- `invoice_number` (optional, string)
|
|
45
|
+
- `issue_date`, `uploaded_date`, `received_date`, `due_date` (optional, string — company date_format)
|
|
46
|
+
- `gross_amount` (optional, number)
|
|
47
|
+
- `currency_id` (optional, integer)
|
|
48
|
+
- `supplier_id` (optional, integer)
|
|
49
|
+
- `standalone_invoice` (optional, boolean) — true if not linked to any PO
|
|
50
|
+
- `payment_term_id` (optional, integer) — payment terms from company settings
|
|
51
|
+
- `selected_purchase_order_ids` (optional, integer array) — PO IDs to link
|
|
52
|
+
- `line_items` (optional, array) — see [references/line-items.md](references/line-items.md)
|
|
53
|
+
- `custom_field_values_attributes` (optional, array) — invoice-level custom field values:
|
|
54
|
+
- `id` (optional, integer — for updates), `value` (required, string), `custom_field_id` (required, integer)
|
|
55
|
+
- Get available custom fields from `get_company_details` (pex-companies) → `custom_fields[]`
|
|
56
|
+
- **Returns:** `Invoice`
|
|
57
|
+
|
|
58
|
+
### update_invoice
|
|
59
|
+
Update an existing invoice.
|
|
60
|
+
- **Params:** `id` (required) + any create params
|
|
61
|
+
- For line items: include `id` to update, `_destroy: true` to remove
|
|
62
|
+
- **Returns:** `Invoice`
|
|
63
|
+
|
|
64
|
+
## Approval Lifecycle Tools
|
|
65
|
+
|
|
66
|
+
### accept_invoice
|
|
67
|
+
Accept an invoice in awaiting_review status (moves to outstanding).
|
|
68
|
+
- **Params:** `id` (required, integer)
|
|
69
|
+
|
|
70
|
+
### approve_invoice
|
|
71
|
+
Approve an invoice (requires invoice approval permission).
|
|
72
|
+
- **Params:** `id` (required, integer)
|
|
73
|
+
|
|
74
|
+
### reject_invoice
|
|
75
|
+
Reject an invoice (requires invoice approval permission).
|
|
76
|
+
- **Params:** `id` (required, integer)
|
|
77
|
+
|
|
78
|
+
### cancel_invoice
|
|
79
|
+
Cancel an invoice (requires cancel permission).
|
|
80
|
+
- **Params:** `id` (required, integer)
|
|
81
|
+
|
|
82
|
+
### archive_invoice
|
|
83
|
+
Archive an invoice (requires archive permission).
|
|
84
|
+
- **Params:** `id` (required, integer)
|
|
85
|
+
|
|
86
|
+
### dearchive_invoice
|
|
87
|
+
Restore an archived invoice.
|
|
88
|
+
- **Params:** `id` (required, integer)
|
|
89
|
+
|
|
90
|
+
### rerun_invoice_approval_flow
|
|
91
|
+
Rerun the approval flow when rules have changed.
|
|
92
|
+
- **Params:** `id` (required, integer)
|
|
93
|
+
|
|
94
|
+
## Comment Tool
|
|
95
|
+
|
|
96
|
+
### add_invoice_comment
|
|
97
|
+
Add a comment to an invoice.
|
|
98
|
+
- **Params:** `invoice_id` (required, integer), `comment` (required, string)
|
|
99
|
+
|
|
100
|
+
## Invoice Status Flow
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
awaiting_review → (accept_invoice) → outstanding → (approve_invoice) → ready_to_pay → (payment) → settled
|
|
104
|
+
→ (reject_invoice) → rejected
|
|
105
|
+
→ (cancel_invoice) → cancelled
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
If `invoice_approval_flow_enabled`, the approval flow determines the approval path automatically.
|
|
109
|
+
|
|
110
|
+
## Invoice Response Fields
|
|
111
|
+
|
|
112
|
+
Key fields in `Invoice`:
|
|
113
|
+
- `id`, `invoice_number`, `status`, `gross_amount`, `net_amount`
|
|
114
|
+
- `issue_date`, `uploaded_date`, `received_date`, `due_date`, `validation_date`
|
|
115
|
+
- `supplier_id`, `supplier_name`, `currency`
|
|
116
|
+
- `standalone_invoice` — whether linked to POs
|
|
117
|
+
- `confidence_score`, `digital_invoice` — AI extraction confidence
|
|
118
|
+
- `invoice_line_items[]` — line items (see [references/line-items.md](references/line-items.md))
|
|
119
|
+
- `purchase_order_summaries[]` — linked PO summaries
|
|
120
|
+
- `supplier_invoice_uploads[]` — attached invoice files
|
|
121
|
+
- `invoice_histories[]` — status change history
|
|
122
|
+
- `invoice_comments[]` — comments with creator info
|
|
123
|
+
- `payments[]` — payment records
|
|
124
|
+
- Actions: `can_accept`, `can_approve`, `can_reject`, `can_cancel`, `can_archive`, `can_dearchive`
|
|
125
|
+
- `payment_terms_list[]` — available payment terms
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Invoice Line Item Schema
|
|
2
|
+
|
|
3
|
+
## Creating/Updating Line Items
|
|
4
|
+
|
|
5
|
+
Each line item in the `line_items` array accepts:
|
|
6
|
+
|
|
7
|
+
| Field | Type | Required | Description |
|
|
8
|
+
|-------|------|----------|-------------|
|
|
9
|
+
| `id` | integer | For updates | Existing line item ID |
|
|
10
|
+
| `description` | string | No | Item description |
|
|
11
|
+
| `unit_price` | number | No | Unit price |
|
|
12
|
+
| `quantity` | number | No | Quantity |
|
|
13
|
+
| `vat` | number | No | VAT/tax percentage |
|
|
14
|
+
| `net_amount` | number | No | Net amount |
|
|
15
|
+
| `sequence_no` | integer | No | Display order |
|
|
16
|
+
| `tax_rate_id` | integer | No | Tax rate ID (from pex-settings) |
|
|
17
|
+
| `chart_of_account_id` | integer | No | GL code (from pex-settings) |
|
|
18
|
+
| `qbo_customer_id` | integer | No | QuickBooks customer |
|
|
19
|
+
| `quickbooks_class_id` | integer | No | QuickBooks class |
|
|
20
|
+
| `qbo_line_description` | string | No | QuickBooks line description override |
|
|
21
|
+
| `purchase_order_id` | integer | No | Link to a specific PO |
|
|
22
|
+
| `purchase_order_item_id` | integer | No | Link to a specific PO line item |
|
|
23
|
+
| `billable_status` | string | No | Billable status for QuickBooks |
|
|
24
|
+
| `_destroy` | boolean | No | Set true to delete (updates only) |
|
|
25
|
+
| `custom_field_values_attributes` | array | No | Line-item-level custom field values: `[{id?, value, custom_field_id}]` |
|
|
26
|
+
|
|
27
|
+
## Line Item Response Fields
|
|
28
|
+
|
|
29
|
+
Each `InvoiceLineItem` in the response contains:
|
|
30
|
+
|
|
31
|
+
- `id`, `sequence_no`, `description`, `unit_price`, `quantity`
|
|
32
|
+
- `vat`, `gross_amount`, `net_amount` — calculated amounts
|
|
33
|
+
- `tax_rate_id`, `tax_exception` — tax details
|
|
34
|
+
- `chart_of_account` — GL code details (id, name, display_name)
|
|
35
|
+
- `qbo_customer` — QuickBooks customer details
|
|
36
|
+
- `quickbooks_class` — QuickBooks class details
|
|
37
|
+
- `invoice_id`, `purchase_order_id`, `purchase_order_item_id` — relationships
|
|
38
|
+
|
|
39
|
+
## Linking to Purchase Orders
|
|
40
|
+
|
|
41
|
+
Invoice line items can be linked to PO line items for three-way matching:
|
|
42
|
+
- Set `purchase_order_id` to link to a PO
|
|
43
|
+
- Set `purchase_order_item_id` to link to a specific PO line item
|
|
44
|
+
- Also set `selected_purchase_order_ids` on the invoice itself
|
|
45
|
+
|
|
46
|
+
This enables matching invoice amounts against PO amounts for variance detection.
|
|
47
|
+
|
|
48
|
+
## Reference Data
|
|
49
|
+
|
|
50
|
+
For IDs used in line items, use pex-settings tools:
|
|
51
|
+
- `list_tax_rates` → `tax_rate_id`
|
|
52
|
+
- `list_chart_of_accounts` → `chart_of_account_id`
|
|
53
|
+
- `list_qbo_customers` → `qbo_customer_id`
|
|
54
|
+
- `list_qbo_classes` → `quickbooks_class_id`
|
|
55
|
+
- Custom field IDs from `get_company_details` (pex-companies) → `custom_fields[]`
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pex:payments
|
|
3
|
+
description: >
|
|
4
|
+
ProcurementExpress payment management. Use when creating or viewing payments to settle
|
|
5
|
+
invoices and purchase orders. Routes to MCP tools: get_payment, create_payment,
|
|
6
|
+
create_po_payment. Triggers on: payment, pay invoice, pay purchase order, settle,
|
|
7
|
+
bank transfer, payment record, payment type.
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# ProcurementExpress Payments
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
Authenticate (pex-auth) and set active company (pex-companies) first.
|
|
15
|
+
The payments feature may be feature-flagged — contact sales if `create_payment` returns an error.
|
|
16
|
+
|
|
17
|
+
## Tools Reference
|
|
18
|
+
|
|
19
|
+
### get_payment
|
|
20
|
+
Get payment details by ID including linked invoices and POs.
|
|
21
|
+
- **Params:** `id` (required, integer)
|
|
22
|
+
- **Returns:** `Payment`
|
|
23
|
+
|
|
24
|
+
### create_payment
|
|
25
|
+
Create a payment to settle invoices and/or purchase orders.
|
|
26
|
+
- **Params:**
|
|
27
|
+
- `supplier_id` (required, integer)
|
|
28
|
+
- `ptype` (required, enum) — payment type, one of:
|
|
29
|
+
- `"bank_transfer"`, `"card"`, `"credit_card"`, `"check"`, `"cash"`, `"one_time_card"`, `"letter_of_credit"`, `"other"`
|
|
30
|
+
- `date` (required, string) — must match company `date_format` setting
|
|
31
|
+
- `currency_id` (required, integer)
|
|
32
|
+
- `amount` (required, number) — total payment amount
|
|
33
|
+
- `reference` (optional, string) — payment reference number
|
|
34
|
+
- `payment_mode` (optional, string)
|
|
35
|
+
- `status` (optional, string)
|
|
36
|
+
- `invoices` (optional, array) — invoices to settle:
|
|
37
|
+
- `invoice_id` (required, integer)
|
|
38
|
+
- `gross_amount` (required, number) — amount applied to this invoice
|
|
39
|
+
- `purchase_orders` (optional, array) — POs to settle:
|
|
40
|
+
- `purchase_order_id` (required, integer)
|
|
41
|
+
- `budget_id` (optional, integer)
|
|
42
|
+
- `gross_amount` (required, number) — amount applied to this PO
|
|
43
|
+
- `comments` (optional, array) — payment comments:
|
|
44
|
+
- `comment` (required, string)
|
|
45
|
+
- **Returns:** `Payment`
|
|
46
|
+
|
|
47
|
+
### create_po_payment
|
|
48
|
+
Create a payment for a specific purchase order with optional item-level breakdown.
|
|
49
|
+
- **Params:**
|
|
50
|
+
- `purchase_order_id` (required, integer)
|
|
51
|
+
- `amount` (optional, number) — total payment (if not using item-level)
|
|
52
|
+
- `note` (optional, string)
|
|
53
|
+
- `item_payments` (optional, array) — item-level payments:
|
|
54
|
+
- `purchase_order_item_id` (required, integer) — PO line item ID
|
|
55
|
+
- `amount` (required, number) — amount for this item
|
|
56
|
+
- **Returns:** Payment result
|
|
57
|
+
|
|
58
|
+
## Payment Response Fields
|
|
59
|
+
|
|
60
|
+
- `id`, `reference`, `status`, `ptype`, `date`, `amount`
|
|
61
|
+
- `currency` — currency details
|
|
62
|
+
- `supplier` — supplier summary
|
|
63
|
+
- `user` — creator details
|
|
64
|
+
- `invoices[]` — linked invoice summaries
|
|
65
|
+
- `npayment_comments[]` — payment comments (id, comment, creator_id, system_generated)
|
|
66
|
+
|
|
67
|
+
## Workflow: Settle an Invoice
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
1. get_invoice (pex-invoices) → get invoice details, supplier_id, gross_amount
|
|
71
|
+
2. create_payment → with supplier_id, amount, ptype, invoices array
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Workflow: Pay a Purchase Order
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
Option A: create_po_payment → simple PO payment with optional item breakdown
|
|
78
|
+
Option B: create_payment → with purchase_orders array (can combine with invoices)
|
|
79
|
+
```
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pex:purchase-orders
|
|
3
|
+
description: >
|
|
4
|
+
ProcurementExpress purchase order (PO) management — the core procurement workflow. Covers
|
|
5
|
+
creating, updating, approving, rejecting, cancelling, archiving, and deleting POs. Also
|
|
6
|
+
handles delivery tracking, PDF generation, forwarding POs to suppliers, and adding comments.
|
|
7
|
+
Routes to MCP tools: list_purchase_orders, get_purchase_order, create_purchase_order,
|
|
8
|
+
update_purchase_order, approve_purchase_order, reject_purchase_order,
|
|
9
|
+
override_and_approve_purchase_order, cancel_purchase_order, archive_purchase_order,
|
|
10
|
+
delete_purchase_order, generate_purchase_order_pdf, get_pending_request_count,
|
|
11
|
+
receive_purchase_order_items, cancel_receiving_items, complete_purchase_order_delivery,
|
|
12
|
+
add_purchase_order_comment, forward_purchase_order, list_send_to_supplier_templates.
|
|
13
|
+
Triggers on: purchase order, PO, create PO, approve PO, reject PO, PO delivery, PO PDF,
|
|
14
|
+
forward PO, PO comment, pending approvals, line items, PO status.
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# ProcurementExpress Purchase Orders
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
Authenticate (pex-auth) and set active company (pex-companies) first.
|
|
22
|
+
|
|
23
|
+
## Core Tools
|
|
24
|
+
|
|
25
|
+
### list_purchase_orders
|
|
26
|
+
List POs with pagination, search, and filters. Always returns paginated results.
|
|
27
|
+
- **Params:**
|
|
28
|
+
- `page` (optional, integer, default: 1)
|
|
29
|
+
- `search` (optional) — matches PO number, supplier name, notes, line item descriptions
|
|
30
|
+
- `status` (optional) — `"draft"`, `"pending"`, `"approved"`, `"rejected"`, `"cancelled"`, `"paid"`
|
|
31
|
+
- `delivery_status` (optional) — `"not_delivered"`, `"partially_delivered"`, `"complete_delivered"`
|
|
32
|
+
- `payment_status` (optional) — `"unpaid"`, `"partially_paid"`, `"paid"`, `"invoice_received"`
|
|
33
|
+
- `supplier_id`, `requester_id`, `budget_id`, `filter_dept_id`, `approver_id` (all optional, integer)
|
|
34
|
+
- `archived` (optional, boolean, default: false)
|
|
35
|
+
- `date_filter` (optional) — `"current_month"`, `"current_year"`, `"last_month"`, `"last_year"`
|
|
36
|
+
- `from`, `to` (optional) — custom date range (company date_format)
|
|
37
|
+
- `updated_after` (optional) — ISO datetime for incremental sync
|
|
38
|
+
- `sort` (optional), `direction` (optional, `"asc"` or `"desc"`)
|
|
39
|
+
- `requests` (optional, boolean) — include pending approval requests
|
|
40
|
+
- `bell` (optional, boolean) — with requests=true, show only bell notification items
|
|
41
|
+
- **Returns:** `{ purchase_orders: PurchaseOrder[], meta: PaginationMeta }`
|
|
42
|
+
|
|
43
|
+
### get_purchase_order
|
|
44
|
+
Get PO details including line items, comments, approvals, and status flags.
|
|
45
|
+
- **Params:** `id` (required, string) — accepts numeric ID, approval-key, or slug
|
|
46
|
+
- **Returns:** `PurchaseOrder`
|
|
47
|
+
|
|
48
|
+
### create_purchase_order
|
|
49
|
+
Create a new PO. At least one line item is required. See [references/line-items.md](references/line-items.md).
|
|
50
|
+
- **Params:**
|
|
51
|
+
- `commit` (required) — `"Send"` (submit for approval) or `"Draft"` (save as draft)
|
|
52
|
+
- `creator_id` (required, integer) — get from `get_current_user`
|
|
53
|
+
- `line_items` (required, array, min 1) — see [references/line-items.md](references/line-items.md)
|
|
54
|
+
- `department_id` (optional, integer)
|
|
55
|
+
- `supplier_id` (optional, integer) — existing supplier
|
|
56
|
+
- `supplier_name` (optional) — display name for existing supplier
|
|
57
|
+
- `new_supplier_name` (optional) — create a new supplier inline
|
|
58
|
+
- `currency_id` (optional, integer) — defaults to company/user currency
|
|
59
|
+
- `iso_code` (optional) — alternative to currency_id (e.g. "USD")
|
|
60
|
+
- `notes` (optional)
|
|
61
|
+
- `submitted_on` (optional) — date in company date_format
|
|
62
|
+
- `on_behalf_of` (optional, integer) — create on behalf of another user (companyadmin only)
|
|
63
|
+
- `approver_list` (optional, integer array) — override default approvers
|
|
64
|
+
- `custom_field_values_attributes` (optional, array) — PO-level custom field values:
|
|
65
|
+
- `id` (optional, integer — for updates), `value` (required, string), `custom_field_id` (required, integer)
|
|
66
|
+
- Get available custom fields from `get_company_details` (pex-companies) → `custom_fields[]`
|
|
67
|
+
- **Returns:** `PurchaseOrder`
|
|
68
|
+
|
|
69
|
+
### update_purchase_order
|
|
70
|
+
Update an existing PO. Use `commit: "Send"` to submit a draft for approval.
|
|
71
|
+
- **Params:** `id` (required, string) + any create params (all optional)
|
|
72
|
+
- For line items: include `id` to update existing, `_destroy: true` to remove
|
|
73
|
+
- **Returns:** `PurchaseOrder`
|
|
74
|
+
|
|
75
|
+
## Approval Tools
|
|
76
|
+
|
|
77
|
+
### approve_purchase_order
|
|
78
|
+
- **Params:** `id` (required, string), `token` (required, string — accept token from approver_requests)
|
|
79
|
+
- Get the token from `get_purchase_order` response → `approver_requests[].accept_token`
|
|
80
|
+
|
|
81
|
+
### reject_purchase_order
|
|
82
|
+
- **Params:** `id` (required, string), `token` (required, string — reject token from approver_requests)
|
|
83
|
+
- Get the token from `get_purchase_order` response → `approver_requests[].reject_token`
|
|
84
|
+
|
|
85
|
+
### override_and_approve_purchase_order
|
|
86
|
+
Override and approve without a token. Requires finance role.
|
|
87
|
+
- **Params:** `id` (required, string)
|
|
88
|
+
|
|
89
|
+
### get_pending_request_count
|
|
90
|
+
Get count of pending approval requests for the current user.
|
|
91
|
+
- **Params:** None
|
|
92
|
+
- **Returns:** Text with pending count
|
|
93
|
+
|
|
94
|
+
## Lifecycle Tools
|
|
95
|
+
|
|
96
|
+
### cancel_purchase_order
|
|
97
|
+
- **Params:** `id` (required, string). Requires cancel permission.
|
|
98
|
+
|
|
99
|
+
### archive_purchase_order
|
|
100
|
+
Toggle archive status. Requires finance role. Call again to dearchive.
|
|
101
|
+
- **Params:** `id` (required, string)
|
|
102
|
+
|
|
103
|
+
### delete_purchase_order
|
|
104
|
+
Permanently delete. Requires destroy permission.
|
|
105
|
+
- **Params:** `id` (required, string)
|
|
106
|
+
|
|
107
|
+
## Delivery Tools
|
|
108
|
+
|
|
109
|
+
### receive_purchase_order_items
|
|
110
|
+
Mark line items as received (partial or full delivery).
|
|
111
|
+
- **Params:**
|
|
112
|
+
- `id` (required, string) — PO ID
|
|
113
|
+
- `items` (required, array) — `[{ id: lineItemId, quantity: receivedQty }, ...]`
|
|
114
|
+
- `delivered_on` (required, string) — delivery date in company date_format
|
|
115
|
+
- `notes` (optional)
|
|
116
|
+
|
|
117
|
+
### cancel_receiving_items
|
|
118
|
+
Cancel all received deliveries, reverting to not_delivered status.
|
|
119
|
+
- **Params:** `id` (required, string)
|
|
120
|
+
|
|
121
|
+
### complete_purchase_order_delivery
|
|
122
|
+
Mark PO as fully delivered.
|
|
123
|
+
- **Params:** `id` (required, string)
|
|
124
|
+
|
|
125
|
+
## Communication Tools
|
|
126
|
+
|
|
127
|
+
### add_purchase_order_comment
|
|
128
|
+
- **Params:** `purchase_order_id` (required, integer), `comment` (required, string)
|
|
129
|
+
- **Returns:** `PurchaseOrderComment` with formatted dates and creator info
|
|
130
|
+
|
|
131
|
+
### forward_purchase_order
|
|
132
|
+
Forward PO to supplier(s) via email with PDF attached.
|
|
133
|
+
- **Params:**
|
|
134
|
+
- `purchase_order_id` (required, integer)
|
|
135
|
+
- `emails` (required, string) — comma-separated recipient emails
|
|
136
|
+
- `cc` (optional) — CC email (defaults to PO creator's email)
|
|
137
|
+
- `note` (optional) — email body text
|
|
138
|
+
- `email_subject` (optional)
|
|
139
|
+
- `uploads` (optional, integer array) — upload IDs to attach
|
|
140
|
+
|
|
141
|
+
### list_send_to_supplier_templates
|
|
142
|
+
List email templates for forwarding POs.
|
|
143
|
+
- **Returns:** `SendToSupplierTemplate[]` — id, label, text, is_default, template_name
|
|
144
|
+
|
|
145
|
+
### generate_purchase_order_pdf
|
|
146
|
+
Generate a PDF and get download link.
|
|
147
|
+
- **Params:** `id` (required, string)
|
|
148
|
+
- **Returns:** `{ pdf_link: string }`
|
|
149
|
+
|
|
150
|
+
## PO Response Fields
|
|
151
|
+
|
|
152
|
+
Key fields in `PurchaseOrder`:
|
|
153
|
+
- `id`, `po_number`, `slug`, `status`, `notes`, `total_gross_amount`, `total_net_amount`
|
|
154
|
+
- `supplier_name`, `supplier_id`, `department_name`, `department_id`
|
|
155
|
+
- `currency_id`, `creator_id`, `submitted_on`, `archived`
|
|
156
|
+
- `delivery_status`, `payment_status`
|
|
157
|
+
- `purchase_order_items[]` — line items (see [references/line-items.md](references/line-items.md))
|
|
158
|
+
- `purchase_order_comments[]` — comments with creator info
|
|
159
|
+
- `approver_requests[]` — approval status with accept/reject tokens
|
|
160
|
+
- `approvers_with_flows[]` — approval flow step details
|
|
161
|
+
- `compliance_checks[]` — compliance status with violations
|
|
162
|
+
- `custom_field_values[]` — custom field data
|
|
163
|
+
- `uploads[]` — attached files
|
|
164
|
+
|
|
165
|
+
## Common Workflows
|
|
166
|
+
|
|
167
|
+
See [references/workflows.md](references/workflows.md) for step-by-step guides.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# PO Line Item Schema
|
|
2
|
+
|
|
3
|
+
## Creating/Updating Line Items
|
|
4
|
+
|
|
5
|
+
Each line item in the `line_items` array accepts:
|
|
6
|
+
|
|
7
|
+
| Field | Type | Required | Description |
|
|
8
|
+
|-------|------|----------|-------------|
|
|
9
|
+
| `id` | integer | For updates | Existing line item ID (omit for new items) |
|
|
10
|
+
| `description` | string | Yes | Item description |
|
|
11
|
+
| `quantity` | number | Yes | Quantity |
|
|
12
|
+
| `unit_price` | number | Yes | Unit price |
|
|
13
|
+
| `budget_id` | integer | No | Budget to charge against |
|
|
14
|
+
| `vat` | number | No | VAT/tax percentage |
|
|
15
|
+
| `tax_rate_id` | integer | No | Tax rate ID (from pex-settings) |
|
|
16
|
+
| `item_number` | string | No | Item number (if company has show_po_item_number enabled) |
|
|
17
|
+
| `sequence_no` | integer | No | Display order |
|
|
18
|
+
| `department_id` | integer | No | Department for this line item |
|
|
19
|
+
| `product_id` | integer | No | Product ID (auto-fills description, SKU, unit_price from catalog) |
|
|
20
|
+
| `chart_of_account_id` | integer | No | GL code (from pex-settings) |
|
|
21
|
+
| `qbo_customer_id` | integer | No | QuickBooks customer |
|
|
22
|
+
| `quickbooks_class_id` | integer | No | QuickBooks class |
|
|
23
|
+
| `qbo_line_description` | string | No | QuickBooks line description override |
|
|
24
|
+
| `archived` | boolean | No | Archive this line item |
|
|
25
|
+
| `_destroy` | boolean | No | Set true to delete this line item (updates only) |
|
|
26
|
+
| `custom_field_values_attributes` | array | No | Line-item-level custom field values: `[{id?, value, custom_field_id}]` |
|
|
27
|
+
|
|
28
|
+
## Line Item Response Fields
|
|
29
|
+
|
|
30
|
+
Each `PurchaseOrderItem` in the response contains:
|
|
31
|
+
|
|
32
|
+
- `id`, `description`, `quantity`, `unit_price`, `item_number`, `sequence_no`
|
|
33
|
+
- `budget_id`, `budget_name` — associated budget
|
|
34
|
+
- `gross_amount`, `net_amount`, `vat` — calculated amounts
|
|
35
|
+
- `tax_rate_id` — applied tax rate
|
|
36
|
+
- `product_id` — linked product
|
|
37
|
+
- `received_quantity` — quantity received so far
|
|
38
|
+
- `chart_of_account` — GL code details (id, name, display_name)
|
|
39
|
+
- `qbo_customer` — QuickBooks customer details
|
|
40
|
+
- `quickbooks_class` — QuickBooks class details
|
|
41
|
+
- `custom_field_values[]` — custom field data for this line item
|
|
42
|
+
- `department_id`, `purchase_order_id`
|
|
43
|
+
|
|
44
|
+
## Tips
|
|
45
|
+
|
|
46
|
+
- When using `product_id`, the product's description, SKU, and unit_price will be used as defaults
|
|
47
|
+
- To update existing line items, include their `id`. To add new items, omit `id`
|
|
48
|
+
- To remove a line item during update, include `id` and `_destroy: true`
|
|
49
|
+
- The `budget_id` determines which budget is charged when the PO is approved
|
|
50
|
+
- If the company uses `gross_or_net` setting, amounts are calculated accordingly
|
|
51
|
+
- Custom fields can be set at both PO level and line item level via `custom_field_values_attributes`
|
|
52
|
+
- Get available custom field IDs from `get_company_details` (pex-companies) → `custom_fields[]`
|
|
53
|
+
- For reference data IDs: use pex-settings tools (`list_tax_rates`, `list_chart_of_accounts`, `list_qbo_customers`, `list_qbo_classes`)
|