Merge pull request #7535 from ChrisWin22/withdraw-from-piggy-banks

Withdraw from piggy banks
This commit is contained in:
James Cole 2023-05-24 08:22:41 +02:00 committed by GitHub
commit f711fcfd52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 3 additions and 30 deletions

View File

@ -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.');

View File

@ -49,12 +49,6 @@ class PiggyBankEventFactory
return;
}
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);

View File

@ -569,11 +569,6 @@ class TransactionJournalFactory
private 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']);

View File

@ -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(

View File

@ -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">