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, ornullwhen the transaction is not spread.intermediateAccountis the balance sheet account the amounts are spread from. The periods are either the same for the whole transaction (startPeriodandendPeriod) or set per detail line (lines, whenisByLines()is true).$spread->spreadTransactions: the transactions Twinfield made, each aTransactionReference. 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 withjournalTransactions()->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;}php examples/spread-transactions/read-spread/example.php INK 202600021The output below follows the documentation; it was not run live yet.
Original: INK 202600021Intermediate account: 2500Periods: 2026/01 to 2026/02Spread transaction: KOSTENVERDELING 202600002Spread transaction: KOSTENVERDELING 202600003Spread transaction: KOSTENVERDELING 202600004What 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>Source
Section titled “Source”View examples/spread-transactions/read-spread/example.php on GitHub.
Twinfield and Wolters Kluwer are trademarks of Wolters Kluwer. Their names and logos are used only to refer to their products.