Skip to content

Commit

Permalink
Rematch all temptransactions after unbooking any transaction
Browse files Browse the repository at this point in the history
Since a new document is available, it might be matched to any other temp transaction
  • Loading branch information
ImanuelBertrand committed Sep 6, 2023
1 parent 2764ebf commit 93275c8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Service/Booker.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@ public function unbook(Transaction|int $transaction): void

$this->tempTransactionResource->save($tempTransaction);
$this->transactionRepository->delete($transaction);

// With unbooking, the document is now free to be matched again, which can potentially affect other
// temp transactions. Therefore, we need to recalculate the match confidence for all temp transactions.
$allTempTransactions = $this->tempTransactionCollectionFactory->create();
foreach ($allTempTransactions as $tempTransaction) {
$tempTransaction->setIsDirty(TempTransaction::DIRTY);
$tempTransaction->setHasDataChanges(true);
$this->tempTransactionRepository->save($tempTransaction);
}

$db->commit();
} catch (Exception $e) {
$db->rollBack();
Expand Down

0 comments on commit 93275c8

Please sign in to comment.