mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-15 19:09:50 +00:00
Update transactions, delete splits.
This commit is contained in:
@@ -57,6 +57,7 @@ class JournalUpdateService
|
||||
*
|
||||
* @return TransactionJournal
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function update(TransactionJournal $journal, array $data): TransactionJournal
|
||||
{
|
||||
@@ -94,6 +95,14 @@ class JournalUpdateService
|
||||
// otherwise, create!
|
||||
$factory->createPair($journal, $trData);
|
||||
}
|
||||
// could be that journal has more transactions than submitted (remove split)
|
||||
$transactions = $journal->transactions()->where('amount', '>', 0)->get();
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
if (!isset($data['transactions'][$transaction->identifier])) {
|
||||
$journal->transactions()->where('identifier', $transaction->identifier)->delete();
|
||||
}
|
||||
}
|
||||
|
||||
// connect bill:
|
||||
$this->connectBill($journal, $data);
|
||||
|
||||
Reference in New Issue
Block a user