Skip to content

Read sales transaction

Reads one sales transaction: the invoice number and due date, the total line with the customer, the revenue and VAT lines, whether it is paid, and with which payments.

Twinfield documentation: Sales transactions.

get($dayBook, $number) returns a SalesTransaction, or throws a TransactionNotFoundException when the transaction (or the day book) does not exist. Use find() to get null instead.

  • $transaction->header: company, day book, number, status (Provisional or Final), period, date, currency, origin, user and dates.
  • $transaction->invoiceNumber, dueDate and paymentReference (null when not set).
  • $transaction->total: the line with the customer (customer) and the accounts receivable account (account), the total including VAT, the VAT total, the payment status (matchStatus), the open amount and the payments it is matched with (matches).
  • $transaction->details: the revenue without VAT, with VAT code and VAT amount, and the cost center (dim2) and project (dim3).
  • $transaction->vat: the VAT per VAT code, with the amount it was calculated on (vatTurnover).

value() is the total signed: positive for an invoice, negative for a credit note (isCreditNote()). isPaid() is true when the invoice is matched with payments. Twinfield gives the open amount in the base currency (openBaseValue). Amounts are Amount objects: exact numeric strings such as 121.00, which you can echo directly.

The Finder gives no transaction numbers; see Open invoices to find unpaid invoices by customer.

$twinfield = Example::twinfield();
if (!isset($argv[1], $argv[2])) {
echo 'Pass a sales day book and transaction number, e.g. VRK 202600012.', PHP_EOL;
exit(0);
}
try {
$transaction = $twinfield->salesTransactions()->get($argv[1], (int) $argv[2]);
} catch (TransactionNotFoundException $exception) {
echo 'Not found: ', $exception->reason, PHP_EOL;
exit(1);
}
$header = $transaction->header;
$total = $transaction->total;
echo 'Transaction: ', $header->dayBook, ' ', $header->number, ' (', $header->status->name, ')', PHP_EOL;
echo 'Invoice: ', $transaction->invoiceNumber, $transaction->isCreditNote() ? ' (credit note)' : '', PHP_EOL;
echo 'Date: ', $header->date->format('Y-m-d'), ', due ', $transaction->dueDate->format('Y-m-d'),
', period ', $header->period, PHP_EOL;
echo 'Customer: ', $transaction->customer()->code, ' ', $transaction->customer()->name, ' on ',
$total->dim1->code, PHP_EOL;
echo 'Total: ', $transaction->value(), ' ', $header->currency, ', VAT ', $total->vatTotal ?? '-', PHP_EOL;
echo 'Payment: ', $total->matchStatus->value, ', open ', $total->openBaseValue ?? '-', PHP_EOL;
foreach ($transaction->details as $line) {
echo sprintf(
' %-6s %-6s %10s %-4s %8s %s',
$line->debitCredit->value,
$line->dim1->code,
$line->value,
$line->vatCode ?? '',
$line->vatValue ?? '',
$line->description ?? '',
), PHP_EOL;
}
foreach ($transaction->vat as $line) {
echo sprintf(
' %-6s %-6s %10s VAT %s on %s',
$line->debitCredit->value,
$line->dim1->code,
$line->value,
$line->vatCode,
$line->vatTurnover ?? '-',
), PHP_EOL;
}
foreach ($total->matches as $set) {
foreach ($set->lines as $match) {
echo ' paid with ', $match->dayBook, ' ', $match->number, ' line ', $match->line, ': ', $match->matchValue,
' on ', $set->matchDate->format('Y-m-d'), PHP_EOL;
}
}
Terminal window
php examples/sales-transactions/read-sales-transaction/example.php VRK 202600012
Transaction: VRK 202600012 (Final)
Invoice: 2026-0042
Date: 2026-11-03, due 2026-12-03, period 2026/11
Customer: 1000 Example customer on 1300
Total: 181.50 EUR, VAT 31.50
Payment: available, open 181.50
credit 8000 100.00 VH 21.00 Consultancy
credit 8000 50.00 VH 10.50 Training
credit 1530 31.50 VAT VH on 150.00

