Skip to content

List deleted transactions

Shows the transactions that were deleted in the last 30 days, newest first: day book, number, date of the transaction, when and by whom it was deleted, and why.

Twinfield documentation: Deleted transactions.

Deleted transactions come from the DeletedTransactionsService, a Command & Query web service, so the client needs a company (company('1000')); Example::twinfield() uses your default company.

  • deletedTransactions()->list(): all deleted transactions of the company, of all day books (bank, cash, sales, purchase, journal, …), as DeletedTransaction objects with dayBook, number, transactionDate, deletionDate, user and reason.
  • list(dayBook: 'BNK'): only one day book. An unknown day book gives a CommandQueryFaultException with errorCode InvalidDaybook (see DeletedTransactionsServiceFaultCode).
  • list(from: …, to: …): deleted between two days. Only the date counts, not the time, and both days are included.

This is useful to keep a copy of the transactions in sync: transactions deleted in Twinfield itself show up here too. Without filters you get every deleted transaction of the company, which can be thousands: Twinfield has no paging, so filter on a date when you can.

$twinfield = Example::twinfield();
$days = (int) ($argv[1] ?? 30);
$dayBook = $argv[2] ?? null;
$from = new DateTimeImmutable(sprintf('-%d days', $days));
$transactions = $twinfield->deletedTransactions()->list(dayBook: $dayBook, from: $from);
echo 'Company ', $twinfield->companyCode(), PHP_EOL;
echo count($transactions), ' transaction(s) deleted since ', $from->format('Y-m-d');
echo $dayBook === null ? '' : ' in day book ' . $dayBook, PHP_EOL;
foreach ($transactions as $index => $transaction) {
echo sprintf(
'[%d/%d] %s %d (dated %s) deleted %s by %s: %s',
$index + 1,
count($transactions),
$transaction->dayBook,
$transaction->number,
$transaction->transactionDate->format('Y-m-d'),
$transaction->deletionDate->format('Y-m-d H:i'),
$transaction->user,
$transaction->reason,
), PHP_EOL;
}
Terminal window
php examples/deleted-transactions/list-deleted-transactions/example.php # last 30 days
php examples/deleted-transactions/list-deleted-transactions/example.php 365 BNK # last year, day book BNK

Add TWINFIELD_DEBUG=1 to see the SOAP request and response.

Company 1000
3 transaction(s) deleted since 2026-10-10
[1/3] MEMO 202600018 (dated 2026-11-03) deleted 2026-11-04 05:31 by JDOE: Test data
[2/3] INK 202600231 (dated 2026-10-28) deleted 2026-10-30 14:02 by JDOE: Entered twice
[3/3] BNK 202600045 (dated 2026-10-12) deleted 2026-10-12 16:47 by ADMIN: Wrong statement

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: Deleted transactions: GetDeletedTransactions.

$twinfield->deletedTransactions()->list();

The SDK sends this in the SOAP body to DeletedTransactionsService.svc, with SOAPAction http://www.twinfield.com/DeletedTransactionsService/Query; the access token goes in the SOAP header:

<Query xmlns="http://www.twinfield.com/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:a="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.DeletedTransactionsService" i:type="a:GetDeletedTransactions">
<a:CompanyCode>1000</a:CompanyCode>
</Query>

Twinfield answers with this SOAP body:

<Result xmlns="http://www.twinfield.com/" xmlns:a="http://schemas.datacontract.org/2004/07/Twinfield.WebServices" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:b="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.DeletedTransactionsService" i:type="b:GetDeletedTransactionsResult">
<b:DeletedTransactions>
<b:DeletedTransaction>
<b:Daybook>HGSF</b:Daybook>
<b:DeletionDate>2024-08-02T11:55:10.883</b:DeletionDate>
<b:ReasonForDeletion>Riqk</b:ReasonForDeletion>
<b:TransactionDate>2024-07-27T00:00:00</b:TransactionDate>
<b:TransactionNumber>965764205</b:TransactionNumber>
<b:User>AVTZ</b:User>
</b:DeletedTransaction>
<b:DeletedTransaction>
<b:Daybook>GWPO</b:Daybook>
<b:DeletionDate>2023-02-16T15:18:02.533</b:DeletionDate>
<b:ReasonForDeletion>Tvgi</b:ReasonForDeletion>
<b:TransactionDate>2023-02-16T00:00:00</b:TransactionDate>
<b:TransactionNumber>752708213</b:TransactionNumber>
<b:User>HXPEQ</b:User>
</b:DeletedTransaction>
<!-- 17 more b:DeletedTransaction elements -->
</b:DeletedTransactions>
</Result>

View examples/deleted-transactions/list-deleted-transactions/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.