Skip to content

Purchase Invoices

Manage your Purchase Invoices in Moneybird.

Working with Purchase Invoices

This section covers how to interact with Moneybird’s Purchase Invoices API. You can create, retrieve, update, and delete purchase invoices, as well as manage attachments and synchronize data.

Basic Operations

Get a Purchase Invoice

Retrieve a purchase invoice by its ID.

$purchaseInvoice = $client->purchaseInvoices()->get('123456789');

List Purchase Invoices

Get a paginated list of purchase invoices.

$purchaseInvoices = $client->purchaseInvoices()->paginate();
// Iterate through the pages
foreach ($purchaseInvoices as $purchaseInvoice) {
echo $purchaseInvoice->reference . ': ' . $purchaseInvoice->total_price_incl_tax;
}

Get All Purchase Invoices

Get all purchase invoices at once.

$allPurchaseInvoices = $client->purchaseInvoices()->all();
// Iterate through all purchase invoices
foreach ($allPurchaseInvoices as $purchaseInvoice) {
echo $purchaseInvoice->reference . ': ' . $purchaseInvoice->total_price_incl_tax;
}

Create a Purchase Invoice

Create a new purchase invoice.

$data = [
'contact_id' => '123456789',
'reference' => 'INV-2023-001',
'date' => '2023-01-15',
'due_date' => '2023-02-15',
'currency' => 'EUR',
'prices_are_incl_tax' => true,
'details' => [
[
'description' => 'Office Supplies',
'price' => '100.00',
'amount' => '1',
'tax_rate_id' => '123456'
]
]
];
$purchaseInvoice = $client->purchaseInvoices()->create($data);

Update a Purchase Invoice

Update an existing purchase invoice.

$updateData = [
'reference' => 'INV-2023-001-UPDATED',
'due_date' => '2023-03-01'
];
$purchaseInvoice = $client->purchaseInvoices()->update('123456789', $updateData);

Delete a Purchase Invoice

Delete a purchase invoice.

$client->purchaseInvoices()->delete('123456789');

Attachments

Add an Attachment

Add an attachment to a purchase invoice.

$attachmentData = [
'filename' => 'invoice.pdf',
'content' => base64_encode(file_get_contents('/path/to/invoice.pdf'))
];
$client->purchaseInvoices()->createAttachment('123456789', $attachmentData);

Delete an Attachment

Delete an attachment from a purchase invoice.

$client->purchaseInvoices()->deleteAttachment('123456789', 'attachment_id');

Synchronization

Get Synchronization List

Get a list of purchase invoice IDs and version timestamps for synchronization.

$syncList = $client->purchaseInvoices()->synchronization();
foreach ($syncList as $item) {
echo $item->id . ' (version: ' . $item->version . ')';
}

Synchronize Purchase Invoices

Synchronize purchase invoices by providing an array of IDs.

$purchaseInvoiceIds = ['123456789', '987654321'];
$syncedPurchaseInvoices = $client->purchaseInvoices()->synchronize($purchaseInvoiceIds);
foreach ($syncedPurchaseInvoices as $purchaseInvoice) {
echo $purchaseInvoice->reference;
}

Purchase Invoice Properties

When working with purchase invoices, you’ll have access to the following properties:

PropertyTypeDescription
idstringUnique identifier
administration_idstringID of the administration the purchase invoice belongs to
contact_idstringID of the contact associated with the purchase invoice
referencestringReference number or code for the purchase invoice
datestringDate of the purchase invoice
due_datestringDue date for payment
entry_numberstringEntry number in the system
statestringCurrent state of the purchase invoice
currencystringCurrency code (e.g., ‘EUR’, ‘USD’)
exchange_ratestringExchange rate if not using the default currency
revenue_invoicestringWhether this is a revenue invoice
prices_are_incl_taxstringWhether prices include tax
originstringOrigin of the purchase invoice
paid_atstringDate when the invoice was paid
tax_numberstringTax number associated with the invoice
total_price_excl_taxstringTotal price excluding tax
total_price_incl_taxstringTotal price including tax
detailsarrayLine items on the purchase invoice
paymentsarrayPayment information
notesarrayNotes associated with the purchase invoice
attachmentsarrayAttachments associated with the purchase invoice
eventsarrayEvents related to the purchase invoice
created_atstringISO 8601 timestamp of when the purchase invoice was created
updated_atstringISO 8601 timestamp of when the purchase invoice was last updated

Note: See the official API reference for the complete list of available properties.

Further reading