Skip to content

Examples

Small, self-contained examples. Each folder shows one thing, with an example.php you can run and a README.md that explains it.

  1. Register http://localhost:8765/callback as redirect URI for your client in the Twinfield developer portal.

  2. Run any example, for instance:

    Terminal window
    php examples/offices/list-offices/example.php

The first time, the example asks for your client ID, client secret and redirect URI, opens the Twinfield login in your browser and asks for a default company. Everything is saved in ~/.config/twinfield/, so after that examples start right away. Run composer twinfield:setup to change these values.

Every example starts the same way:

require __DIR__ . '/../../../vendor/autoload.php';
$twinfield = Example::twinfield();

In your own application you create the client yourself: see Authentication.

Add TWINFIELD_DEBUG=1 to any example to see the SOAP requests and responses.

  • Login: let a user log in and get the refresh token.
  • Authentication: create a client in your own application.
  • Token info: organisation, user and cluster of an access token.
  • Error handling: catch errors and act on their code.
  • REST API request: call an endpoint of the REST API directly, with the company GUID.
  • List bank books: code and name of all bank books, or those matching a pattern.
  • Read bank book: bank account, ledger account and automatic bank processing of one bank book.
  • Create bank book: create a bank book with a bank account (changes data; cannot be deleted).
  • Update bank book: change a bank book; only changed values are sent (changes data).
  • List cash books: code and name of all cash books, or those matching a pattern.
  • Read cash book: name, short name and ledger account of one cash book.
  • Create cash book: create a cash book (changes data; cannot be deleted).
  • Update cash book: change a cash book; only changed values are sent (changes data).
  • Read sales transaction: invoice number, customer, revenue and VAT lines, payment status and payments of one sales transaction.
  • Create sales transaction: book an invoice from your own software, with the VAT calculated from the VAT code (changes data with --save).
  • Credit note: book a credit note: the same positive amounts, the sides turned around (changes data with --save).
  • Open invoices: unpaid invoices of a customer, with Finder IVT.
  • Read purchase transaction: invoice number, supplier, cost and VAT lines, payment status and payments of one purchase transaction.
  • Create purchase transaction: book a received invoice, with the VAT calculated from the VAT code (changes data with --save).
  • Credit note: book a credit note of a supplier: the same positive amounts, the sides turned around (changes data with --save).
  • Open invoices: unpaid invoices of a supplier, with Finder IVT.
  • List invoice types: the invoice types of the company, with Finder INV.
  • Read sales invoice: header, lines, VAT and totals of one sales invoice, and the sales transaction Twinfield booked for it.
  • Create sales invoice: let Twinfield make a concept invoice, or only calculate it (changes data with --save).
  • Finalize sales invoice: make a concept invoice final, so Twinfield books the sales transaction (changes data with --save).
  • List customers: code and name of all customers, or those matching a pattern.
  • Read customer: payment term, direct debit, credit management, addresses and bank accounts of one customer.
  • Create customer: create a customer with an address and a bank account (changes data).
  • Update customer: change settings, an address, and add an address and a bank account (changes data).
  • Delete customer: delete or hide a customer, and activate it again (changes data).
  • List changed customers: customers changed since a date, also deleted and archived ones (REST API).

The new fixed assets module, on the REST API. For the classic module see Fixed assets (classic).

  • List fixed assets: code and name of all fixed assets, or those matching a pattern or in a group.
  • Read fixed asset: status, depreciation settings, free texts, transaction lines and locked settings of one asset.
  • Create fixed asset: create a fixed asset with the next free code (changes data).
  • Update fixed asset: change a fixed asset; locked settings are left out (changes data).
  • Delete fixed asset: delete or hide a fixed asset, and activate it again (changes data).
  • List posting rules: how invoices of customers and suppliers are divided over accounts (REST API).
  • List rates: code and name of all rates, or those matching a pattern.
  • Search rates: rates for hours or quantities, by name.
  • Read rate: type, unit, currency, all prices and the price today.
  • Create rate: create a kilometre rate (changes data).
  • Update rate price: new prices from a date with newPriceFrom() (changes data).
  • Delete rate: delete or hide a rate (changes data).
  • List users: code and name of all users of the organisation.
  • Search users: search by code, and the users that share a company with you.
  • Read user: role, login status, companies and Time & Expenses settings of one user.
  • Current user: the user of the access token, with userCode() and users()->current().
  • Create user: create and invite a user (changes data, can cost money).
  • Update user: change a user with edit(), and grant or revoke company access (changes data).
  • Delete user: delete or hide a user with a reason (changes data).
  • List suppliers: code and name of all suppliers, or those matching a pattern.
  • Read supplier: payment term, how the supplier is paid, remittance advice, addresses, bank accounts and posting rules of one supplier.
  • Create supplier: create a supplier paid by credit transfer, with an address and a bank account (changes data).
  • Update supplier: change how the supplier is paid, a bank account, and add a bank account (changes data).
  • Delete supplier: delete or hide a supplier, and activate it again (changes data).
  • List budgets: code and name of all budgets, or those matching a pattern.
  • Budget vs. actual: budget and actual amounts per general ledger account, with the difference.
  • Budget by cost center: amounts per account, cost center and period.
  • Budget by project: amounts per period, account, cost center and project.
  • List budget lines: the budgets per year and their lines (REST API).
  • Create budget: create a budget, spread an amount over the periods and delete it again (REST API, changes data).
  • List PSD2 feeds: the PSD2 feeds of all companies and when their consent expires (REST API).

One example per browse code; see Browse codes for all codes and their fields.

  • Match transactions: match an invoice with its payment, partly or with a discount (write).
  • List match sets: the matched lines of a customer with their match number (browse data).
  • Undo match: undo a match set by its match number (write).
  • Matching audit trail: the matches and undone matches since a date (REST API).
  • List pay runs: the payment and direct debit runs of a company.
  • Get pay run: a run with its summaries, bank accounts and invoices.
  • Create pay run: select the open invoices for a payment or direct debit run (write).
  • Finish pay run: delete a run that is not posted yet, or end it after the files (write).
  • Pay run lifecycle: modify, authorise, post, create the SEPA files and finish (write, can’t be undone).
Made by SolveBeam

Twinfield and Wolters Kluwer are trademarks of Wolters Kluwer. Their names and logos are used only to refer to their products.