Rearrange code [skip ci]

This commit is contained in:
James Cole 2016-12-14 18:59:12 +01:00
parent f19b99194c
commit 848cfabcba
45 changed files with 321 additions and 319 deletions

View File

@ -50,7 +50,7 @@ class CreateImport extends Command
} }
/** /**
* *
*/ */
public function handle() public function handle()
{ {

View File

@ -73,10 +73,10 @@ class UpgradeDatabase extends Command
$subQuery = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') $subQuery = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->whereNull('transaction_journals.deleted_at') ->whereNull('transaction_journals.deleted_at')
->whereNull('transactions.deleted_at') ->whereNull('transactions.deleted_at')
->groupBy(['transaction_journals.id']) ->groupBy(['transaction_journals.id'])
->select(['transaction_journals.id', DB::raw('COUNT(transactions.id) AS t_count')]); ->select(['transaction_journals.id', DB::raw('COUNT(transactions.id) AS t_count')]);
$result = DB::table(DB::raw('(' . $subQuery->toSql() . ') AS derived')) $result = DB::table(DB::raw('(' . $subQuery->toSql() . ') AS derived'))
->mergeBindings($subQuery->getQuery()) ->mergeBindings($subQuery->getQuery())
@ -98,9 +98,9 @@ class UpgradeDatabase extends Command
try { try {
/** @var Transaction $opposing */ /** @var Transaction $opposing */
$opposing = Transaction::where('transaction_journal_id', $journalId) $opposing = Transaction::where('transaction_journal_id', $journalId)
->where('amount', $amount)->where('identifier', '=', 0) ->where('amount', $amount)->where('identifier', '=', 0)
->whereNotIn('id', $processed) ->whereNotIn('id', $processed)
->first(); ->first();
} catch (QueryException $e) { } catch (QueryException $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
$this->error('Firefly III could not find the "identifier" field in the "transactions" table.'); $this->error('Firefly III could not find the "identifier" field in the "transactions" table.');

View File

@ -17,8 +17,6 @@ use Crypt;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\Tag;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
@ -103,12 +101,12 @@ class VerifyDatabase extends Command
private function reportAccounts() private function reportAccounts()
{ {
$set = Account::leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id') $set = Account::leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
->leftJoin('users', 'accounts.user_id', '=', 'users.id') ->leftJoin('users', 'accounts.user_id', '=', 'users.id')
->groupBy(['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email']) ->groupBy(['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email'])
->whereNull('transactions.account_id') ->whereNull('transactions.account_id')
->get( ->get(
['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email'] ['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email']
); );
/** @var stdClass $entry */ /** @var stdClass $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
@ -125,10 +123,10 @@ class VerifyDatabase extends Command
private function reportBudgetLimits() private function reportBudgetLimits()
{ {
$set = Budget::leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budgets.id') $set = Budget::leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budgets.id')
->leftJoin('users', 'budgets.user_id', '=', 'users.id') ->leftJoin('users', 'budgets.user_id', '=', 'users.id')
->groupBy(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email']) ->groupBy(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email'])
->whereNull('budget_limits.id') ->whereNull('budget_limits.id')
->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email']); ->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email']);
/** @var stdClass $entry */ /** @var stdClass $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
@ -147,20 +145,20 @@ class VerifyDatabase extends Command
private function reportDeletedAccounts() private function reportDeletedAccounts()
{ {
$set = Account::leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id') $set = Account::leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->whereNotNull('accounts.deleted_at') ->whereNotNull('accounts.deleted_at')
->whereNotNull('transactions.id') ->whereNotNull('transactions.id')
->where( ->where(
function (Builder $q) { function (Builder $q) {
$q->whereNull('transactions.deleted_at'); $q->whereNull('transactions.deleted_at');
$q->orWhereNull('transaction_journals.deleted_at'); $q->orWhereNull('transaction_journals.deleted_at');
} }
) )
->get( ->get(
['accounts.id as account_id', 'accounts.deleted_at as account_deleted_at', 'transactions.id as transaction_id', ['accounts.id as account_id', 'accounts.deleted_at as account_deleted_at', 'transactions.id as transaction_id',
'transactions.deleted_at as transaction_deleted_at', 'transaction_journals.id as journal_id', 'transactions.deleted_at as transaction_deleted_at', 'transaction_journals.id as journal_id',
'transaction_journals.deleted_at as journal_deleted_at'] 'transaction_journals.deleted_at as journal_deleted_at']
); );
/** @var stdClass $entry */ /** @var stdClass $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
$date = is_null($entry->transaction_deleted_at) ? $entry->journal_deleted_at : $entry->transaction_deleted_at; $date = is_null($entry->transaction_deleted_at) ? $entry->journal_deleted_at : $entry->transaction_deleted_at;
@ -185,14 +183,17 @@ class VerifyDatabase extends Command
]; ];
foreach ($configuration as $transactionType => $accountTypes) { foreach ($configuration as $transactionType => $accountTypes) {
$set = TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id') $set = TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'account_types.id', 'accounts.account_type_id') ->leftJoin('account_types', 'account_types.id', 'accounts.account_type_id')
->leftJoin('users', 'users.id', '=', 'transaction_journals.user_id') ->leftJoin('users', 'users.id', '=', 'transaction_journals.user_id')
->where('transaction_types.type', $transactionType) ->where('transaction_types.type', $transactionType)
->whereIn('account_types.type', $accountTypes) ->whereIn('account_types.type', $accountTypes)
->whereNull('transaction_journals.deleted_at') ->whereNull('transaction_journals.deleted_at')
->get(['transaction_journals.id', 'transaction_journals.user_id', 'users.email', 'account_types.type as a_type', 'transaction_types.type']); ->get(
['transaction_journals.id', 'transaction_journals.user_id', 'users.email', 'account_types.type as a_type',
'transaction_types.type']
);
foreach ($set as $entry) { foreach ($set as $entry) {
$this->error( $this->error(
sprintf( sprintf(
@ -215,17 +216,17 @@ class VerifyDatabase extends Command
private function reportJournals() private function reportJournals()
{ {
$set = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') $set = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->whereNotNull('transaction_journals.deleted_at')// USE THIS ->whereNotNull('transaction_journals.deleted_at')// USE THIS
->whereNull('transactions.deleted_at') ->whereNull('transactions.deleted_at')
->whereNotNull('transactions.id') ->whereNotNull('transactions.id')
->get( ->get(
[ [
'transaction_journals.id as journal_id', 'transaction_journals.id as journal_id',
'transaction_journals.description', 'transaction_journals.description',
'transaction_journals.deleted_at as journal_deleted', 'transaction_journals.deleted_at as journal_deleted',
'transactions.id as transaction_id', 'transactions.id as transaction_id',
'transactions.deleted_at as transaction_deleted_at'] 'transactions.deleted_at as transaction_deleted_at']
); );
/** @var stdClass $entry */ /** @var stdClass $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
$this->error( $this->error(
@ -241,9 +242,9 @@ class VerifyDatabase extends Command
private function reportNoTransactions() private function reportNoTransactions()
{ {
$set = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') $set = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->groupBy('transaction_journals.id') ->groupBy('transaction_journals.id')
->whereNull('transactions.transaction_journal_id') ->whereNull('transactions.transaction_journal_id')
->get(['transaction_journals.id']); ->get(['transaction_journals.id']);
foreach ($set as $entry) { foreach ($set as $entry) {
$this->error( $this->error(
@ -262,11 +263,11 @@ class VerifyDatabase extends Command
$class = sprintf('FireflyIII\Models\%s', ucfirst($name)); $class = sprintf('FireflyIII\Models\%s', ucfirst($name));
$field = $name == 'tag' ? 'tag' : 'name'; $field = $name == 'tag' ? 'tag' : 'name';
$set = $class::leftJoin($name . '_transaction_journal', $plural . '.id', '=', $name . '_transaction_journal.' . $name . '_id') $set = $class::leftJoin($name . '_transaction_journal', $plural . '.id', '=', $name . '_transaction_journal.' . $name . '_id')
->leftJoin('users', $plural . '.user_id', '=', 'users.id') ->leftJoin('users', $plural . '.user_id', '=', 'users.id')
->distinct() ->distinct()
->whereNull($name . '_transaction_journal.' . $name . '_id') ->whereNull($name . '_transaction_journal.' . $name . '_id')
->whereNull($plural . '.deleted_at') ->whereNull($plural . '.deleted_at')
->get([$plural . '.id', $plural . '.' . $field . ' as name', $plural . '.user_id', 'users.email']); ->get([$plural . '.id', $plural . '.' . $field . ' as name', $plural . '.user_id', 'users.email']);
/** @var stdClass $entry */ /** @var stdClass $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
@ -309,12 +310,12 @@ class VerifyDatabase extends Command
private function reportTransactions() private function reportTransactions()
{ {
$set = Transaction::leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') $set = Transaction::leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->whereNotNull('transactions.deleted_at') ->whereNotNull('transactions.deleted_at')
->whereNull('transaction_journals.deleted_at') ->whereNull('transaction_journals.deleted_at')
->get( ->get(
['transactions.id as transaction_id', 'transactions.deleted_at as transaction_deleted', 'transaction_journals.id as journal_id', ['transactions.id as transaction_id', 'transactions.deleted_at as transaction_deleted', 'transaction_journals.id as journal_id',
'transaction_journals.deleted_at'] 'transaction_journals.deleted_at']
); );
/** @var stdClass $entry */ /** @var stdClass $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
$this->error( $this->error(
@ -330,10 +331,10 @@ class VerifyDatabase extends Command
private function reportTransfersBudgets() private function reportTransfersBudgets()
{ {
$set = TransactionJournal::distinct() $set = TransactionJournal::distinct()
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id') ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->leftJoin('budget_transaction_journal', 'transaction_journals.id', '=', 'budget_transaction_journal.transaction_journal_id') ->leftJoin('budget_transaction_journal', 'transaction_journals.id', '=', 'budget_transaction_journal.transaction_journal_id')
->where('transaction_types.type', TransactionType::TRANSFER) ->where('transaction_types.type', TransactionType::TRANSFER)
->whereNotNull('budget_transaction_journal.budget_id')->get(['transaction_journals.id']); ->whereNotNull('budget_transaction_journal.budget_id')->get(['transaction_journals.id']);
/** @var TransactionJournal $entry */ /** @var TransactionJournal $entry */
foreach ($set as $entry) { foreach ($set as $entry) {

View File

@ -293,55 +293,55 @@ class JournalExportCollector extends BasicCollector implements CollectorInterfac
{ {
$accountIds = $this->accounts->pluck('id')->toArray(); $accountIds = $this->accounts->pluck('id')->toArray();
$this->workSet = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') $this->workSet = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin( ->leftJoin(
'transactions AS opposing', function (JoinClause $join) { 'transactions AS opposing', function (JoinClause $join) {
$join->on('opposing.transaction_journal_id', '=', 'transactions.transaction_journal_id') $join->on('opposing.transaction_journal_id', '=', 'transactions.transaction_journal_id')
->where('opposing.amount', '=', DB::raw('transactions.amount * -1')) ->where('opposing.amount', '=', DB::raw('transactions.amount * -1'))
->where('transactions.identifier', '=', DB::raw('opposing.identifier')); ->where('transactions.identifier', '=', DB::raw('opposing.identifier'));
} }
) )
->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id') ->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
->leftJoin('accounts AS opposing_accounts', 'opposing.account_id', '=', 'opposing_accounts.id') ->leftJoin('accounts AS opposing_accounts', 'opposing.account_id', '=', 'opposing_accounts.id')
->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', 'transaction_types.id') ->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', 'transaction_types.id')
->leftJoin('transaction_currencies', 'transaction_journals.transaction_currency_id', '=', 'transaction_currencies.id') ->leftJoin('transaction_currencies', 'transaction_journals.transaction_currency_id', '=', 'transaction_currencies.id')
->whereIn('transactions.account_id', $accountIds) ->whereIn('transactions.account_id', $accountIds)
->where('transaction_journals.user_id', $this->job->user_id) ->where('transaction_journals.user_id', $this->job->user_id)
->where('transaction_journals.date', '>=', $this->start->format('Y-m-d')) ->where('transaction_journals.date', '>=', $this->start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $this->end->format('Y-m-d')) ->where('transaction_journals.date', '<=', $this->end->format('Y-m-d'))
->where('transaction_journals.completed', 1) ->where('transaction_journals.completed', 1)
->whereNull('transaction_journals.deleted_at') ->whereNull('transaction_journals.deleted_at')
->whereNull('transactions.deleted_at') ->whereNull('transactions.deleted_at')
->whereNull('opposing.deleted_at') ->whereNull('opposing.deleted_at')
->orderBy('transaction_journals.date', 'DESC') ->orderBy('transaction_journals.date', 'DESC')
->orderBy('transactions.identifier', 'ASC') ->orderBy('transactions.identifier', 'ASC')
->get( ->get(
[ [
'transactions.id', 'transactions.id',
'transactions.amount', 'transactions.amount',
'transactions.description', 'transactions.description',
'transactions.account_id', 'transactions.account_id',
'accounts.name as account_name', 'accounts.name as account_name',
'accounts.encrypted as account_name_encrypted', 'accounts.encrypted as account_name_encrypted',
'transactions.identifier', 'transactions.identifier',
'opposing.id as opposing_id', 'opposing.id as opposing_id',
'opposing.amount AS opposing_amount', 'opposing.amount AS opposing_amount',
'opposing.description as opposing_description', 'opposing.description as opposing_description',
'opposing.account_id as opposing_account_id', 'opposing.account_id as opposing_account_id',
'opposing_accounts.name as opposing_account_name', 'opposing_accounts.name as opposing_account_name',
'opposing_accounts.encrypted as opposing_account_encrypted', 'opposing_accounts.encrypted as opposing_account_encrypted',
'opposing.identifier as opposing_identifier', 'opposing.identifier as opposing_identifier',
'transaction_journals.id as transaction_journal_id', 'transaction_journals.id as transaction_journal_id',
'transaction_journals.date', 'transaction_journals.date',
'transaction_journals.description as journal_description', 'transaction_journals.description as journal_description',
'transaction_journals.encrypted as journal_encrypted', 'transaction_journals.encrypted as journal_encrypted',
'transaction_journals.transaction_type_id', 'transaction_journals.transaction_type_id',
'transaction_types.type as transaction_type', 'transaction_types.type as transaction_type',
'transaction_journals.transaction_currency_id', 'transaction_journals.transaction_currency_id',
'transaction_currencies.code AS transaction_currency_code', 'transaction_currencies.code AS transaction_currency_code',
] ]
); );
} }
} }

View File

@ -94,7 +94,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
* *
* @return bool * @return bool
*/ */
private function collectVintageUploads():bool private function collectVintageUploads(): bool
{ {
// grab upload directory. // grab upload directory.
$files = $this->uploadDisk->files(); $files = $this->uploadDisk->files();

View File

@ -21,17 +21,6 @@ namespace FireflyIII\Generator\Chart\Basic;
interface GeneratorInterface interface GeneratorInterface
{ {
/**
* Expects data as:
*
* key => value
*
* @param array $data
*
* @return array
*/
public function pieChart(array $data): array;
/** /**
* Will generate a (ChartJS) compatible array from the given input. Expects this format: * Will generate a (ChartJS) compatible array from the given input. Expects this format:
* *
@ -57,6 +46,17 @@ interface GeneratorInterface
*/ */
public function multiSet(array $data): array; public function multiSet(array $data): array;
/**
* Expects data as:
*
* key => value
*
* @param array $data
*
* @return array
*/
public function pieChart(array $data): array;
/** /**
* Will generate a (ChartJS) compatible array from the given input. Expects this format: * Will generate a (ChartJS) compatible array from the given input. Expects this format:
* *

View File

@ -142,6 +142,35 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
} }
/**
* @param array $entries
*
* @return array
*/
public function pieChart(array $entries): array
{
$data = [
'datasets' => [
0 => [],
],
'labels' => [],
];
$index = 0;
foreach ($entries as $entry) {
if (bccomp($entry['amount'], '0') === -1) {
$entry['amount'] = bcmul($entry['amount'], '-1');
}
$data['datasets'][0]['data'][] = round($entry['amount'], 2);
$data['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
$data['labels'][] = $entry['name'];
$index++;
}
return $data;
}
/** /**
* @param array $entries * @param array $entries
* *
@ -177,33 +206,4 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
} }
/**
* @param array $entries
*
* @return array
*/
public function pieChart(array $entries): array
{
$data = [
'datasets' => [
0 => [],
],
'labels' => [],
];
$index = 0;
foreach ($entries as $entry) {
if (bccomp($entry['amount'], '0') === -1) {
$entry['amount'] = bcmul($entry['amount'], '-1');
}
$data['datasets'][0]['data'][] = round($entry['amount'], 2);
$data['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
$data['labels'][] = $entry['name'];
$index++;
}
return $data;
}
} }

View File

@ -91,7 +91,7 @@ class ChartJsReportChartGenerator implements ReportChartGeneratorInterface
* *
* @return array * @return array
*/ */
public function netWorth(Collection $entries) : array public function netWorth(Collection $entries): array
{ {
$format = (string)trans('config.month_and_day'); $format = (string)trans('config.month_and_day');
$data = [ $data = [

View File

@ -44,7 +44,7 @@ interface ReportChartGeneratorInterface
* *
* @return array * @return array
*/ */
public function netWorth(Collection $entries) : array; public function netWorth(Collection $entries): array;
/** /**
* @param Collection $entries * @param Collection $entries

View File

@ -38,7 +38,7 @@ class BudgetEventHandler
* *
* @return bool * @return bool
*/ */
public function storeRepetition(StoredBudgetLimit $budgetLimitEvent):bool public function storeRepetition(StoredBudgetLimit $budgetLimitEvent): bool
{ {
return $this->processRepetitionChange($budgetLimitEvent->budgetLimit, $budgetLimitEvent->end); return $this->processRepetitionChange($budgetLimitEvent->budgetLimit, $budgetLimitEvent->end);
} }
@ -61,7 +61,7 @@ class BudgetEventHandler
* *
* @return bool * @return bool
*/ */
private function processRepetitionChange(BudgetLimit $budgetLimit, Carbon $date):bool private function processRepetitionChange(BudgetLimit $budgetLimit, Carbon $date): bool
{ {
$set = $budgetLimit->limitrepetitions() $set = $budgetLimit->limitrepetitions()
->where('startdate', $budgetLimit->startdate->format('Y-m-d 00:00:00')) ->where('startdate', $budgetLimit->startdate->format('Y-m-d 00:00:00'))

View File

@ -35,7 +35,7 @@ class UpdatedJournalEventHandler
* *
* @return bool * @return bool
*/ */
public function processRules(UpdatedTransactionJournal $updatedJournalEvent):bool public function processRules(UpdatedTransactionJournal $updatedJournalEvent): bool
{ {
// get all the user's rule groups, with the rules, order by 'order'. // get all the user's rule groups, with the rules, order by 'order'.
$journal = $updatedJournalEvent->journal; $journal = $updatedJournalEvent->journal;

View File

@ -79,6 +79,22 @@ class BillLine
$this->bill = $bill; $this->bill = $bill;
} }
/**
* @return Carbon
*/
public function getLastHitDate(): Carbon
{
return $this->lastHitDate;
}
/**
* @param Carbon $lastHitDate
*/
public function setLastHitDate(Carbon $lastHitDate)
{
$this->lastHitDate = $lastHitDate;
}
/** /**
* @return string * @return string
*/ */
@ -151,21 +167,5 @@ class BillLine
$this->hit = $hit; $this->hit = $hit;
} }
/**
* @param Carbon $lastHitDate
*/
public function setLastHitDate(Carbon $lastHitDate)
{
$this->lastHitDate = $lastHitDate;
}
/**
* @return Carbon
*/
public function getLastHitDate(): Carbon
{
return $this->lastHitDate;
}
} }

View File

@ -88,7 +88,7 @@ class Help implements HelpInterface
* *
* @return bool * @return bool
*/ */
public function hasRoute(string $route):bool public function hasRoute(string $route): bool
{ {
return Route::has($route); return Route::has($route);
} }
@ -99,7 +99,7 @@ class Help implements HelpInterface
* *
* @return bool * @return bool
*/ */
public function inCache(string $route, string $language):bool public function inCache(string $route, string $language): bool
{ {
$line = sprintf('help.%s.%s', $route, $language); $line = sprintf('help.%s.%s', $route, $language);
$result = Cache::has($line); $result = Cache::has($line);

View File

@ -34,7 +34,7 @@ interface HelpInterface
* *
* @return string * @return string
*/ */
public function getFromGithub(string $language, string $route):string; public function getFromGithub(string $language, string $route): string;
/** /**
* @param string $route * @param string $route

View File

@ -61,6 +61,7 @@ class ConfigurationController extends Controller
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data; $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$mustConfirmAccount = FireflyConfig::get('must_confirm_account', config('firefly.configuration.must_confirm_account'))->data; $mustConfirmAccount = FireflyConfig::get('must_confirm_account', config('firefly.configuration.must_confirm_account'))->data;
$isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data; $isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
$siteOwner = env('SITE_OWNER');
// email settings: // email settings:
$sendErrorMessage = [ $sendErrorMessage = [
@ -71,7 +72,10 @@ class ConfigurationController extends Controller
'mail_for_blocked_login' => FireflyConfig::get('mail_for_blocked_login', config('firefly.configuration.mail_for_blocked_login'))->data, 'mail_for_blocked_login' => FireflyConfig::get('mail_for_blocked_login', config('firefly.configuration.mail_for_blocked_login'))->data,
]; ];
return view('admin.configuration.index', compact('subTitle', 'subTitleIcon', 'singleUserMode', 'mustConfirmAccount', 'isDemoSite', 'sendErrorMessage')); return view(
'admin.configuration.index',
compact('subTitle', 'subTitleIcon', 'singleUserMode', 'mustConfirmAccount', 'isDemoSite', 'sendErrorMessage', 'siteOwner')
);
} }

View File

@ -14,11 +14,11 @@ namespace FireflyIII\Http\Controllers\Auth;
use Auth; use Auth;
use Config; use Config;
use FireflyConfig;
use FireflyIII\Events\BlockedUseOfDomain; use FireflyIII\Events\BlockedUseOfDomain;
use FireflyIII\Events\BlockedUseOfEmail; use FireflyIII\Events\BlockedUseOfEmail;
use FireflyIII\Events\RegisteredUser; use FireflyIII\Events\RegisteredUser;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyConfig;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -114,7 +114,6 @@ class RegisterController extends Controller
} }
$user = $this->create($request->all()); $user = $this->create($request->all());
// trigger user registration event: // trigger user registration event:

View File

@ -238,7 +238,7 @@ class AccountController extends Controller
$end = clone session('end', Carbon::now()->endOfMonth()); $end = clone session('end', Carbon::now()->endOfMonth());
$defaultSet = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray(); $defaultSet = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray();
Log::debug('Default set is ', $defaultSet); Log::debug('Default set is ', $defaultSet);
$frontPage = Preferences::get('frontPageAccounts', $defaultSet); $frontPage = Preferences::get('frontPageAccounts', $defaultSet);
Log::debug('Frontpage preference set is ', $frontPage->data); Log::debug('Frontpage preference set is ', $frontPage->data);
if (count($frontPage->data) === 0) { if (count($frontPage->data) === 0) {
$frontPage->data = $defaultSet; $frontPage->data = $defaultSet;

View File

@ -70,7 +70,7 @@ class BillController extends Controller
strval(trans('firefly.paid')) => $paid, strval(trans('firefly.paid')) => $paid,
]; ];
$data = $this->generator->pieChart($chartData); $data = $this->generator->pieChart($chartData);
$cache->store($data); $cache->store($data);
return Response::json($data); return Response::json($data);
@ -127,7 +127,7 @@ class BillController extends Controller
$chartData[2]['entries'][$date] = bcmul($entry->transaction_amount, '-1'); $chartData[2]['entries'][$date] = bcmul($entry->transaction_amount, '-1');
} }
$data = $this->generator->multiSet($chartData); $data = $this->generator->multiSet($chartData);
$cache->store($data); $cache->store($data);
return Response::json($data); return Response::json($data);

View File

@ -204,7 +204,7 @@ class BudgetController extends Controller
$cache->addProperty('budget'); $cache->addProperty('budget');
$cache->addProperty('period'); $cache->addProperty('period');
if ($cache->has()) { if ($cache->has()) {
return Response::json($cache->get()); return Response::json($cache->get());
} }
// the expenses: // the expenses:
@ -274,15 +274,15 @@ class BudgetController extends Controller
} }
// the expenses: // the expenses:
$periods = Navigation::listOfPeriods($start, $end); $periods = Navigation::listOfPeriods($start, $end);
$entries = $repository->getNoBudgetPeriodReport($accounts, $start, $end); $entries = $repository->getNoBudgetPeriodReport($accounts, $start, $end);
// join them: // join them:
$result = []; $result = [];
foreach (array_keys($periods) as $period) { foreach (array_keys($periods) as $period) {
$nice = $periods[$period]; $nice = $periods[$period];
$result[$nice] = [ $result[$nice] = [
'spent' => isset($entries['entries'][$period]) ? $entries['entries'][$period] : '0', 'spent' => isset($entries['entries'][$period]) ? $entries['entries'][$period] : '0',
]; ];
} }

View File

@ -50,8 +50,9 @@ class ReportController extends Controller
* which means that giving it a 2 week "period" should be enough granularity. * which means that giving it a 2 week "period" should be enough granularity.
* *
* @param Collection $accounts * @param Collection $accounts
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
*
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function netWorth(Collection $accounts, Carbon $start, Carbon $end) public function netWorth(Collection $accounts, Carbon $start, Carbon $end)
@ -131,6 +132,7 @@ class ReportController extends Controller
/** /**
* Shows sum income and expense, debet/credit: operations * Shows sum income and expense, debet/credit: operations
*
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* @param Collection $accounts * @param Collection $accounts
@ -301,7 +303,7 @@ class ReportController extends Controller
* *
* @return string * @return string
*/ */
private function arraySum($array) : string private function arraySum($array): string
{ {
$sum = '0'; $sum = '0';
foreach ($array as $entry) { foreach ($array as $entry) {

View File

@ -121,7 +121,7 @@ class CurrencyController extends Controller
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/ */
public function destroy(CurrencyRepositoryInterface $repository, TransactionCurrency $currency) public function destroy(CurrencyRepositoryInterface $repository, TransactionCurrency $currency)
{ {
if (!$repository->canDeleteCurrency($currency)) { if (!$repository->canDeleteCurrency($currency)) {
Session::flash('error', trans('firefly.cannot_delete_currency', ['name' => $currency->name])); Session::flash('error', trans('firefly.cannot_delete_currency', ['name' => $currency->name]));
@ -170,7 +170,7 @@ class CurrencyController extends Controller
if (!auth()->user()->hasRole('owner')) { if (!auth()->user()->hasRole('owner')) {
Session::flash('warning', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')])); Session::flash('warning', trans('firefly.ask_site_owner', ['site_owner' => env('SITE_OWNER')]));
} }

View File

@ -17,7 +17,6 @@ namespace FireflyIII\Http\Controllers;
use Carbon\Carbon; use Carbon\Carbon;
use ExpandedForm; use ExpandedForm;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Export\Processor;
use FireflyIII\Export\ProcessorInterface; use FireflyIII\Export\ProcessorInterface;
use FireflyIII\Http\Requests\ExportFormRequest; use FireflyIII\Http\Requests\ExportFormRequest;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;

View File

@ -208,7 +208,7 @@ class HomeController extends Controller
'debugbar', 'debugbar',
'attachments.preview', 'attachments.preview',
'budgets.income', 'budgets.income',
'currencies.default' 'currencies.default',
]; ];

View File

@ -212,7 +212,7 @@ class PreferencesController extends Controller
/** /**
* @return string * @return string
*/ */
private function getDomain() : string private function getDomain(): string
{ {
$url = url()->to('/'); $url = url()->to('/');
$parts = parse_url($url); $parts = parse_url($url);

View File

@ -36,7 +36,7 @@ class BalanceController extends Controller
* *
* @return mixed|string * @return mixed|string
*/ */
public function general(BalanceReportHelperInterface $helper,Collection $accounts, Carbon $start, Carbon $end) public function general(BalanceReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end)
{ {

View File

@ -16,7 +16,6 @@ namespace FireflyIII\Http\Controllers\Report;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Helpers\Collector\JournalCollectorInterface; use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
@ -57,6 +56,33 @@ class OperationsController extends Controller
} }
/**
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
public function income(Collection $accounts, Carbon $start, Carbon $end)
{
// chart properties for cache:
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('income-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
//return $cache->get();
}
$income = $this->getIncomeReport($start, $end, $accounts);
$result = view('reports.partials.income', compact('income'))->render();
$cache->store($result);
return $result;
}
/** /**
* @param Collection $accounts * @param Collection $accounts
* @param Carbon $start * @param Carbon $start
@ -101,33 +127,6 @@ class OperationsController extends Controller
} }
/**
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
public function income(Collection $accounts, Carbon $start, Carbon $end)
{
// chart properties for cache:
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('income-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
//return $cache->get();
}
$income = $this->getIncomeReport($start, $end, $accounts);
$result = view('reports.partials.income', compact('income'))->render();
$cache->store($result);
return $result;
}
/** /**
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end

View File

@ -80,7 +80,7 @@ class AccountFormRequest extends Request
'name' => $nameRule, 'name' => $nameRule,
'openingBalance' => 'numeric', 'openingBalance' => 'numeric',
'iban' => 'iban', 'iban' => 'iban',
'BIC' => 'bic', 'BIC' => 'bic',
'virtualBalance' => 'numeric', 'virtualBalance' => 'numeric',
'openingBalanceDate' => 'date', 'openingBalanceDate' => 'date',
'currency_id' => 'exists:transaction_currencies,id', 'currency_id' => 'exists:transaction_currencies,id',

View File

@ -161,6 +161,7 @@ class JournalFormRequest extends Request
private function getFieldOrEmptyString(string $field): string private function getFieldOrEmptyString(string $field): string
{ {
$string = $this->get($field) ?? ''; $string = $this->get($field) ?? '';
return trim($string); return trim($string);
} }
} }

View File

@ -41,7 +41,7 @@ class ReportFormRequest extends Request
/** /**
* @return Collection * @return Collection
*/ */
public function getAccountList():Collection public function getAccountList(): Collection
{ {
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class); $repository = app(AccountRepositoryInterface::class);
@ -59,27 +59,6 @@ class ReportFormRequest extends Request
return $collection; return $collection;
} }
/**
* @return Collection
*/
public function getCategoryList(): Collection
{
/** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class);
$set = $this->get('category');
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $categoryId) {
$category = $repository->find(intval($categoryId));
if (!is_null($category->id)) {
$collection->push($category);
}
}
}
return $collection;
}
/** /**
* @return Collection * @return Collection
*/ */
@ -101,6 +80,27 @@ class ReportFormRequest extends Request
return $collection; return $collection;
} }
/**
* @return Collection
*/
public function getCategoryList(): Collection
{
/** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class);
$set = $this->get('category');
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $categoryId) {
$category = $repository->find(intval($categoryId));
if (!is_null($category->id)) {
$collection->push($category);
}
}
}
return $collection;
}
/** /**
* @return Carbon * @return Carbon
* @throws FireflyException * @throws FireflyException

View File

@ -35,7 +35,7 @@ class TagFormRequest extends Request
/** /**
* @return array * @return array
*/ */
public function collectTagData() :array public function collectTagData(): array
{ {
if ($this->get('setTag') == 'true') { if ($this->get('setTag') == 'true') {
$latitude = $this->get('latitude'); $latitude = $this->get('latitude');

View File

@ -67,7 +67,7 @@ Breadcrumbs::register(
Breadcrumbs::register( Breadcrumbs::register(
'accounts.show', function (BreadCrumbGenerator $breadcrumbs, Account $account) { 'accounts.show', function (BreadCrumbGenerator $breadcrumbs, Account $account) {
$what = config('firefly.shortNamesByFullName.' . $account->accountType->type); $what = config('firefly.shortNamesByFullName.' . $account->accountType->type);
$breadcrumbs->parent('accounts.index', $what); $breadcrumbs->parent('accounts.index', $what);
$breadcrumbs->push($account->name, route('accounts.show', [$account->id])); $breadcrumbs->push($account->name, route('accounts.show', [$account->id]));

View File

@ -37,7 +37,7 @@ class BasicConverter
/** /**
* @return int * @return int
*/ */
public function getCertainty():int public function getCertainty(): int
{ {
return $this->certainty; return $this->certainty;
} }

View File

@ -433,7 +433,7 @@ class CsvSetup implements SetupInterface
* *
* @return array * @return array
*/ */
private function getDataForColumnRoles():array private function getDataForColumnRoles(): array
{ {
Log::debug('Now in getDataForColumnRoles()'); Log::debug('Now in getDataForColumnRoles()');
$config = $this->job->configuration; $config = $this->job->configuration;

View File

@ -200,10 +200,10 @@ class Account extends Model
public function getOpeningBalanceAmount(): string public function getOpeningBalanceAmount(): string
{ {
$journal = TransactionJournal::sortCorrectly() $journal = TransactionJournal::sortCorrectly()
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.account_id', $this->id) ->where('transactions.account_id', $this->id)
->transactionTypes([TransactionType::OPENING_BALANCE]) ->transactionTypes([TransactionType::OPENING_BALANCE])
->first(['transaction_journals.*']); ->first(['transaction_journals.*']);
if (is_null($journal)) { if (is_null($journal)) {
return '0'; return '0';
} }
@ -230,10 +230,10 @@ class Account extends Model
{ {
$date = new Carbon('1900-01-01'); $date = new Carbon('1900-01-01');
$journal = TransactionJournal::sortCorrectly() $journal = TransactionJournal::sortCorrectly()
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.account_id', $this->id) ->where('transactions.account_id', $this->id)
->transactionTypes([TransactionType::OPENING_BALANCE]) ->transactionTypes([TransactionType::OPENING_BALANCE])
->first(['transaction_journals.*']); ->first(['transaction_journals.*']);
if (is_null($journal)) { if (is_null($journal)) {
return $date; return $date;
} }

View File

@ -46,7 +46,7 @@ class Transaction extends Model
* *
* @return bool * @return bool
*/ */
public static function isJoined(Builder $query, string $table):bool public static function isJoined(Builder $query, string $table): bool
{ {
$joins = $query->getQuery()->joins; $joins = $query->getQuery()->joins;
if (is_null($joins)) { if (is_null($joins)) {

View File

@ -65,9 +65,9 @@ class TransactionJournal extends TransactionJournalSupport
{ {
if (auth()->check()) { if (auth()->check()) {
$object = TransactionJournal::where('transaction_journals.id', $value) $object = TransactionJournal::where('transaction_journals.id', $value)
->with('transactionType') ->with('transactionType')
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id') ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->where('user_id', auth()->user()->id)->first(['transaction_journals.*']); ->where('user_id', auth()->user()->id)->first(['transaction_journals.*']);
if (!is_null($object)) { if (!is_null($object)) {
return $object; return $object;
} }
@ -113,7 +113,7 @@ class TransactionJournal extends TransactionJournalSupport
* *
* @return bool * @return bool
*/ */
public function deleteMeta(string $name):bool public function deleteMeta(string $name): bool
{ {
$this->transactionJournalMeta()->where('name', $name)->delete(); $this->transactionJournalMeta()->where('name', $name)->delete();

View File

@ -14,17 +14,13 @@ declare(strict_types = 1);
namespace FireflyIII\Repositories\Account; namespace FireflyIII\Repositories\Account;
use Carbon\Carbon; use Carbon\Carbon;
use Crypt;
use DB;
use FireflyIII\Helpers\Collection\Account as AccountCollection; use FireflyIII\Helpers\Collection\Account as AccountCollection;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Database\Query\JoinClause; use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
use stdClass;
use Steam; use Steam;
/** /**

View File

@ -200,7 +200,7 @@ class TransactionJournalSupport extends Model
* *
* @return bool * @return bool
*/ */
public static function isJoined(Builder $query, string $table):bool public static function isJoined(Builder $query, string $table): bool
{ {
$joins = $query->getQuery()->joins; $joins = $query->getQuery()->joins;
if (is_null($joins)) { if (is_null($joins)) {

View File

@ -59,8 +59,8 @@ class Preferences
} }
/** /**
* @param \FireflyIII\User $user * @param \FireflyIII\User $user
* @param array $list * @param array $list
* *
* @return array * @return array
*/ */

View File

@ -84,7 +84,7 @@ class General extends Twig_Extension
protected function activeRoutePartial(): Twig_SimpleFunction protected function activeRoutePartial(): Twig_SimpleFunction
{ {
return new Twig_SimpleFunction( return new Twig_SimpleFunction(
'activeRoutePartial', function () : string { 'activeRoutePartial', function (): string {
$args = func_get_args(); $args = func_get_args();
$route = $args[0]; // name of the route. $route = $args[0]; // name of the route.
$name = Route::getCurrentRoute()->getName() ?? ''; $name = Route::getCurrentRoute()->getName() ?? '';
@ -106,7 +106,7 @@ class General extends Twig_Extension
protected function activeRoutePartialWhat(): Twig_SimpleFunction protected function activeRoutePartialWhat(): Twig_SimpleFunction
{ {
return new Twig_SimpleFunction( return new Twig_SimpleFunction(
'activeRoutePartialWhat', function ($context) : string { 'activeRoutePartialWhat', function ($context): string {
$args = func_get_args(); $args = func_get_args();
$route = $args[1]; // name of the route. $route = $args[1]; // name of the route.
$what = $args[2]; // name of the route. $what = $args[2]; // name of the route.
@ -130,7 +130,7 @@ class General extends Twig_Extension
protected function activeRouteStrict(): Twig_SimpleFunction protected function activeRouteStrict(): Twig_SimpleFunction
{ {
return new Twig_SimpleFunction( return new Twig_SimpleFunction(
'activeRouteStrict', function () : string { 'activeRouteStrict', function (): string {
$args = func_get_args(); $args = func_get_args();
$route = $args[0]; // name of the route. $route = $args[0]; // name of the route.
@ -149,7 +149,7 @@ class General extends Twig_Extension
protected function balance(): Twig_SimpleFilter protected function balance(): Twig_SimpleFilter
{ {
return new Twig_SimpleFilter( return new Twig_SimpleFilter(
'balance', function (Account $account = null) : string { 'balance', function (Account $account = null): string {
if (is_null($account)) { if (is_null($account)) {
return 'NULL'; return 'NULL';
} }
@ -166,7 +166,7 @@ class General extends Twig_Extension
protected function env(): Twig_SimpleFunction protected function env(): Twig_SimpleFunction
{ {
return new Twig_SimpleFunction( return new Twig_SimpleFunction(
'env', function (string $name, string $default) : string { 'env', function (string $name, string $default): string {
return env($name, $default); return env($name, $default);
} }
); );
@ -179,7 +179,7 @@ class General extends Twig_Extension
protected function formatAmount(): Twig_SimpleFilter protected function formatAmount(): Twig_SimpleFilter
{ {
return new Twig_SimpleFilter( return new Twig_SimpleFilter(
'formatAmount', function (string $string) : string { 'formatAmount', function (string $string): string {
return app('amount')->format($string); return app('amount')->format($string);
}, ['is_safe' => ['html']] }, ['is_safe' => ['html']]
@ -192,7 +192,7 @@ class General extends Twig_Extension
protected function formatAmountPlain(): Twig_SimpleFilter protected function formatAmountPlain(): Twig_SimpleFilter
{ {
return new Twig_SimpleFilter( return new Twig_SimpleFilter(
'formatAmountPlain', function (string $string) : string { 'formatAmountPlain', function (string $string): string {
return app('amount')->format($string, false); return app('amount')->format($string, false);
}, ['is_safe' => ['html']] }, ['is_safe' => ['html']]
@ -205,7 +205,7 @@ class General extends Twig_Extension
protected function formatFilesize(): Twig_SimpleFilter protected function formatFilesize(): Twig_SimpleFilter
{ {
return new Twig_SimpleFilter( return new Twig_SimpleFilter(
'filesize', function (int $size) : string { 'filesize', function (int $size): string {
// less than one GB, more than one MB // less than one GB, more than one MB
if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) { if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {
@ -228,7 +228,7 @@ class General extends Twig_Extension
protected function formatJournal(): Twig_SimpleFilter protected function formatJournal(): Twig_SimpleFilter
{ {
return new Twig_SimpleFilter( return new Twig_SimpleFilter(
'formatJournal', function (TransactionJournal $journal) : string { 'formatJournal', function (TransactionJournal $journal): string {
return app('amount')->formatJournal($journal); return app('amount')->formatJournal($journal);
}, ['is_safe' => ['html']] }, ['is_safe' => ['html']]
); );
@ -240,7 +240,7 @@ class General extends Twig_Extension
protected function getAccountRole(): Twig_SimpleFilter protected function getAccountRole(): Twig_SimpleFilter
{ {
return new Twig_SimpleFilter( return new Twig_SimpleFilter(
'getAccountRole', function (string $name) : string { 'getAccountRole', function (string $name): string {
return Config::get('firefly.accountRoles.' . $name); return Config::get('firefly.accountRoles.' . $name);
} }
); );
@ -252,7 +252,7 @@ class General extends Twig_Extension
protected function getCurrencyCode(): Twig_SimpleFunction protected function getCurrencyCode(): Twig_SimpleFunction
{ {
return new Twig_SimpleFunction( return new Twig_SimpleFunction(
'getCurrencyCode', function () : string { 'getCurrencyCode', function (): string {
return app('amount')->getCurrencyCode(); return app('amount')->getCurrencyCode();
} }
); );
@ -264,7 +264,7 @@ class General extends Twig_Extension
protected function getCurrencySymbol(): Twig_SimpleFunction protected function getCurrencySymbol(): Twig_SimpleFunction
{ {
return new Twig_SimpleFunction( return new Twig_SimpleFunction(
'getCurrencySymbol', function () : string { 'getCurrencySymbol', function (): string {
return app('amount')->getCurrencySymbol(); return app('amount')->getCurrencySymbol();
} }
); );
@ -276,7 +276,7 @@ class General extends Twig_Extension
protected function mimeIcon(): Twig_SimpleFilter protected function mimeIcon(): Twig_SimpleFilter
{ {
return new Twig_SimpleFilter( return new Twig_SimpleFilter(
'mimeIcon', function (string $string) : string { 'mimeIcon', function (string $string): string {
switch ($string) { switch ($string) {
default: default:
return 'fa-file-o'; return 'fa-file-o';
@ -296,7 +296,7 @@ class General extends Twig_Extension
protected function phpdate() protected function phpdate()
{ {
return new Twig_SimpleFunction( return new Twig_SimpleFunction(
'phpdate', function (string $str) : string { 'phpdate', function (string $str): string {
return date($str); return date($str);
} }
); );
@ -308,7 +308,7 @@ class General extends Twig_Extension
private function getAmountFromJournal() private function getAmountFromJournal()
{ {
return new Twig_SimpleFunction( return new Twig_SimpleFunction(
'getAmount', function (TransactionJournal $journal) : string { 'getAmount', function (TransactionJournal $journal): string {
return TransactionJournal::amount($journal); return TransactionJournal::amount($journal);
} }
); );

View File

@ -110,9 +110,9 @@ class Transaction extends Twig_Extension
$amount = strval( $amount = strval(
TransactionModel::where('transaction_journal_id', $journalId) TransactionModel::where('transaction_journal_id', $journalId)
->whereNull('deleted_at') ->whereNull('deleted_at')
->where('amount', '<', 0) ->where('amount', '<', 0)
->sum('amount') ->sum('amount')
); );
if ($type === TransactionType::DEPOSIT || $type === TransactionType::TRANSFER) { if ($type === TransactionType::DEPOSIT || $type === TransactionType::TRANSFER) {
@ -203,10 +203,10 @@ class Transaction extends Twig_Extension
$journalId = $transaction->journal_id; $journalId = $transaction->journal_id;
/** @var TransactionModel $other */ /** @var TransactionModel $other */
$other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id) $other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)
->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where('identifier', $transaction->identifier) ->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where('identifier', $transaction->identifier)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id') ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->first(['transactions.account_id', 'accounts.encrypted', 'accounts.name', 'account_types.type']); ->first(['transactions.account_id', 'accounts.encrypted', 'accounts.name', 'account_types.type']);
$name = intval($other->encrypted) === 1 ? Crypt::decrypt($other->name) : $other->name; $name = intval($other->encrypted) === 1 ? Crypt::decrypt($other->name) : $other->name;
$id = $other->account_id; $id = $other->account_id;
$type = $other->type; $type = $other->type;
@ -275,10 +275,10 @@ class Transaction extends Twig_Extension
$journalId = $transaction->journal_id; $journalId = $transaction->journal_id;
/** @var TransactionModel $other */ /** @var TransactionModel $other */
$other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id) $other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)
->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where('identifier', $transaction->identifier) ->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where('identifier', $transaction->identifier)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id') ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->first(['transactions.account_id', 'accounts.encrypted', 'accounts.name', 'account_types.type']); ->first(['transactions.account_id', 'accounts.encrypted', 'accounts.name', 'account_types.type']);
$name = intval($other->encrypted) === 1 ? Crypt::decrypt($other->name) : $other->name; $name = intval($other->encrypted) === 1 ? Crypt::decrypt($other->name) : $other->name;
$id = $other->account_id; $id = $other->account_id;
$type = $other->type; $type = $other->type;

View File

@ -188,6 +188,20 @@ class User extends Authenticatable
return $this->hasMany('FireflyIII\Models\Rule'); return $this->hasMany('FireflyIII\Models\Rule');
} }
/**
* Send the password reset notification.
*
* @param string $token
*
* @return void
*/
public function sendPasswordResetNotification($token)
{
$ip = Request::ip();
event(new RequestedNewPassword($this, $token, $ip));
}
/** /**
* @return HasMany * @return HasMany
*/ */
@ -212,18 +226,5 @@ class User extends Authenticatable
return $this->hasManyThrough('FireflyIII\Models\Transaction', 'FireflyIII\Models\TransactionJournal'); return $this->hasManyThrough('FireflyIII\Models\Transaction', 'FireflyIII\Models\TransactionJournal');
} }
/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$ip = Request::ip();
event(new RequestedNewPassword($this, $token, $ip));
}
} }

View File

@ -847,7 +847,7 @@ return [
'setting_is_demo_site' => 'Demo site', 'setting_is_demo_site' => 'Demo site',
'setting_is_demo_site_explain' => 'If you check this box, this installation will behave as if it is the demo site, which can have weird side effects.', 'setting_is_demo_site_explain' => 'If you check this box, this installation will behave as if it is the demo site, which can have weird side effects.',
'setting_send_email_notifications' => 'Send email notifications', 'setting_send_email_notifications' => 'Send email notifications',
'setting_send_email_explain' => 'Firefly III can send you email notifications about certain events. They will be sent to <code>:email</code>. This email address can be set in the <code>.env</code> file.', 'setting_send_email_explain' => 'Firefly III can send you email notifications about certain events. They will be sent to <code>:site_owner</code>. This email address can be set in the <code>.env</code> file.',
'mail_for_lockout_help' => 'When a user is locked out', 'mail_for_lockout_help' => 'When a user is locked out',
'mail_for_blocked_domain_help' => 'When a user tries to register using a blocked domain', 'mail_for_blocked_domain_help' => 'When a user tries to register using a blocked domain',
'mail_for_blocked_email_help' => 'When a user tries to register using a blocked email address', 'mail_for_blocked_email_help' => 'When a user tries to register using a blocked email address',

View File

@ -426,7 +426,7 @@ return [
'deleted_currency' => 'Valuta :name verwijderd', 'deleted_currency' => 'Valuta :name verwijderd',
'created_currency' => 'Nieuwe valuta :name opgeslagen', 'created_currency' => 'Nieuwe valuta :name opgeslagen',
'updated_currency' => 'Valuta :name bijgewerkt', 'updated_currency' => 'Valuta :name bijgewerkt',
'ask_site_owner' => 'Vraag :owner of deze valuta wilt toevoegen, verwijderen of wijzigen.', 'ask_site_owner' => 'Vraag :site_owner of deze valuta wilt toevoegen, verwijderen of wijzigen.',
'currencies_intro' => 'Firefly III ondersteunt diverse valuta die je hier kan instellen en bewerken.', 'currencies_intro' => 'Firefly III ondersteunt diverse valuta die je hier kan instellen en bewerken.',
'make_default_currency' => 'maak standaard', 'make_default_currency' => 'maak standaard',
'default_currency' => 'standaard', 'default_currency' => 'standaard',

View File

@ -76,11 +76,11 @@
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12"> <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
<div class="box box-default"> <div class="box box-default">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">{{ 'setting_send_email_notifications'|_ }}</h3> <h3 class="box-title">{{ trans('firefly.setting_send_email_notifications') }}</h3>
</div> </div>
<div class="box-body"> <div class="box-body">
<p class="text-info"> <p class="text-info">
{{ 'setting_send_email_explain'|_ }} {{ trans('firefly.setting_send_email_explain',{site_owner: siteOwner})|raw }}
</p> </p>
{{ ExpandedForm.checkbox('mail_for_lockout','1', sendErrorMessage.mail_for_lockout, {helpText: trans('firefly.mail_for_lockout_help')}) }} {{ ExpandedForm.checkbox('mail_for_lockout','1', sendErrorMessage.mail_for_lockout, {helpText: trans('firefly.mail_for_lockout_help')}) }}
{{ ExpandedForm.checkbox('mail_for_blocked_domain','1', sendErrorMessage.mail_for_blocked_domain, {helpText: trans('firefly.mail_for_blocked_domain_help')}) }} {{ ExpandedForm.checkbox('mail_for_blocked_domain','1', sendErrorMessage.mail_for_blocked_domain, {helpText: trans('firefly.mail_for_blocked_domain_help')}) }}