What the SDK sends to Twinfield and what Twinfield sends back, for a call like the one in this example. The responses come from the tests, with example data.

Twinfield documentation: Sales transactions: Read.

$twinfield->salesTransactions()->get('VRK', 202600012);

The SDK sends this XML as xmlRequest of ProcessXmlString to processxml.asmx:

<read>
<type>transaction</type>
<office>1000</office>
<code>VRK</code>
<number>202600012</number>
</read>

Twinfield answers with this XML in ProcessXmlStringResult:

<transaction location="final" result="1">
<header>
<office name="Example Holding B.V." shortname="">1000</office>
<code name="Verkoopfactuur" shortname="Verkoop">VRK</code>
<number>202600012</number>
<period>2026/11</period>
<currency name="Euro" shortname="Euro">EUR</currency>
<regime>Generic</regime>
<date>20261103</date>
<origin>manual</origin>
<originreference/>
<modificationdate>20261104091200</modificationdate>
<user name="Example user" shortname="User">EXAMPLE</user>
<inputdate>20261103101530</inputdate>
<duedate>20261203</duedate>
<invoicenumber>2026-0042</invoicenumber>
<freetext1>Order 778</freetext1>
<freetext3/>
</header>
<lines>
<line type="total" id="1">
<dim1 name="Debiteuren" shortname="" dimensiontype="BAS">1300</dim1>
<dim2 name="Example customer" shortname="" dimensiontype="DEB">1000</dim2>
<debitcredit>debit</debitcredit>
<basevalue>181.50</basevalue>
<rate>1</rate>
<value>181.50</value>
<description>Total</description>
<vatbasetotal>31.50</vatbasetotal>
<vattotal>31.50</vattotal>
<matchstatus>available</matchstatus>
<matchlevel>2</matchlevel>
<relation>2</relation>
<basevalueopen>181.50</basevalueopen>
</line>
<line type="detail" id="2">
<dim1 name="Omzet hoog" shortname="" dimensiontype="PNL">8000</dim1>
<debitcredit>credit</debitcredit>
<basevalue>100.00</basevalue>
<rate>1</rate>
<value>100.00</value>
<description>Consultancy</description>
<vatcode name="BTW Hoog" shortname="V Hoog" type="sales">VH</vatcode>
<vatbasevalue>21.00</vatbasevalue>
<vatvalue>21.00</vatvalue>
<matchstatus>notmatchable</matchstatus>
</line>
<line type="detail" id="3">
<dim1 name="Omzet hoog" shortname="" dimensiontype="PNL">8000</dim1>
<dim2 name="Algemeen" shortname="" dimensiontype="KPL">00100</dim2>
<dim3 name="Example project" shortname="" dimensiontype="PRJ">P0001</dim3>
<debitcredit>credit</debitcredit>
<basevalue>50.00</basevalue>
<rate>1</rate>
<value>50.00</value>
<description>Training</description>
<vatcode name="BTW Hoog" shortname="V Hoog" type="sales">VH</vatcode>
<vatbasevalue>10.50</vatbasevalue>
<vatvalue>10.50</vatvalue>
<matchstatus>notmatchable</matchstatus>
</line>
<line type="vat" id="4">
<dim1 name="Te betalen btw hoog" shortname="" dimensiontype="BAS">1530</dim1>
<debitcredit>credit</debitcredit>
<basevalue>31.50</basevalue>
<rate>1</rate>
<value>31.50</value>
<description>Btw</description>
<vatbaseturnover>150.00</vatbaseturnover>
<vatturnover>150.00</vatturnover>
<vatcode name="BTW Hoog" shortname="V Hoog" type="sales">VH</vatcode>
<vatbasevalue>0.00</vatbasevalue>
<vatvalue>0.00</vatvalue>
<baseline>1</baseline>
<matchstatus>available</matchstatus>
<matchlevel>1</matchlevel>
<relation>0</relation>
<basevalueopen>-31.50</basevalueopen>
</line>
</lines>
</transaction>

View examples/sales-transactions/read-sales-transaction/example.php on GitHub.

Made by SolveBeam

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