Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Withdrawal directly from Piggy Bank - Fixes #6631
Christian Desktop74992e95f279
diff --git a/app/Console/Commands/Correction/FixPiggies.php b/app/Console/Commands/Correction/FixPiggies.phpindex 8d2bca27c0..a7f98d9fb9 100644--- a/app/Console/Commands/Correction/FixPiggies.php+++ b/app/Console/Commands/Correction/FixPiggies.php@@ -25,11 +25,10 @@ namespace FireflyIII\Console\Commands\Correction;use FireflyIII\Models\PiggyBankEvent;use FireflyIII\Models\TransactionJournal;-use FireflyIII\Models\TransactionType;use Illuminate\Console\Command;/**- * Report (and fix) piggy banks. Make sure there are only transfers linked to piggy bank events.+ * Report (and fix) piggy banks.** Class FixPiggies*/@@ -57,7 +56,7 @@ class FixPiggies extends Command{$count = 0;$start = microtime(true);- $set = PiggyBankEvent::with(['PiggyBank', 'TransactionJournal', 'TransactionJournal.TransactionType'])->get();+ $set = PiggyBankEvent::with(['PiggyBank', 'TransactionJournal'])->get();/** @var PiggyBankEvent $event */foreach ($set as $event) {@@ -73,15 +72,6 @@ class FixPiggies extends Command$count++;continue;}--- $type = $journal->transactionType->type;- if (TransactionType::TRANSFER !== $type) {- $event->transaction_journal_id = null;- $event->save();- $this->line(sprintf('Piggy bank #%d was referenced by an invalid event. This has been fixed.', $event->piggy_bank_id));- $count++;- }}if (0 === $count) {$this->line('All piggy bank events are correct.');diff --git a/app/Factory/PiggyBankEventFactory.php b/app/Factory/PiggyBankEventFactory.phpindex 3cfe576a91..09b4be3b31 100644--- a/app/Factory/PiggyBankEventFactory.php+++ b/app/Factory/PiggyBankEventFactory.php@@ -49,12 +49,6 @@ class PiggyBankEventFactoryreturn;}- if (TransactionType::TRANSFER !== $journal->transactionType->type) {- Log::info(sprintf('Will not connect %s #%d to a piggy bank.', $journal->transactionType->type, $journal->id));-- return;- }-/** @var PiggyBankRepositoryInterface $piggyRepos */$piggyRepos = app(PiggyBankRepositoryInterface::class);$piggyRepos->setUser($journal->user);diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.phpindex d5eb723a6e..3df1293a52 100644--- a/app/Factory/TransactionJournalFactory.php+++ b/app/Factory/TransactionJournalFactory.php@@ -569,11 +569,6 @@ class TransactionJournalFactoryprivate function storePiggyEvent(TransactionJournal $journal, NullArrayObject $data): void{Log::debug('Will now store piggy event.');- if (!$journal->isTransfer()) {- Log::debug('Journal is not a transfer, do nothing.');-- return;- }$piggyBank = $this->piggyRepository->findPiggyBank((int)$data['piggy_bank_id'], $data['piggy_bank_name']);diff --git a/app/TransactionRules/Actions/UpdatePiggybank.php b/app/TransactionRules/Actions/UpdatePiggybank.phpindex 2f13ca31b0..96a14032ce 100644--- a/app/TransactionRules/Actions/UpdatePiggybank.php+++ b/app/TransactionRules/Actions/UpdatePiggybank.php@@ -65,12 +65,6 @@ class UpdatePiggybank implements ActionInterface$type = TransactionType::find((int)$journalObj->transaction_type_id);$journal['transaction_type_type'] = $type->type;- if (TransactionType::TRANSFER !== $journal['transaction_type_type']) {- Log::info(sprintf('Journal #%d is a "%s" so skip this action.', $journal['transaction_journal_id'], $journal['transaction_type_type']));-- return false;- }-$piggyBank = $this->findPiggyBank($user);if (null === $piggyBank) {Log::info(diff --git a/resources/assets/js/components/transactions/PiggyBank.vue b/resources/assets/js/components/transactions/PiggyBank.vueindex 14585aee65..fd0472892f 100644--- a/resources/assets/js/components/transactions/PiggyBank.vue+++ b/resources/assets/js/components/transactions/PiggyBank.vue@@ -18,7 +18,7 @@- along with this program. If not, see <https://www.gnu.org/licenses/>.--><template>- <div v-if="typeof this.transactionType !== 'undefined' && this.transactionType === 'Transfer'"+ <div v-if="typeof this.transactionType !== 'undefined'"class="form-group"v-bind:class="{ 'has-error': hasError()}"><div class="col-sm-12 text-sm">