Skip to content

Read spread

Reads the spread of a sales or purchase transaction: the intermediate account, the periods and the spread transactions Twinfield made for it.

Twinfield documentation: Spread transactions.

A spread divides the costs or revenue of one invoice over a number of periods, e.g. a yearly subscription over twelve months (kosten- of opbrengstenverdeling).

get($dayBook, $number) returns a Spread:

  • $spread->original: the transaction you asked for (company, day book and number).
  • $spread->settings: the spread settings, or null when the transaction is not spread. intermediateAccount is the balance sheet account the amounts are spread from. The periods are either the same for the whole transaction (startPeriod and endPeriod) or set per detail line (lines, when isByLines() is true).
  • $spread->spreadTransactions: the transactions Twinfield made, each a TransactionReference. One moves the amounts of the detail lines to the intermediate account in the period of the original transaction; the others spread them from there over the periods. Read them with journalTransactions()->get().

Only sales and purchase transactions can be spread. Twinfield refusals are thrown as ProcessXmlException.

$twinfield = Example::twinfield();
// E.g. `INK 202600021`: day book and number of a sales or purchase transaction.
[, $dayBook, $number] = array_pad($argv ?? [], 3, null);
if ($dayBook === null || $number === null) {
echo 'Usage: php example.php <day book> <transaction number>', PHP_EOL;
exit(0);
}
try {
$spread = $twinfield->spreadTransactions()->get($dayBook, (int) $number);
} catch (ProcessXmlException $exception) {
echo 'Refused: ', $exception->getMessage(), PHP_EOL;
exit(1);
}
echo 'Original: ', $spread->original->dayBook, ' ', $spread->original->number, PHP_EOL;
if ($spread->settings === null) {
echo 'Not spread.', PHP_EOL;
exit(0);
}
echo 'Intermediate account: ', $spread->settings->intermediateAccount, PHP_EOL;
if ($spread->settings->isByLines()) {
foreach ($spread->settings->lines as $line) {
echo 'Line ', $line->lineId, ': ', $line->startPeriod, ' to ', $line->endPeriod, PHP_EOL;
}
} else {
echo 'Periods: ', $spread->settings->startPeriod, ' to ', $spread->settings->endPeriod, PHP_EOL;
}
foreach ($spread->spreadTransactions as $transaction) {
echo 'Spread transaction: ', $transaction->dayBook, ' ', $transaction->number, PHP_EOL;
}
Terminal window
php examples/spread-transactions/read-spread/example.php INK 202600021

The output below follows the documentation; it was not run live yet.

Original: INK 202600021
Intermediate account: 2500
Periods: 2026/01 to 2026/02
Spread transaction: KOSTENVERDELING 202600002
Spread transaction: KOSTENVERDELING 202600003
Spread transaction: KOSTENVERDELING 202600004

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: Spread transactions: Get.

$twinfield->spreadTransactions()->get('INK', 202600001);

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

<spread action="getspreadtransactioninfo">
<original>
<office>1000</office>
<code>INK</code>
<number>202600001</number>
</original>
</spread>

Twinfield answers with this XML in ProcessXmlStringResult:

<spread result="1" action="getspreadtransactioninfo">
<original>
<office>1000</office>
<code>INK</code>
<number>202600001</number>
</original>
<settings>
<dim1>2500</dim1>
<startperiod>2026/01</startperiod>
<endperiod>2026/02</endperiod>
</settings>
<spreadtransactions>
<spreadtransaction>
<office>1000</office>
<code>KOSTENVERDELING</code>
<number>202600002</number>
</spreadtransaction>
<spreadtransaction>
<office>1000</office>
<code>KOSTENVERDELING</code>
<number>202600003</number>
</spreadtransaction>
<spreadtransaction>
<office>1000</office>
<code>KOSTENVERDELING</code>
<number>202600004</number>
</spreadtransaction>
</spreadtransactions>
</spread>

View examples/spread-transactions/read-spread/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.