Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Start with edit and view screens.
James Coleb7c446f7dbd1
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.phpindex ded94b2943..0aafa57c49 100644--- a/app/Http/Controllers/HomeController.php+++ b/app/Http/Controllers/HomeController.php@@ -153,10 +153,10 @@ class HomeController extends Controller{// these routes are not relevant for the help pages:$ignore = [- 'logout', 'register', 'bills.rescan', 'attachments.download', 'attachments.preview',- 'budgets.income', 'csv.download-config', 'currency.default', 'export.status', 'export.download',- 'json.', 'help.', 'piggy-banks.addMoney', 'piggy-banks.removeMoney', 'rules.rule.up', 'rules.rule.down',- 'rules.rule-group.up', 'rules.rule-group.down', 'debugbar',+// 'logout', 'register', 'bills.rescan', 'attachments.download', 'attachments.preview',+// 'budgets.income', 'csv.download-config', 'currency.default', 'export.status', 'export.download',+// 'json.', 'help.', 'piggy-banks.addMoney', 'piggy-banks.removeMoney', 'rules.rule.up', 'rules.rule.down',+// 'rules.rule-group.up', 'rules.rule-group.down', 'debugbar',];$routes = Route::getRoutes();/** @var \Illuminate\Routing\Route $route */@@ -166,9 +166,7 @@ class HomeController extends Controller$methods = $route->getMethods();if (!is_null($name) && in_array('GET', $methods) && !$this->startsWithAny($ignore, $name)) {- foreach (array_keys(config('firefly.languages')) as $lang) {- echo 'touch ' . $lang . '/' . $name . '.md<br>';- }+ echo $name . '<br>';}}diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.phpindex 62870495d3..53edce6490 100644--- a/app/Http/Controllers/Transaction/SplitController.php+++ b/app/Http/Controllers/Transaction/SplitController.php@@ -15,6 +15,7 @@ use FireflyIII\Crud\Split\JournalInterface;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Http\Requests\SplitJournalFormRequest;+use FireflyIII\Models\TransactionJournal;use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;@@ -41,6 +42,13 @@ class SplitController extends ControllerView::share('title', trans('firefly.split-transactions'));}+ public function edit(TransactionJournal $journal)+ {+ $count = $journal->transactions()->count();+ if ($count === 2) {+ return redirect(route('transactions.edit', [$journal->id]));+ }+ }/*** @param Request $request@@ -88,7 +96,8 @@ class SplitController extends Controller* @param SplitJournalFormRequest $request* @param JournalInterface $repository*- * @return mixed+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector+ * @throws FireflyException*/public function postJournalFromStore(SplitJournalFormRequest $request, JournalInterface $repository){diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.phpindex 71871aabaa..a03d971893 100644--- a/app/Http/Controllers/TransactionController.php+++ b/app/Http/Controllers/TransactionController.php@@ -12,6 +12,7 @@ namespace FireflyIII\Http\Controllers;use Amount;use Auth;use Carbon\Carbon;+use DB;use ExpandedForm;use FireflyIII\Events\TransactionJournalStored;use FireflyIII\Events\TransactionJournalUpdated;@@ -21,7 +22,6 @@ use FireflyIII\Http\Requests\MassDeleteJournalRequest;use FireflyIII\Http\Requests\MassEditJournalRequest;use FireflyIII\Models\PiggyBank;use FireflyIII\Models\PiggyBankEvent;-use FireflyIII\Models\Transaction;use FireflyIII\Models\TransactionJournal;use FireflyIII\Models\TransactionType;use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;@@ -147,6 +147,10 @@ class TransactionController extends Controller*/public function edit(TransactionJournal $journal){+ $count = $journal->transactions()->count();+ if ($count > 2) {+ return redirect(route('split.journal.edit', [$journal->id]));+ }/** @var ARI $accountRepository */$accountRepository = app(ARI::class);/** @var BudgetRepositoryInterface $budgetRepository */@@ -400,12 +404,11 @@ class TransactionController extends Controller}/**- * @param JournalRepositoryInterface $repository- * @param TransactionJournal $journal+ * @param TransactionJournal $journal** @return \Illuminate\View\View*/- public function show(JournalRepositoryInterface $repository, TransactionJournal $journal)+ public function show(TransactionJournal $journal){/** @var Collection $set */@@ -415,17 +418,13 @@ class TransactionController extends Controller$event->piggyBank = $event->piggyBank()->withTrashed()->first();});-- $journal->transactions->each(- function (Transaction $t) use ($journal, $repository) {- $t->before = $repository->getAmountBefore($journal, $t);- $t->after = bcadd($t->before, $t->amount);- }+ $transactions = $journal->transactions()->groupBy('transactions.account_id')->orderBy('amount', 'ASC')->get(+ ['transactions.*', DB::raw('SUM(`transactions`.`amount`) as `sum`')]);- $what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);- $subTitle = trans('firefly.' . $what) . ' "' . e($journal->description) . '"';+ $what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);+ $subTitle = trans('firefly.' . $what) . ' "' . e($journal->description) . '"';- return view('transactions.show', compact('journal', 'events', 'subTitle', 'what'));+ return view('transactions.show', compact('journal', 'events', 'subTitle', 'what', 'transactions'));}/**diff --git a/resources/views/transactions/show.twig b/resources/views/transactions/show.twigindex c139094dde..610d21acff 100644--- a/resources/views/transactions/show.twig+++ b/resources/views/transactions/show.twig@@ -132,7 +132,7 @@{% endif %}</td><td style="width:100px;">- <img src="{{ route('attachments.preview', att.id) }}" />+ <img src="{{ route('attachments.preview', att.id) }}"/></td></tr>{% endfor %}@@ -154,54 +154,103 @@{% endif %}</div><div class="col-lg-6 col-md-6 col-sm-12">+ {% if transactions.count == 2 %}+ {% for t in transactions %}+ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">{{ t.account.name }}</h3>+ </div>+ <table class="table table-bordered table-striped">+ <tr>+ <td style="width:30%;">{{ 'account'|_ }}</td>+ <td><a href="{{ route('accounts.show',t.account.id) }}">{{ t.account.name }}</a></td>+ </tr>+ <tr>+ <td>{{ 'account_type'|_ }}</td>+ <td>{{ t.account.accounttype.type|_ }}</td>+ </tr>+ <tr>+ <td>{{ 'amount'|_ }}</td>+ <td>{{ t|formatTransaction }}</td>+ </tr>+ <tr>+ <td>{{ 'newBalance'|_ }}</td>+ <td>null</td>+ </tr>+ {% if t.description %}+ <tr>+ <td>{{ trans('form.description') }}</td>+ <td>{{ t.description }}</td>+ </tr>+ {% endif %}+ {% if t.categories[0] %}+ <tr>+ <td>{{ 'category'|_ }}</td>+ <td>+ <a href="{{ route('categories.show',t.categories[0].id) }}">{{ t.categories[0].name }}</a>+ </td>+ </tr>+ {% endif %}+ {% if t.budgets[0] %}+ <tr>+ <td>{{ 'budget'|_ }}</td>+ <td>+ <a href="{{ route('budgets.show',t.budgets[0].id) }}">{{ t.budgets[0].name }}</a>+ </td>+ </tr>+ {% endif %}+ </table>+ </div>+ {% endfor %}+ {% endif %}+ </div>+ </div>++ <!-- more than two start-->+ {% if transactions.count > 2 %}+ <div class="row">+ <div class="col-lg-12 col-md-12 col-sm-12">- {% for t in journal.transactions %}<div class="box"><div class="box-header with-border">- <h3 class="box-title">{{ t.account.name }}</h3>+ <h3 class="box-title">Transactions</h3></div><table class="table table-bordered table-striped">+ <thead><tr>- <td style="width:30%;">{{ 'account'|_ }}</td>- <td><a href="{{ route('accounts.show',t.account.id) }}">{{ t.account.name }}</a></td>+ <th>{{ trans('list.account') }}</th>+ <th>{{ trans('list.account_type') }}</th>+ <th>{{ trans('list.amount') }}</th>+ <th>{{ trans('list.new_balance') }}</th>+ <th>{{ trans('list.description') }}</th>+ <th>{{ trans('list.category') }}</th>+ <th>{{ trans('list.budget') }}</th></tr>+ </thead>+ <tbody>+ {% for t in transactions %}<tr>- <td>{{ 'account_type'|_ }}</td>+ <td><a href="{{ route('accounts.show',t.account.id) }}">{{ t.account.name }}</a></td><td>{{ t.account.accounttype.type|_ }}</td>- </tr>- <tr>- <td>{{ 'amount'|_ }}</td>- <td>{{ t|formatTransaction }}</td>- </tr>- <tr>- <td>{{ 'newBalance'|_ }}</td>- <td>{{ t.before|formatAmount }} → {{ t.after|formatAmount }}</td>- </tr>- {% if t.description %}- <tr>- <td>{{ trans('form.description') }}</td>- <td>{{ t.description }}</td>- </tr>- {% endif %}- {% if t.categories[0] %}- <tr>- <td>{{ 'category'|_ }}</td>- <td>+ <td>{{ t.sum|formatAmount }}</td>+ <td>null</td>+ <td>{{ t.description }}</td>+ <td>+ {% if t.categories[0] %}<a href="{{ route('categories.show',t.categories[0].id) }}">{{ t.categories[0].name }}</a>- </td>- </tr>- {% endif %}- {% if t.budgets[0] %}- <tr>- <td>{{ 'budget'|_ }}</td>- <td>+ {% endif %}+ </td>+ <td>+ {% if t.budgets[0] %}<a href="{{ route('budgets.show',t.budgets[0].id) }}">{{ t.budgets[0].name }}</a>- </td>- </tr>- {% endif %}+ {% endif %}+ </td>+ {% endfor %}+ </tbody></table></div>- {% endfor %}+ </div></div>- </div>+ {% endif %}+ <!-- end -->{% endblock %}