Purchases¶
This page covers the purchasing side of the Company API: the supplier directory, supplier invoices (purchase bills) from import through payment and accounting validation, and purchase requests (purchase orders) raised ahead of an invoice.
Suppliers ($client->suppliers)¶
Manages the supplier directory and the categories a supplier is normally booked against.
| Method | HTTP | Scope | Description |
|---|---|---|---|
list($cursor = null, $limit = null, ...) |
GET /suppliers |
suppliers:readonly or suppliers:all |
List suppliers. |
create($name, $establishmentNo = null, $regNo = null, ...) |
POST /suppliers |
suppliers:all |
Create a supplier. |
get($supplierId) |
GET /suppliers/{supplierId} |
suppliers:readonly or suppliers:all |
Retrieve a supplier by its id. |
update($supplierId, $name = null, $establishmentNo = null, ...) |
PUT /suppliers/{supplierId} |
suppliers:all |
Update a supplier. |
listCategories($supplierId, $cursor = null, $limit = null) |
GET /suppliers/{supplierId}/categories |
suppliers:readonly or suppliers:all |
List the categories a supplier is booked against. |
categorize($supplierId, $categories) |
PUT /suppliers/{supplierId}/categories |
suppliers:all |
Replace the categories a supplier is booked against. |
SupplierInvoices ($client->supplierInvoices)¶
Manages supplier invoices end to end: creation by import, updates to lines and categories, payment tracking, transaction matching, and e-invoice status.
| Method | HTTP | Scope | Description |
|---|---|---|---|
list($cursor = null, $limit = null, ...) |
GET /supplier_invoices |
supplier_invoices:readonly or supplier_invoices:all |
List supplier invoices. |
get($supplierInvoiceId) |
GET /supplier_invoices/{supplierInvoiceId} |
supplier_invoices:readonly or supplier_invoices:all |
Retrieve a supplier invoice by its id. |
update($supplierInvoiceId, $supplierId = null, $date = null, ...) |
PUT /supplier_invoices/{supplierInvoiceId} |
supplier_invoices:all |
Update a supplier invoice, optionally adding, editing, or removing invoice lines. |
listInvoiceLines($supplierInvoiceId, $cursor = null, $limit = null, $sort = null) |
GET /supplier_invoices/{supplierInvoiceId}/invoice_lines |
supplier_invoices:readonly or supplier_invoices:all |
List the lines of a supplier invoice. |
listCategories($supplierInvoiceId, $cursor = null, $limit = null) |
GET /supplier_invoices/{supplierInvoiceId}/categories |
supplier_invoices:readonly or supplier_invoices:all |
List the categories a supplier invoice is booked against. |
categorize($supplierInvoiceId, $categories) |
PUT /supplier_invoices/{supplierInvoiceId}/categories |
supplier_invoices:all |
Replace the categories a supplier invoice is booked against. |
listPayments($supplierInvoiceId, $cursor = null, $limit = null, $sort = null) |
GET /supplier_invoices/{supplierInvoiceId}/payments |
supplier_invoices:readonly or supplier_invoices:all |
List the payments recorded against a supplier invoice. |
updatePaymentStatus($supplierInvoiceId, $paymentStatus) |
PUT /supplier_invoices/{supplierInvoiceId}/payment_status |
supplier_invoices:all |
Update the payment status of a supplier invoice (paid or to_be_paid). |
listMatchedTransactions($supplierInvoiceId, $cursor = null, $limit = null, $sort = null) |
GET /supplier_invoices/{supplierInvoiceId}/matched_transactions |
supplier_invoices:readonly or supplier_invoices:all |
List the bank transactions matched to a supplier invoice. |
matchTransaction($supplierInvoiceId, $transactionId) |
POST /supplier_invoices/{supplierInvoiceId}/matched_transactions |
supplier_invoices:all |
Match a bank transaction to a supplier invoice. |
unmatchTransaction($supplierInvoiceId, $transactionId) |
DELETE /supplier_invoices/{supplierInvoiceId}/matched_transactions/{transactionId} |
supplier_invoices:all |
Unmatch a bank transaction from a supplier invoice. |
linkPurchaseRequests($supplierInvoiceId, $purchaseRequestId) |
POST /supplier_invoices/{supplierInvoiceId}/linked_purchase_requests |
supplier_invoices:all |
Link a purchase request to a supplier invoice. |
importFromFile($fileAttachmentId, $supplierId, $date, $deadline, ...) |
POST /supplier_invoices/import |
supplier_invoices:all |
Import a supplier invoice from a file already uploaded through file attachments. |
importEInvoice($file, $invoiceOptions = null) |
POST /supplier_invoices/e_invoices/imports |
supplier_invoices:all |
Import a supplier e-invoice file (Factur-X, UBL, or CII); beta, subject to change. |
validateAccounting($supplierInvoiceId) |
PUT /supplier_invoices/{supplierInvoiceId}/validate_accounting |
supplier_invoices:all |
Validate the accounting of a supplier invoice. |
updateEInvoiceStatus($supplierInvoiceId, $status, $reason = null) |
PUT /supplier_invoices/{supplierInvoiceId}/e_invoice_status |
supplier_invoices:all |
Update the e-invoice status of a supplier invoice (approved, disputed, or refused). |
Note: importFromFile() takes a fileAttachmentId referencing a file already uploaded through $client->fileAttachments, it does not accept a raw upload. importEInvoice() is the one method here that takes a FileUpload directly, built with FileUpload::fromPath().
PurchaseRequests ($client->purchaseRequests)¶
Manages purchase requests (purchase orders raised for approval ahead of the corresponding supplier invoice).
| Method | HTTP | Scope | Description |
|---|---|---|---|
list($cursor = null, $limit = null, ...) |
GET /purchase_requests |
purchase_requests:readonly or purchase_requests:all |
List purchase requests. |
get($purchaseRequestId) |
GET /purchase_requests/{purchaseRequestId} |
purchase_requests:readonly or purchase_requests:all |
Retrieve a purchase request by its id. |
importFromFile($fileAttachmentId, $reason, $supplierId, $purchaseOrderNumber, ...) |
POST /purchase_requests/imports |
purchase_requests:all |
Import a purchase order from a file already uploaded through file attachments. |
Like supplier invoice imports, importFromFile() here takes a fileAttachmentId from a file uploaded beforehand through $client->fileAttachments, not a direct file upload.
Example¶
<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
use Pennylane\Sdk\Filter;
use Pennylane\Sdk\Pennylane;
$client = new Pennylane();
$supplier = $client->suppliers->create(
name: 'Office Supplies Co',
establishmentNo: '12345678900012',
);
foreach ($client->supplierInvoices->list(filter: Filter::eq('supplier_id', $supplier->id)) as $invoice) {
$client->supplierInvoices->validateAccounting($invoice->id);
}
foreach ($client->purchaseRequests->list(filter: Filter::eq('supplier_id', $supplier->id)) as $request) {
echo "Purchase request #{$request->id}\n";
}