mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Various code cleanup.
This commit is contained in:
@@ -221,7 +221,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function getCashAccount(): Account
|
||||
{
|
||||
/** @var AccountType $type */
|
||||
@@ -342,7 +342,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function getReconciliation(Account $account): ?Account
|
||||
{
|
||||
if (AccountType::ASSET !== $account->accountType->type) {
|
||||
@@ -617,7 +617,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function store(array $data): Account
|
||||
{
|
||||
/** @var AccountFactory $factory */
|
||||
@@ -629,7 +629,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function update(Account $account, array $data): Account
|
||||
{
|
||||
/** @var AccountUpdateService $service */
|
||||
|
@@ -42,7 +42,7 @@ class AccountTasker implements AccountTaskerInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function getAccountReport(Collection $accounts, Carbon $start, Carbon $end): array
|
||||
{
|
||||
$yesterday = clone $start;
|
||||
@@ -109,7 +109,7 @@ class AccountTasker implements AccountTaskerInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function getExpenseReport(Carbon $start, Carbon $end, Collection $accounts): array
|
||||
{
|
||||
// get all expenses for the given accounts in the given period!
|
||||
@@ -140,7 +140,7 @@ class AccountTasker implements AccountTaskerInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function getIncomeReport(Carbon $start, Carbon $end, Collection $accounts): array
|
||||
{
|
||||
// get all incomes for the given accounts in the given period!
|
||||
@@ -175,7 +175,7 @@ class AccountTasker implements AccountTaskerInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
private function groupExpenseByDestination(array $array): array
|
||||
{
|
||||
$defaultCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);
|
||||
@@ -235,7 +235,7 @@ class AccountTasker implements AccountTaskerInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
private function groupIncomeBySource(array $array): array
|
||||
{
|
||||
$defaultCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);
|
||||
|
@@ -218,6 +218,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
|
||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||
*/
|
||||
private function getTransactionsForSum(
|
||||
string $type,
|
||||
|
@@ -421,8 +421,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
/**
|
||||
* Given the date in $date, this method will return a moment in the future where the bill is expected to be paid.
|
||||
*
|
||||
* */
|
||||
*/
|
||||
public function nextExpectedMatch(Bill $bill, Carbon $date): Carbon
|
||||
{
|
||||
$cache = new CacheProperties();
|
||||
@@ -463,7 +462,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function store(array $data): Bill
|
||||
{
|
||||
/** @var BillFactory $factory */
|
||||
@@ -643,7 +642,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function update(Bill $bill, array $data): Bill
|
||||
{
|
||||
/** @var BillUpdateService $service */
|
||||
|
@@ -261,7 +261,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function store(array $data): BudgetLimit
|
||||
{
|
||||
// if no currency has been provided, use the user's default currency:
|
||||
@@ -316,7 +316,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function update(BudgetLimit $budgetLimit, array $data): BudgetLimit
|
||||
{
|
||||
$budgetLimit->amount = array_key_exists('amount', $data) ? $data['amount'] : $budgetLimit->amount;
|
||||
|
@@ -97,7 +97,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
app('log')->debug(sprintf('Budget limit #%d', $limit->id));
|
||||
$currency = $limit->transactionCurrency;
|
||||
$return[$currency->id] ??= [
|
||||
'id' => (string)$currency->id,
|
||||
'id' => (string) $currency->id,
|
||||
'name' => $currency->name,
|
||||
'symbol' => $currency->symbol,
|
||||
'code' => $currency->code,
|
||||
@@ -120,12 +120,12 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
}
|
||||
$total = $limit->start_date->diffInDays($limit->end_date) + 1; // include the day itself.
|
||||
$days = $this->daysInOverlap($limit, $start, $end);
|
||||
$amount = bcmul(bcdiv($limit->amount, (string)$total), (string)$days);
|
||||
$amount = bcmul(bcdiv($limit->amount, (string) $total), (string) $days);
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $amount);
|
||||
app('log')->debug(
|
||||
sprintf(
|
||||
'Amount per day: %s (%s over %d days). Total amount for %d days: %s',
|
||||
bcdiv($limit->amount, (string)$total),
|
||||
bcdiv($limit->amount, (string) $total),
|
||||
$limit->amount,
|
||||
$total,
|
||||
$days,
|
||||
@@ -171,7 +171,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
app('log')->debug(sprintf('Budget limit #%d', $limit->id));
|
||||
$currency = $limit->transactionCurrency;
|
||||
$return[$currency->id] ??= [
|
||||
'id' => (string)$currency->id,
|
||||
'id' => (string) $currency->id,
|
||||
'name' => $currency->name,
|
||||
'symbol' => $currency->symbol,
|
||||
'code' => $currency->code,
|
||||
@@ -194,12 +194,12 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
}
|
||||
$total = $limit->start_date->diffInDays($limit->end_date) + 1; // include the day itself.
|
||||
$days = $this->daysInOverlap($limit, $start, $end);
|
||||
$amount = bcmul(bcdiv($limit->amount, (string)$total), (string)$days);
|
||||
$amount = bcmul(bcdiv($limit->amount, (string) $total), (string) $days);
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $amount);
|
||||
app('log')->debug(
|
||||
sprintf(
|
||||
'Amount per day: %s (%s over %d days). Total amount for %d days: %s',
|
||||
bcdiv($limit->amount, (string)$total),
|
||||
bcdiv($limit->amount, (string) $total),
|
||||
$limit->amount,
|
||||
$total,
|
||||
$days,
|
||||
@@ -233,7 +233,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function update(Budget $budget, array $data): Budget
|
||||
{
|
||||
app('log')->debug('Now in update()');
|
||||
@@ -248,7 +248,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$budget->active = $data['active'];
|
||||
}
|
||||
if (array_key_exists('notes', $data)) {
|
||||
$this->setNoteText($budget, (string)$data['notes']);
|
||||
$this->setNoteText($budget, (string) $data['notes']);
|
||||
}
|
||||
$budget->save();
|
||||
|
||||
@@ -310,8 +310,8 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
foreach ($budgets as $budget) {
|
||||
\DB::table('budget_transaction')->where('budget_id', $budget->id)->delete();
|
||||
\DB::table('budget_transaction_journal')->where('budget_id', $budget->id)->delete();
|
||||
RecurrenceTransactionMeta::where('name', 'budget_id')->where('value', (string)$budget->id)->delete();
|
||||
RuleAction::where('action_type', 'set_budget')->where('action_value', (string)$budget->id)->delete();
|
||||
RecurrenceTransactionMeta::where('name', 'budget_id')->where('value', (string) $budget->id)->delete();
|
||||
RuleAction::where('action_type', 'set_budget')->where('action_value', (string) $budget->id)->delete();
|
||||
$budget->delete();
|
||||
}
|
||||
}
|
||||
@@ -335,7 +335,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
{
|
||||
app('log')->debug('Now in findBudget()');
|
||||
app('log')->debug(sprintf('Searching for budget with ID #%d...', $budgetId));
|
||||
$result = $this->find((int)$budgetId);
|
||||
$result = $this->find((int) $budgetId);
|
||||
if (null === $result && null !== $budgetName && '' !== $budgetName) {
|
||||
app('log')->debug(sprintf('Searching for budget with name %s...', $budgetName));
|
||||
$result = $this->findByName($budgetName);
|
||||
@@ -471,9 +471,9 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$array = [];
|
||||
|
||||
foreach ($journals as $journal) {
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$array[$currencyId] ??= [
|
||||
'id' => (string)$currencyId,
|
||||
'id' => (string) $currencyId,
|
||||
'name' => $journal['currency_name'],
|
||||
'symbol' => $journal['currency_symbol'],
|
||||
'code' => $journal['currency_code'],
|
||||
@@ -483,10 +483,10 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($journal['amount']));
|
||||
|
||||
// also do foreign amount:
|
||||
$foreignId = (int)$journal['foreign_currency_id'];
|
||||
$foreignId = (int) $journal['foreign_currency_id'];
|
||||
if (0 !== $foreignId) {
|
||||
$array[$foreignId] ??= [
|
||||
'id' => (string)$foreignId,
|
||||
'id' => (string) $foreignId,
|
||||
'name' => $journal['foreign_currency_name'],
|
||||
'symbol' => $journal['foreign_currency_symbol'],
|
||||
'code' => $journal['foreign_currency_code'],
|
||||
@@ -533,9 +533,9 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$array = [];
|
||||
|
||||
foreach ($journals as $journal) {
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$array[$currencyId] ??= [
|
||||
'id' => (string)$currencyId,
|
||||
'id' => (string) $currencyId,
|
||||
'name' => $journal['currency_name'],
|
||||
'symbol' => $journal['currency_symbol'],
|
||||
'code' => $journal['currency_code'],
|
||||
@@ -545,10 +545,10 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($journal['amount']));
|
||||
|
||||
// also do foreign amount:
|
||||
$foreignId = (int)$journal['foreign_currency_id'];
|
||||
$foreignId = (int) $journal['foreign_currency_id'];
|
||||
if (0 !== $foreignId) {
|
||||
$array[$foreignId] ??= [
|
||||
'id' => (string)$foreignId,
|
||||
'id' => (string) $foreignId,
|
||||
'name' => $journal['foreign_currency_name'],
|
||||
'symbol' => $journal['foreign_currency_symbol'],
|
||||
'code' => $journal['foreign_currency_code'],
|
||||
@@ -564,7 +564,9 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||
*/
|
||||
public function store(array $data): Budget
|
||||
{
|
||||
$order = $this->getMaxOrder();
|
||||
@@ -588,7 +590,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
|
||||
// set notes
|
||||
if (array_key_exists('notes', $data)) {
|
||||
$this->setNoteText($newBudget, (string)$data['notes']);
|
||||
$this->setNoteText($newBudget, (string) $data['notes']);
|
||||
}
|
||||
|
||||
if (!array_key_exists('auto_budget_type', $data) || !array_key_exists('auto_budget_amount', $data) || !array_key_exists('auto_budget_period', $data)) {
|
||||
@@ -616,10 +618,10 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
$currency = null;
|
||||
if (array_key_exists('currency_id', $data)) {
|
||||
$currency = $repos->find((int)$data['currency_id']);
|
||||
$currency = $repos->find((int) $data['currency_id']);
|
||||
}
|
||||
if (array_key_exists('currency_code', $data)) {
|
||||
$currency = $repos->findByCode((string)$data['currency_code']);
|
||||
$currency = $repos->findByCode((string) $data['currency_code']);
|
||||
}
|
||||
if (null === $currency) {
|
||||
$currency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);
|
||||
@@ -655,7 +657,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
|
||||
public function getMaxOrder(): int
|
||||
{
|
||||
return (int)$this->user->budgets()->max('order');
|
||||
return (int) $this->user->budgets()->max('order');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -750,7 +752,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
private function updateAutoBudget(Budget $budget, array $data): void
|
||||
{
|
||||
// update or create auto-budget:
|
||||
@@ -771,8 +773,8 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {
|
||||
/** @var CurrencyRepositoryInterface $repos */
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
$currencyId = (int)($data['currency_id'] ?? 0);
|
||||
$currencyCode = (string)($data['currency_code'] ?? '');
|
||||
$currencyId = (int) ($data['currency_id'] ?? 0);
|
||||
$currencyCode = (string) ($data['currency_code'] ?? '');
|
||||
$currency = $repos->find($currencyId);
|
||||
if (null === $currency) {
|
||||
$currency = $repos->findByCode($currencyCode);
|
||||
|
@@ -135,7 +135,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
* Used for connecting to a piggy bank.
|
||||
*
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function getExactAmount(PiggyBank $piggyBank, PiggyBankRepetition $repetition, TransactionJournal $journal): string
|
||||
{
|
||||
app('log')->debug(sprintf('Now in getExactAmount(%d, %d, %d)', $piggyBank->id, $repetition->id, $journal->id));
|
||||
@@ -318,8 +318,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
|
||||
/**
|
||||
* Get for piggy account what is left to put in piggies.
|
||||
*
|
||||
* */
|
||||
*/
|
||||
public function leftOnAccount(PiggyBank $piggyBank, Carbon $date): string
|
||||
{
|
||||
$balance = app('steam')->balanceIgnoreVirtual($piggyBank->account, $date);
|
||||
|
@@ -258,8 +258,7 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
|
||||
/**
|
||||
* Get the tags from the recurring transaction.
|
||||
*
|
||||
* */
|
||||
*/
|
||||
public function getTags(RecurrenceTransaction $transaction): array
|
||||
{
|
||||
$tags = [];
|
||||
@@ -479,7 +478,7 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function store(array $data): Recurrence
|
||||
{
|
||||
/** @var RecurrenceFactory $factory */
|
||||
|
@@ -255,7 +255,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
* Return all piggy bank events for all journals in the group.
|
||||
*
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function getPiggyEvents(TransactionGroup $group): array
|
||||
{
|
||||
$return = [];
|
||||
@@ -318,7 +318,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
/**
|
||||
* @throws DuplicateTransactionException
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function store(array $data): TransactionGroup
|
||||
{
|
||||
/** @var TransactionGroupFactory $factory */
|
||||
|
@@ -157,6 +157,8 @@ class UserGroupRepository implements UserGroupRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function updateMembership(UserGroup $userGroup, array $data): UserGroup
|
||||
|
@@ -217,7 +217,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
* Find by object, ID or code. Returns user default or system default.
|
||||
*
|
||||
* @throws FireflyException
|
||||
* */
|
||||
*/
|
||||
public function findCurrency(?int $currencyId, ?string $currencyCode): TransactionCurrency
|
||||
{
|
||||
$result = $this->findCurrencyNull($currencyId, $currencyCode);
|
||||
|
Reference in New Issue
Block a user