mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-19 10:53:31 +00:00
Code clean up.
This commit is contained in:
@@ -37,7 +37,6 @@ use FireflyIII\User;
|
||||
use Log;
|
||||
use Validator;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Class AccountRepository
|
||||
@@ -176,7 +175,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$this->deleteInitialBalance($newAccount);
|
||||
|
||||
return $newAccount;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,7 +209,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
if (!is_null($journal->id)) {
|
||||
$journal->delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,10 +273,10 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
// verify its creation:
|
||||
if (is_null($newAccount->id)) {
|
||||
Log::error(
|
||||
sprintf('Could not create account "%s" (%d error(s))', $data['name'], $newAccount->getErrors()->count()), $newAccount->getErrors()->toArray()
|
||||
sprintf('Could not create account "%s" (%d error(s))', $data['name'], $newAccount->getErrors()->count()),
|
||||
$newAccount->getErrors()->toArray()
|
||||
);
|
||||
throw new FireflyException(sprintf('Tried to create account named "%s" but failed. The logs have more details.', $data['name']));
|
||||
|
||||
}
|
||||
Log::debug(sprintf('Created new account #%d named "%s" of type %s.', $newAccount->id, $newAccount->name, $accountType->type));
|
||||
|
||||
@@ -424,7 +421,10 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
Log::debug(
|
||||
sprintf(
|
||||
'Created meta-field "%s":"%s" for account #%d ("%s") ',
|
||||
$field, $data[$field], $account->id, $account->name
|
||||
$field,
|
||||
$data[$field],
|
||||
$account->id,
|
||||
$account->name
|
||||
)
|
||||
);
|
||||
AccountMeta::create(
|
||||
@@ -443,12 +443,14 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
Log::debug(
|
||||
sprintf(
|
||||
'Updated meta-field "%s":"%s" for account #%d ("%s") ',
|
||||
$field, $data[$field], $account->id, $account->name
|
||||
$field,
|
||||
$data[$field],
|
||||
$account->id,
|
||||
$account->name
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -496,7 +498,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
Log::debug('Updated opening balance journal.');
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -159,5 +159,4 @@ interface AccountRepositoryInterface
|
||||
* @return Account
|
||||
*/
|
||||
public function update(Account $account, array $data): Account;
|
||||
|
||||
}
|
||||
|
@@ -65,5 +65,4 @@ interface AccountTaskerInterface
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user);
|
||||
|
||||
}
|
||||
|
@@ -120,7 +120,6 @@ trait FindAccountsTrait
|
||||
if (count($types) > 0) {
|
||||
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||
$query->whereIn('account_types.type', $types);
|
||||
|
||||
}
|
||||
Log::debug(sprintf('Searching for account named "%s" (of user #%d) of the following type(s)', $name, $this->user->id), ['types' => $types]);
|
||||
|
||||
|
@@ -168,13 +168,11 @@ class AttachmentRepository implements AttachmentRepositoryInterface
|
||||
*/
|
||||
public function update(Attachment $attachment, array $data): Attachment
|
||||
{
|
||||
|
||||
$attachment->title = $data['title'];
|
||||
$attachment->description = $data['description'];
|
||||
$attachment->notes = $data['notes'];
|
||||
$attachment->save();
|
||||
|
||||
return $attachment;
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -97,4 +97,3 @@ interface AttachmentRepositoryInterface
|
||||
*/
|
||||
public function update(Attachment $attachment, array $attachmentData): Attachment;
|
||||
}
|
||||
|
||||
|
@@ -125,7 +125,6 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
$set = $set->sortBy(
|
||||
function (Bill $bill) {
|
||||
|
||||
$int = $bill->active ? 0 : 1;
|
||||
|
||||
return $int . strtolower($bill->name);
|
||||
@@ -161,14 +160,16 @@ class BillRepository implements BillRepositoryInterface
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
$set = $this->user->bills()
|
||||
->leftJoin(
|
||||
'transaction_journals', function (JoinClause $join) {
|
||||
$join->on('transaction_journals.bill_id', '=', 'bills.id')->whereNull('transaction_journals.deleted_at');
|
||||
}
|
||||
'transaction_journals',
|
||||
function (JoinClause $join) {
|
||||
$join->on('transaction_journals.bill_id', '=', 'bills.id')->whereNull('transaction_journals.deleted_at');
|
||||
}
|
||||
)
|
||||
->leftJoin(
|
||||
'transactions', function (JoinClause $join) {
|
||||
$join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '<', 0);
|
||||
}
|
||||
'transactions',
|
||||
function (JoinClause $join) {
|
||||
$join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '<', 0);
|
||||
}
|
||||
)
|
||||
->whereIn('transactions.account_id', $ids)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
@@ -177,7 +178,6 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
$set = $set->sortBy(
|
||||
function (Bill $bill) {
|
||||
|
||||
$int = $bill->active === 1 ? 0 : 1;
|
||||
|
||||
return $int . strtolower($bill->name);
|
||||
@@ -238,7 +238,6 @@ class BillRepository implements BillRepositoryInterface
|
||||
Log::debug(sprintf('Dates = %d, journalCount = %d, total = %d', $dates->count(), $count, $total));
|
||||
|
||||
if ($total > 0) {
|
||||
|
||||
$average = bcdiv(bcadd($bill->amount_max, $bill->amount_min), '2');
|
||||
$multi = bcmul($average, strval($total));
|
||||
$sum = bcadd($sum, $multi);
|
||||
@@ -285,7 +284,6 @@ class BillRepository implements BillRepositoryInterface
|
||||
$dates = $bill->transactionJournals()->before($end)->after($start)->get(['transaction_journals.date'])->pluck('date');
|
||||
|
||||
return $dates;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -519,7 +517,6 @@ class BillRepository implements BillRepositoryInterface
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -565,8 +562,6 @@ class BillRepository implements BillRepositoryInterface
|
||||
*/
|
||||
public function update(Bill $bill, array $data): Bill
|
||||
{
|
||||
|
||||
|
||||
$bill->name = $data['name'];
|
||||
$bill->match = $data['match'];
|
||||
$bill->amount_min = $data['amount_min'];
|
||||
|
@@ -188,5 +188,4 @@ interface BillRepositoryInterface
|
||||
* @return Bill
|
||||
*/
|
||||
public function update(Bill $bill, array $data): Bill;
|
||||
|
||||
}
|
||||
|
@@ -72,7 +72,6 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,7 +228,6 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
}
|
||||
|
||||
return $oldest;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -396,7 +394,6 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -219,5 +219,4 @@ interface BudgetRepositoryInterface
|
||||
* @return BudgetLimit
|
||||
*/
|
||||
public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, int $amount): BudgetLimit;
|
||||
|
||||
}
|
||||
|
@@ -547,5 +547,4 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Currency;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\CurrencyExchangeRate;
|
||||
use FireflyIII\Models\Preference;
|
||||
@@ -228,8 +227,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
}
|
||||
|
||||
return new CurrencyExchangeRate;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Currency;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\CurrencyExchangeRate;
|
||||
use FireflyIII\Models\Preference;
|
||||
@@ -142,5 +141,4 @@ interface CurrencyRepositoryInterface
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
public function update(TransactionCurrency $currency, array $data): TransactionCurrency;
|
||||
|
||||
}
|
||||
|
@@ -103,11 +103,9 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
||||
return $exportJob;
|
||||
}
|
||||
$count++;
|
||||
|
||||
}
|
||||
|
||||
return new ExportJob;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -76,5 +76,4 @@ interface ExportJobRepositoryInterface
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user);
|
||||
|
||||
}
|
||||
|
@@ -81,7 +81,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
||||
return $importJob;
|
||||
}
|
||||
$count++;
|
||||
|
||||
}
|
||||
|
||||
return new ImportJob;
|
||||
@@ -115,7 +114,8 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
||||
// demo user's configuration upload is ignored completely.
|
||||
if (!$repository->hasRole($this->user, 'demo')) {
|
||||
Log::debug(
|
||||
'Uploaded configuration file', ['name' => $file->getClientOriginalName(), 'size' => $file->getSize(), 'mime' => $file->getClientMimeType()]
|
||||
'Uploaded configuration file',
|
||||
['name' => $file->getClientOriginalName(), 'size' => $file->getSize(), 'mime' => $file->getClientMimeType()]
|
||||
);
|
||||
|
||||
$configFileObject = new SplFileObject($file->getRealPath());
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
|
||||
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Note;
|
||||
@@ -205,7 +204,6 @@ trait CreateJournalsTrait
|
||||
}
|
||||
|
||||
return $transaction;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -166,7 +166,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
$entry = $this->user->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']);
|
||||
|
||||
if (is_null($entry)) {
|
||||
|
||||
return new TransactionJournal;
|
||||
}
|
||||
|
||||
@@ -214,7 +213,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
$opposing->save();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,7 +319,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
$journal->save();
|
||||
|
||||
return $journal;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -149,5 +149,4 @@ interface JournalRepositoryInterface
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function updateSplitJournal(TransactionJournal $journal, array $data): TransactionJournal;
|
||||
|
||||
}
|
||||
|
@@ -86,13 +86,14 @@ class JournalTasker implements JournalTaskerInterface
|
||||
$set = $journal
|
||||
->transactions()// "source"
|
||||
->leftJoin(
|
||||
'transactions as destination', function (JoinClause $join) {
|
||||
$join
|
||||
'transactions as destination',
|
||||
function (JoinClause $join) {
|
||||
$join
|
||||
->on('transactions.transaction_journal_id', '=', 'destination.transaction_journal_id')
|
||||
->where('transactions.amount', '=', DB::raw('destination.amount * -1'))
|
||||
->where('transactions.identifier', '=', DB::raw('destination.identifier'))
|
||||
->whereNull('destination.deleted_at');
|
||||
}
|
||||
}
|
||||
)
|
||||
->with(['budgets', 'categories'])
|
||||
->leftJoin('accounts as source_accounts', 'transactions.account_id', '=', 'source_accounts.id')
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
@@ -81,7 +81,6 @@ trait SupportJournalsTrait
|
||||
if (is_null($accounts['destination'])) {
|
||||
Log::error('"destination"-account is null, so we cannot continue!', ['data' => $data]);
|
||||
throw new FireflyException('"destination"-account is null, so we cannot continue!');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
|
||||
|
||||
use DB;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
@@ -96,7 +95,6 @@ trait UpdateJournalsTrait
|
||||
$transaction->foreign_currency_id = $data['foreign_currency_id'];
|
||||
$transaction->account_id = $account->id;
|
||||
$transaction->save();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -106,8 +106,6 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
$opposingCount = TransactionJournalLink::whereDestinationId($two->id)->whereSourceId($one->id)->count();
|
||||
|
||||
return ($count + $opposingCount > 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,6 +185,5 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
$linkType->save();
|
||||
|
||||
return $linkType;
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -109,5 +109,4 @@ interface LinkTypeRepositoryInterface
|
||||
* @return LinkType
|
||||
*/
|
||||
public function update(LinkType $linkType, array $data): LinkType;
|
||||
|
||||
}
|
||||
|
@@ -365,7 +365,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
*/
|
||||
public function update(PiggyBank $piggyBank, array $data): PiggyBank
|
||||
{
|
||||
|
||||
$piggyBank->name = $data['name'];
|
||||
$piggyBank->account_id = intval($data['account_id']);
|
||||
$piggyBank->targetamount = round($data['targetamount'], 2);
|
||||
@@ -380,7 +379,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
// remove money from the rep.
|
||||
$repetition = $piggyBank->currentRelevantRep();
|
||||
if ($repetition->currentamount > $piggyBank->targetamount) {
|
||||
|
||||
$diff = bcsub($piggyBank->targetamount, $repetition->currentamount);
|
||||
$this->createEvent($piggyBank, $diff);
|
||||
|
||||
|
@@ -230,7 +230,6 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,7 +372,6 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -147,5 +147,4 @@ interface RuleRepositoryInterface
|
||||
* @return Rule
|
||||
*/
|
||||
public function update(Rule $rule, array $data): Rule;
|
||||
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\RuleGroup;
|
||||
|
||||
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\User;
|
||||
@@ -58,9 +57,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
{
|
||||
/** @var Rule $rule */
|
||||
foreach ($ruleGroup->rules as $rule) {
|
||||
|
||||
if (is_null($moveTo)) {
|
||||
|
||||
$rule->delete();
|
||||
continue;
|
||||
}
|
||||
@@ -167,7 +164,6 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
'rules' => function (HasMany $query) {
|
||||
$query->orderBy('active', 'DESC');
|
||||
$query->orderBy('order', 'ASC');
|
||||
|
||||
},
|
||||
'rules.ruleTriggers' => function (HasMany $query) {
|
||||
$query->orderBy('order', 'ASC');
|
||||
@@ -267,7 +263,6 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\RuleGroup;
|
||||
|
||||
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -141,6 +140,4 @@ interface RuleGroupRepositoryInterface
|
||||
* @return RuleGroup
|
||||
*/
|
||||
public function update(RuleGroup $ruleGroup, array $data): RuleGroup;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Tag;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
@@ -252,8 +251,6 @@ class TagRepository implements TagRepositoryInterface
|
||||
$tag->save();
|
||||
|
||||
return $tag;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -435,7 +432,6 @@ class TagRepository implements TagRepositoryInterface
|
||||
|
||||
// no difference? Every tag same range:
|
||||
if ($amountDiff === 0.0) {
|
||||
|
||||
return $range[0];
|
||||
}
|
||||
|
||||
|
@@ -29,7 +29,6 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
/**
|
||||
* Interface TagRepositoryInterface
|
||||
*
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\User;
|
||||
|
||||
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\Role;
|
||||
use FireflyIII\User;
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\User;
|
||||
|
||||
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
Reference in New Issue
Block a user