Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fixed split journals views.
James Cole4cbb0d971607
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.phpindex 246ea45efd..d52e414c3a 100644--- a/app/Http/Controllers/AccountController.php+++ b/app/Http/Controllers/AccountController.php@@ -41,8 +41,6 @@ class AccountController extends Controller*/public function create(string $what = 'asset'){--$subTitleIcon = config('firefly.subIconsByIdentifier.' . $what);$subTitle = trans('firefly.make_new_' . $what . '_account');Session::flash('preFilled', []);@@ -190,16 +188,18 @@ class AccountController extends Controllerpublic function show(ARI $repository, Account $account){// show journals from current period only:- $range = Preferences::get('viewRange', '1M')->data;- $start = session('start', Navigation::startOfPeriod(new Carbon, $range));- $end = session('end', Navigation::endOfPeriod(new Carbon, $range));- $page = intval(Input::get('page'));- $pageSize = Preferences::get('transactionPageSize', 50)->data;- $offset = ($page - 1) * $pageSize;- $set = $repository->journalsInPeriod(new Collection([$account]), [], $start, $end);- $count = $set->count();- $subSet = $set->splice($offset, $pageSize);- $journals = new LengthAwarePaginator($subSet, $count, $pageSize, $page);+ $subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);+ $subTitle = $account->name;+ $range = Preferences::get('viewRange', '1M')->data;+ $start = session('start', Navigation::startOfPeriod(new Carbon, $range));+ $end = session('end', Navigation::endOfPeriod(new Carbon, $range));+ $page = intval(Input::get('page'));+ $pageSize = Preferences::get('transactionPageSize', 50)->data;+ $offset = ($page - 1) * $pageSize;+ $set = $repository->journalsInPeriod(new Collection([$account]), [], $start, $end);+ $count = $set->count();+ $subSet = $set->splice($offset, $pageSize);+ $journals = new LengthAwarePaginator($subSet, $count, $pageSize, $page);$journals->setPath('accounts/show/' . $account->id);// grouped other months thing:diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.phpindex 8d1d8b3369..c2d6f29a72 100644--- a/app/Http/Controllers/CategoryController.php+++ b/app/Http/Controllers/CategoryController.php@@ -163,6 +163,8 @@ class CategoryController extends Controller$set = $repository->journalsInPeriod(new Collection([$category]), new Collection, [], $start, $end);$count = $set->count();$subSet = $set->splice($offset, $pageSize);+ $subTitle = $category->name;+ $subTitleIcon = 'fa-bar-chart';$journals = new LengthAwarePaginator($subSet, $count, $pageSize, $page);$journals->setPath('categories/show/' . $category->id);@@ -187,7 +189,7 @@ class CategoryController extends Controllerif ($cache->has()) {$entries = $cache->get();- return view('categories.show', compact('category', 'journals', 'entries', 'hideCategory', 'subTitle'));+ return view('categories.show', compact('category', 'journals', 'entries', 'subTitleIcon', 'hideCategory', 'subTitle'));}diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.phpindex 6dacf03f22..e647b7aee0 100644--- a/app/Repositories/Category/CategoryRepository.php+++ b/app/Repositories/Category/CategoryRepository.php@@ -241,10 +241,12 @@ class CategoryRepository implements CategoryRepositoryInterface// that should do it:$first = $query->get(TransactionJournal::queryFields());+// then collection transactions (harder)- $query = $this->user->transactions()- ->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'))- ->where('transaction_journals.date', '<=', $end->format('Y-m-d 23:59:59'));+ $query = $this->user->transactionjournals()->distinct()+ ->leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')+ ->leftJoin('category_transaction', 'category_transaction.transaction_id', '=', 'transactions.id');+if (count($types) > 0) {$query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id');$query->whereIn('transaction_types.type', $types);@@ -255,10 +257,12 @@ class CategoryRepository implements CategoryRepositoryInterface}if ($categories->count() > 0) {$categoryIds = $categories->pluck('id')->toArray();- $query->leftJoin('category_transaction', 'category_transaction.transaction_id', '=', 'transactions.id');$query->whereIn('category_transaction.category_id', $categoryIds);}- $second = $query->get(['transaction_journals.*']);+++ $second = $query->get(['transaction_journals.*']);+$complete = $complete->merge($first);$complete = $complete->merge($second);diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.phpindex a0332ca6b7..16d8b7ba1b 100644--- a/app/Support/Twig/Journal.php+++ b/app/Support/Twig/Journal.php@@ -6,6 +6,7 @@ namespace FireflyIII\Support\Twig;use Amount;use FireflyIII\Models\Account;+use FireflyIII\Models\Budget;use FireflyIII\Models\Transaction;use FireflyIII\Models\TransactionJournal;use FireflyIII\Support\CacheProperties;@@ -21,6 +22,31 @@ use Twig_SimpleFunction;class Journal extends Twig_Extension{+ /**+ * @return Twig_SimpleFunction+ */+ public function formatBudgetPerspective(): Twig_SimpleFunction+ {+ return new Twig_SimpleFunction(+ 'formatBudgetPerspective', function (TransactionJournal $journal, Budget $budget) {+ // get the account amount:+ $transactions = $journal->transactions()->where('transactions.amount', '<', 0)->get(['transactions.*']);+ $amount = '0';+ foreach ($transactions as $transaction) {+ $currentBudget = $transaction->budgets->first();+ if (!is_null($currentBudget) && $currentBudget->id === $budget->id) {+ $amount = bcadd($amount, strval($transaction->amount));+ }+ }++ $formatted = Amount::format($amount, true);++ return $formatted . ' (' . Amount::formatJournal($journal) . ')';+ }+ );+ }++/*** @return Twig_SimpleFunction*/@@ -30,8 +56,12 @@ class Journal extends Twig_Extension'formatPerspective', function (TransactionJournal $journal, Account $account) {// get the account amount:- $transaction = $journal->transactions()->where('transactions.account_id', $account->id)->first();- $amount = $transaction->amount;+ $transactions = $journal->transactions()->where('transactions.account_id', $account->id)->get(['transactions.*']);+ $amount = '0';+ foreach ($transactions as $transaction) {+ $amount = bcadd($amount, strval($transaction->amount));+ }+if ($journal->isWithdrawal()) {$amount = bcmul($amount, '-1');}@@ -97,6 +127,7 @@ class Journal extends Twig_Extension$this->getSourceAccount(),$this->getDestinationAccount(),$this->formatPerspective(),+ $this->formatBudgetPerspective(),$this->journalBudgets(),$this->journalCategories(),$this->transactionBudgets(),diff --git a/resources/views/budgets/show.twig b/resources/views/budgets/show.twigindex 5c0ba0c54a..efb3505202 100644--- a/resources/views/budgets/show.twig+++ b/resources/views/budgets/show.twig@@ -36,7 +36,7 @@<h3 class="box-title">{{ 'transactions'|_ }}</h3></div><div class="box-body">- {% include 'list.journals' %}+ {% include 'list.journals' with {budgetPerspective: budget} %}</div></div></div>diff --git a/resources/views/emails/error-html.blade.php b/resources/views/emails/error-html.blade.phpnew file mode 100644index 0000000000..778f5eac56--- /dev/null+++ b/resources/views/emails/error-html.blade.php@@ -0,0 +1,52 @@+<!DOCTYPE html>+<html xmlns="http://www.w3.org/1999/xhtml">+<head>+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">++</head>+<body>+<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">+ Firefly III ran into an error: <span style="font-family: monospace;">{{ errorMessage }}</span>+</p>++<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">+The error was of type "{{ class }}".+</p>++<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">+The error occured on/at: {{ time }}.+</p>++<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">+ This error occured in file <span style="font-family: monospace;">{{ file }}</span> on line {{ line }} with code {{ code }}.+</p>++<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">+ {% if loggedIn %}+ The error was encountered by user #{{ user.id }}, <a href="mailto:{{ user.email }}">{{ user.email }}</a>.+ {% else %}+ There was no user logged in for this error or no user was detected.+ {% endif %}+</p>++<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">+ The IP address related to this error is: {{ ip }}+</p>++<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">+ The full stacktrace is below. If you think this is a bug in Firefly III, you+ can forward this message to+ <a href="mailto:[email protected]?subject=BUG!">[email protected]</a>.+ This can help fix the bug you just encountered.+</p>+<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">+ If you prefer, you can also open a new issue on <a href="https://github.com/JC5/firefly-iii/issues/new">Github</a>.+</p>++<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">+ The full stacktrace is below:</p>+<p style="font-family: monospace;font-size:11px;color:#aaa">+ {{ stacktrace|nl2br }}+</p>+</body>+</html>diff --git a/resources/views/list/journals.twig b/resources/views/list/journals.twigindex c9d0145995..0801bad16d 100644--- a/resources/views/list/journals.twig+++ b/resources/views/list/journals.twig@@ -57,11 +57,17 @@</td><td>- {% if not accountPerspective %}+ {% if not accountPerspective and not budgetPerspective %}{{ journal|formatJournal }}- {% else %}+ {% endif %}++ {% if accountPerspective %}{{ formatPerspective(journal, accountPerspective)|raw }}{% endif %}++ {% if budgetPerspective %}+ {{ formatBudgetPerspective(journal, budgetPerspective)|raw }}+ {% endif %}</td><td class="hidden-sm hidden-xs">{{ journal.date.formatLocalized(monthAndDayFormat) }}diff --git a/storage/database/seed.split.json b/storage/database/seed.split.jsonindex 95579e9718..aa276339e7 100644--- a/storage/database/seed.split.json+++ b/storage/database/seed.split.json@@ -274,7 +274,7 @@},{"user_id": 1,- "date": "2016-03-28",+ "date": "2016-05-08","description": "Uneven multi-transfer (15,34,51)","source_ids": [1,