diff --git a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php index 1e7ae33828..52f3b540e7 100644 --- a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php +++ b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php @@ -25,13 +25,13 @@ class ChartJsBillChartGenerator implements BillChartGenerator bcscale(2); $data = [ [ - 'value' => round($unpaid,2), + 'value' => round($unpaid, 2), 'color' => 'rgba(53, 124, 165,0.7)', 'highlight' => 'rgba(53, 124, 165,0.9)', 'label' => trans('firefly.unpaid'), ], [ - 'value' => round($paid * -1,2), // paid is negative, must be positive. + 'value' => round($paid * -1, 2), // paid is negative, must be positive. 'color' => 'rgba(0, 141, 76, 0.7)', 'highlight' => 'rgba(0, 141, 76, 0.9)', 'label' => trans('firefly.paid'), @@ -73,7 +73,7 @@ class ChartJsBillChartGenerator implements BillChartGenerator /* * journalAmount has been collected in BillRepository::getJournals */ - $actualAmount[] = round(($entry->journalAmount * -1), 2); + $actualAmount[] = round(($entry->journalAmount * -1), 2); } $data['datasets'][] = [ diff --git a/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php b/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php index 5b79fdbf47..f876559eeb 100644 --- a/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php +++ b/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php @@ -49,53 +49,13 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator return $data; } - /** - * @param Collection $entries - * - * @return array - */ - public function frontpage(Collection $entries) - { - $data = [ - 'count' => 1, - 'labels' => [], - 'datasets' => [ - [ - 'label' => trans('firefly.spent'), - 'data' => [] - ] - ], - ]; - foreach ($entries as $entry) { - if ($entry['sum'] != 0) { - $data['labels'][] = $entry['name']; - $data['datasets'][0]['data'][] = round(($entry['sum'] * -1), 2); - } - } - - return $data; - } - - /** - * @codeCoverageIgnore - * - * @param Collection $entries - * - * @return array - */ - public function period(Collection $entries) - { - return $this->all($entries); - - } - /** * @param Collection $categories * @param Collection $entries * * @return array */ - public function spentInYear(Collection $categories, Collection $entries) + public function earnedInPeriod(Collection $categories, Collection $entries) { // language: @@ -122,13 +82,90 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator } + /** + * @param Collection $entries + * + * @return array + */ + public function frontpage(Collection $entries) + { + $data = [ + 'count' => 1, + 'labels' => [], + 'datasets' => [ + [ + 'label' => trans('firefly.spent'), + 'data' => [] + ] + ], + ]; + foreach ($entries as $entry) { + if ($entry['sum'] != 0) { + $data['labels'][] = $entry['name']; + $data['datasets'][0]['data'][] = round(($entry['sum'] * -1), 2); + } + } + + return $data; + } + + /** + * @param Collection $entries + * + * @return array + */ + public function multiYear(Collection $entries) + { + // dataset: + $data = [ + 'count' => 0, + 'labels' => [], + 'datasets' => [], + ]; + // get labels from one of the categories (assuming there's at least one): + $first = $entries->first(); + foreach ($first['spent'] as $year => $noInterest) { + $data['labels'][] = strval($year); + } + + // then, loop all entries and create datasets: + foreach ($entries as $entry) { + $name = $entry['name']; + $spent = $entry['spent']; + $earned = $entry['earned']; + if (array_sum(array_values($spent)) != 0) { + $data['datasets'][] = ['label' => 'Spent in category ' . $name, 'data' => array_values($spent)]; + } + if (array_sum(array_values($earned)) != 0) { + $data['datasets'][] = ['label' => 'Earned in category ' . $name, 'data' => array_values($earned)]; + } + } + $data['count'] = count($data['datasets']); + + return $data; + + } + + /** + * @codeCoverageIgnore + * + * @param Collection $entries + * + * @return array + */ + public function period(Collection $entries) + { + return $this->all($entries); + + } + /** * @param Collection $categories * @param Collection $entries * * @return array */ - public function earnedInPeriod(Collection $categories, Collection $entries) + public function spentInYear(Collection $categories, Collection $entries) { // language: @@ -187,41 +224,4 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator return $data; } - - /** - * @param Collection $entries - * - * @return array - */ - public function multiYear(Collection $entries) - { - // dataset: - $data = [ - 'count' => 0, - 'labels' => [], - 'datasets' => [], - ]; - // get labels from one of the categories (assuming there's at least one): - $first = $entries->first(); - foreach ($first['spent'] as $year => $noInterest) { - $data['labels'][] = strval($year); - } - - // then, loop all entries and create datasets: - foreach ($entries as $entry) { - $name = $entry['name']; - $spent = $entry['spent']; - $earned = $entry['earned']; - if (array_sum(array_values($spent)) != 0) { - $data['datasets'][] = ['label' => 'Spent in category ' . $name, 'data' => array_values($spent)]; - } - if (array_sum(array_values($earned)) != 0) { - $data['datasets'][] = ['label' => 'Earned in category ' . $name, 'data' => array_values($earned)]; - } - } - $data['count'] = count($data['datasets']); - - return $data; - - } } diff --git a/app/Generator/Chart/PiggyBank/ChartJsPiggyBankChartGenerator.php b/app/Generator/Chart/PiggyBank/ChartJsPiggyBankChartGenerator.php index 3e10f5cac0..bea4b9605a 100644 --- a/app/Generator/Chart/PiggyBank/ChartJsPiggyBankChartGenerator.php +++ b/app/Generator/Chart/PiggyBank/ChartJsPiggyBankChartGenerator.php @@ -3,9 +3,7 @@ namespace FireflyIII\Generator\Chart\PiggyBank; use Carbon\Carbon; -use Config; use Illuminate\Support\Collection; -use Preferences; /** @@ -25,7 +23,7 @@ class ChartJsPiggyBankChartGenerator implements PiggyBankChartGenerator { // language: - $format = trans('config.month_and_day'); + $format = trans('config.month_and_day'); $data = [ 'count' => 1, diff --git a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php index 8cb01d82d3..1089ba7305 100644 --- a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php +++ b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php @@ -2,9 +2,7 @@ namespace FireflyIII\Generator\Chart\Report; -use Config; use Illuminate\Support\Collection; -use Preferences; /** * Class ChartJsReportChartGenerator @@ -14,40 +12,6 @@ use Preferences; class ChartJsReportChartGenerator implements ReportChartGenerator { - /** - * @param Collection $entries - * - * @return array - */ - public function yearInOut(Collection $entries) - { - // language: - $format = trans('config.month'); - - $data = [ - 'count' => 2, - 'labels' => [], - 'datasets' => [ - [ - 'label' => trans('firefly.income'), - 'data' => [] - ], - [ - 'label' => trans('firefly.expenses'), - 'data' => [] - ] - ], - ]; - - foreach ($entries as $entry) { - $data['labels'][] = $entry[0]->formatLocalized($format); - $data['datasets'][0]['data'][] = round($entry[1], 2); - $data['datasets'][1]['data'][] = round($entry[2], 2); - } - - return $data; - } - /** * Same as above but other translations. * @@ -81,6 +45,71 @@ class ChartJsReportChartGenerator implements ReportChartGenerator return $data; } + /** + * @param string $income + * @param string $expense + * @param int $count + * + * @return array + */ + public function multiYearInOutSummarized($income, $expense, $count) + { + $data = [ + 'count' => 2, + 'labels' => [trans('firefly.sum_of_years'), trans('firefly.average_of_years')], + 'datasets' => [ + [ + 'label' => trans('firefly.income'), + 'data' => [] + ], + [ + 'label' => trans('firefly.expenses'), + 'data' => [] + ] + ], + ]; + $data['datasets'][0]['data'][] = round($income, 2); + $data['datasets'][1]['data'][] = round($expense, 2); + $data['datasets'][0]['data'][] = round(($income / $count), 2); + $data['datasets'][1]['data'][] = round(($expense / $count), 2); + + return $data; + } + + /** + * @param Collection $entries + * + * @return array + */ + public function yearInOut(Collection $entries) + { + // language: + $format = trans('config.month'); + + $data = [ + 'count' => 2, + 'labels' => [], + 'datasets' => [ + [ + 'label' => trans('firefly.income'), + 'data' => [] + ], + [ + 'label' => trans('firefly.expenses'), + 'data' => [] + ] + ], + ]; + + foreach ($entries as $entry) { + $data['labels'][] = $entry[0]->formatLocalized($format); + $data['datasets'][0]['data'][] = round($entry[1], 2); + $data['datasets'][1]['data'][] = round($entry[2], 2); + } + + return $data; + } + /** * @param string $income * @param string $expense @@ -112,35 +141,4 @@ class ChartJsReportChartGenerator implements ReportChartGenerator return $data; } - - /** - * @param string $income - * @param string $expense - * @param int $count - * - * @return array - */ - public function multiYearInOutSummarized($income, $expense, $count) - { - $data = [ - 'count' => 2, - 'labels' => [trans('firefly.sum_of_years'), trans('firefly.average_of_years')], - 'datasets' => [ - [ - 'label' => trans('firefly.income'), - 'data' => [] - ], - [ - 'label' => trans('firefly.expenses'), - 'data' => [] - ] - ], - ]; - $data['datasets'][0]['data'][] = round($income, 2); - $data['datasets'][1]['data'][] = round($expense, 2); - $data['datasets'][0]['data'][] = round(($income / $count), 2); - $data['datasets'][1]['data'][] = round(($expense / $count), 2); - - return $data; - } } diff --git a/app/Helpers/Report/ReportQuery.php b/app/Helpers/Report/ReportQuery.php index 6714c22e4c..54798674f5 100644 --- a/app/Helpers/Report/ReportQuery.php +++ b/app/Helpers/Report/ReportQuery.php @@ -161,15 +161,15 @@ class ReportQuery implements ReportQueryInterface } } ); -// $data = $data->filter( -// function (TransactionJournal $journal) { -// if ($journal->amount != 0) { -// return $journal; -// } -// -// return null; -// } -// ); + // $data = $data->filter( + // function (TransactionJournal $journal) { + // if ($journal->amount != 0) { + // return $journal; + // } + // + // return null; + // } + // ); return $data; } diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index 2e595f74e2..03b2f36660 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -236,7 +236,7 @@ class BudgetController extends Controller // we already have amount, startdate and enddate. // if this "is" a limit repetition (as opposed to a budget without one entirely) // depends on whether startdate and enddate are null. - $name = $budget->name; + $name = $budget->name; if (is_null($budget->startdate) && is_null($budget->enddate)) { $currentStart = clone $start; $currentEnd = clone $end; @@ -252,7 +252,7 @@ class BudgetController extends Controller $amount = $budget->amount; // smaller than 1 means spent MORE than budget allows. $left = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? 0 : bcadd($budget->amount, $expenses); - $spent = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? ($amount*-1) : $expenses; + $spent = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? ($amount * -1) : $expenses; $overspent = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? bcadd($budget->amount, $expenses) : 0; } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index bb9b3d2bc6..465c38c441 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -1,7 +1,6 @@ data); - Carbon::setLocale(substr($pref->data,0,2)); + Carbon::setLocale(substr($pref->data, 0, 2)); $locale = explode(',', trans('config.locale')); $locale = array_map('trim', $locale); diff --git a/app/Models/Budget.php b/app/Models/Budget.php index 1435b50cf9..07e7b146ee 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -78,7 +78,7 @@ class Budget extends Model */ public function getDates() { - return ['created_at', 'updated_at', 'deleted_at','startdate','enddate']; + return ['created_at', 'updated_at', 'deleted_at', 'startdate', 'enddate']; } /** diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index ab722f3786..3af068660c 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -115,16 +115,16 @@ class BillRepository implements BillRepositoryInterface } $set = $bill->transactionjournals() - ->leftJoin( - 'transactions', function (JoinClause $join) { - $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id') - ->where('amount', '<', 0); - } - ) - ->orderBy('transaction_journals.date', 'DESC') - ->orderBy('transaction_journals.order', 'ASC') - ->orderBy('transaction_journals.id', 'DESC') - ->get(['transaction_journals.*', 'transactions.amount as journalAmount']); + ->leftJoin( + 'transactions', function (JoinClause $join) { + $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id') + ->where('amount', '<', 0); + } + ) + ->orderBy('transaction_journals.date', 'DESC') + ->orderBy('transaction_journals.order', 'ASC') + ->orderBy('transaction_journals.id', 'DESC') + ->get(['transaction_journals.*', 'transactions.amount as journalAmount']); $cache->store($set); return $set; diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.php index 39ad90b82f..9ac42a85be 100644 --- a/app/Repositories/Budget/BudgetRepositoryInterface.php +++ b/app/Repositories/Budget/BudgetRepositoryInterface.php @@ -108,6 +108,7 @@ interface BudgetRepositoryInterface /** * @deprecated + * * @param Budget $budget * * @return Carbon @@ -116,6 +117,7 @@ interface BudgetRepositoryInterface /** * @deprecated + * * @param Budget $budget * @param Carbon $date * diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index 8a94d61781..f45165648b 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -53,7 +53,7 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito $cache = new CacheProperties; $cache->addProperty('category-list'); - if($cache->has()) { + if ($cache->has()) { return $cache->get(); } diff --git a/app/Repositories/Shared/ComponentRepository.php b/app/Repositories/Shared/ComponentRepository.php index 99037c015c..f9584ef72d 100644 --- a/app/Repositories/Shared/ComponentRepository.php +++ b/app/Repositories/Shared/ComponentRepository.php @@ -46,7 +46,6 @@ class ComponentRepository } - $entry = $object->transactionjournals() ->transactionTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::OPENING_BALANCE]) ->before($end) diff --git a/resources/lang/fr_FR/firefly.php b/resources/lang/fr_FR/firefly.php index 53eedbd87e..d9dfa8daff 100644 --- a/resources/lang/fr_FR/firefly.php +++ b/resources/lang/fr_FR/firefly.php @@ -328,7 +328,7 @@ return [ 'Default account' => 'Asset account', 'Expense account' => 'Expense account', 'Revenue account' => 'Revenue account', - 'Initial balance account' => 'Initial balance account', + 'Initial balance account' => 'Initial balance account', 'budgets' => 'Budgets', 'tags' => 'Tags', 'reports' => 'Reports', @@ -364,13 +364,13 @@ return [ 'profile' => 'Profile', // reports - 'report_default' => 'Default financial report for :start until :end', - 'quick_link_reports' => 'Quick links', - 'quick_link_default_report' => 'Default financial report', - 'report_this_month_quick' => 'Current month, all accounts', - 'report_this_year_quick' => 'Current year, all accounts', - 'report_all_time_quick' => 'All-time, all accounts', - 'reports_can_bookmark' => 'Remember that reports can be bookmarked.', + 'report_default' => 'Default financial report for :start until :end', + 'quick_link_reports' => 'Quick links', + 'quick_link_default_report' => 'Default financial report', + 'report_this_month_quick' => 'Current month, all accounts', + 'report_this_year_quick' => 'Current year, all accounts', + 'report_all_time_quick' => 'All-time, all accounts', + 'reports_can_bookmark' => 'Remember that reports can be bookmarked.', 'incomeVsExpenses' => 'Income vs. expenses', 'accountBalances' => 'Account balances', 'balanceStartOfYear' => 'Balance at start of year', @@ -389,7 +389,7 @@ return [ 'outsideOfBudgets' => 'Outside of budgets', 'leftInBudget' => 'Left in budget', 'sumOfSums' => 'Sum of sums', - 'noCategory' => '(no category)', + 'noCategory' => '(no category)', 'notCharged' => 'Not charged (yet)', 'inactive' => 'Inactive', 'difference' => 'Difference', @@ -399,18 +399,18 @@ return [ 'showTheRest' => 'Show everything', 'hideTheRest' => 'Show only the top :number', 'sum_of_year' => 'Sum of year', - 'sum_of_years' => 'Sum of years', + 'sum_of_years' => 'Sum of years', 'average_of_year' => 'Average of year', - 'average_of_years' => 'Average of years', + 'average_of_years' => 'Average of years', 'categories_earned_in_year' => 'Categories (by earnings)', 'categories_spent_in_year' => 'Categories (by spendings)', - 'report_type' => 'Report type', - 'report_type_default' => 'Default financial report', - 'report_included_accounts' => 'Included accounts', - 'report_date_range' => 'Date range', - 'report_include_help' => 'In all cases, transfers to shared accounts count as expenses, and transfers from shared accounts count as income.', - 'report_preset_ranges' => 'Pre-set ranges', - 'shared' => 'Shared', + 'report_type' => 'Report type', + 'report_type_default' => 'Default financial report', + 'report_included_accounts' => 'Included accounts', + 'report_date_range' => 'Date range', + 'report_include_help' => 'In all cases, transfers to shared accounts count as expenses, and transfers from shared accounts count as income.', + 'report_preset_ranges' => 'Pre-set ranges', + 'shared' => 'Shared', // charts 'dayOfMonth' => 'Day of the month', diff --git a/resources/lang/nl_NL/validation.php b/resources/lang/nl_NL/validation.php index 33ec3e5570..bfd6f6004f 100644 --- a/resources/lang/nl_NL/validation.php +++ b/resources/lang/nl_NL/validation.php @@ -35,7 +35,7 @@ return [ "in" => ":attribute is ongeldig.", "integer" => ":attribute moet een getal zijn.", "ip" => ":attribute moet een geldig IP-adres zijn.", - 'json' => 'De :attribute moet een JSON tekst zijn.', + 'json' => 'De :attribute moet een JSON tekst zijn.', "max.numeric" => ":attribute mag niet hoger dan :max zijn.", "max.file" => ":attribute mag niet meer dan :max kilobytes zijn.", "max.string" => ":attribute mag niet uit meer dan :max karakters bestaan.", @@ -50,7 +50,7 @@ return [ "regex" => ":attribute formaat is ongeldig.", "required" => ":attribute is verplicht.", "required_if" => ":attribute is verplicht indien :other gelijk is aan :value.", - 'required_unless' => ':attribute is verplicht tenzij :other gelijk is aan :values.', + 'required_unless' => ':attribute is verplicht tenzij :other gelijk is aan :values.', "required_with" => ":attribute is verplicht i.c.m. :values", "required_with_all" => ":attribute is verplicht i.c.m. :values", "required_without" => ":attribute is verplicht als :values niet ingevuld is.", diff --git a/resources/lang/pt_BR/validation.php b/resources/lang/pt_BR/validation.php index 80f0e059f4..7819d30ce1 100755 --- a/resources/lang/pt_BR/validation.php +++ b/resources/lang/pt_BR/validation.php @@ -35,7 +35,7 @@ return [ "in" => "O campo :attribute não contém um valor válido.", "integer" => "O campo :attribute deverá conter um número inteiro.", "ip" => "O campo :attribute deverá conter um IP válido.", - 'json' => 'O campo :attribute deverá conter uma string JSON válida.', + 'json' => 'O campo :attribute deverá conter uma string JSON válida.', "max.numeric" => "O campo :attribute não deverá conter um valor superior a :max.", "max.file" => "O campo :attribute não deverá ter um tamanho superior a :max kilobytes.", "max.string" => "O campo :attribute não deverá conter mais de :max caracteres.", @@ -50,7 +50,7 @@ return [ "regex" => "O formato do valor para o campo :attribute é inválido.", "required" => "O campo :attribute é obrigatório.", "required_if" => "O campo :attribute é obrigatório quando o valor do campo :other é igual a :value.", - 'required_unless' => 'O campo :attribute é obrigatório a menos que :other esteja presente em :values.', + 'required_unless' => 'O campo :attribute é obrigatório a menos que :other esteja presente em :values.', "required_with" => "O campo :attribute é obrigatório quando :values está presente.", "required_with_all" => "O campo :attribute é obrigatório quando um dos :values está presente.", "required_without" => "O campo :attribute é obrigatório quanto :values não está presente.", diff --git a/resources/twig/emails/registered-html.twig b/resources/twig/emails/registered-html.twig index 48edb4ffc0..d05f6901d0 100644 --- a/resources/twig/emails/registered-html.twig +++ b/resources/twig/emails/registered-html.twig @@ -60,6 +60,7 @@ + diff --git a/resources/twig/form/amount.twig b/resources/twig/form/amount.twig index ea390ecddb..46f9fec160 100644 --- a/resources/twig/form/amount.twig +++ b/resources/twig/form/amount.twig @@ -5,7 +5,8 @@