Respond to currency changes.

This commit is contained in:
James Cole
2024-12-21 07:12:11 +01:00
parent 7fd5a88122
commit b52a1f3eb1
15 changed files with 234 additions and 45 deletions

View File

@@ -98,12 +98,12 @@ class UpgradeMultiPiggyBanks extends Command
// update piggy bank to have a currency.
$piggyBank->transaction_currency_id = $currency->id;
$piggyBank->save();
$piggyBank->saveQuietly();
// store current amount in account association.
$piggyBank->accounts()->sync([$piggyBank->account->id => ['current_amount' => $repetition->current_amount]]);
$piggyBank->account_id = null;
$piggyBank->save();
$piggyBank->saveQuietly();
// remove all repetitions (no longer used)
$piggyBank->piggyBankRepetitions()->delete();