Start with edit and view screens.

This commit is contained in:
James Cole 2016-05-11 23:03:13 +02:00
parent 7c39a04c4b
commit b7c446f7db
4 changed files with 124 additions and 69 deletions

View File

@ -153,10 +153,10 @@ class HomeController extends Controller
{ {
// these routes are not relevant for the help pages: // these routes are not relevant for the help pages:
$ignore = [ $ignore = [
'logout', 'register', 'bills.rescan', 'attachments.download', 'attachments.preview', // 'logout', 'register', 'bills.rescan', 'attachments.download', 'attachments.preview',
'budgets.income', 'csv.download-config', 'currency.default', 'export.status', 'export.download', // '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', // 'json.', 'help.', 'piggy-banks.addMoney', 'piggy-banks.removeMoney', 'rules.rule.up', 'rules.rule.down',
'rules.rule-group.up', 'rules.rule-group.down', 'debugbar', // 'rules.rule-group.up', 'rules.rule-group.down', 'debugbar',
]; ];
$routes = Route::getRoutes(); $routes = Route::getRoutes();
/** @var \Illuminate\Routing\Route $route */ /** @var \Illuminate\Routing\Route $route */
@ -166,9 +166,7 @@ class HomeController extends Controller
$methods = $route->getMethods(); $methods = $route->getMethods();
if (!is_null($name) && in_array('GET', $methods) && !$this->startsWithAny($ignore, $name)) { if (!is_null($name) && in_array('GET', $methods) && !$this->startsWithAny($ignore, $name)) {
foreach (array_keys(config('firefly.languages')) as $lang) { echo $name . '<br>';
echo 'touch ' . $lang . '/' . $name . '.md<br>';
}
} }
} }

View File

@ -15,6 +15,7 @@ use FireflyIII\Crud\Split\JournalInterface;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\SplitJournalFormRequest; use FireflyIII\Http\Requests\SplitJournalFormRequest;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
@ -41,6 +42,13 @@ class SplitController extends Controller
View::share('title', trans('firefly.split-transactions')); View::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 * @param Request $request
@ -88,7 +96,8 @@ class SplitController extends Controller
* @param SplitJournalFormRequest $request * @param SplitJournalFormRequest $request
* @param JournalInterface $repository * @param JournalInterface $repository
* *
* @return mixed * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws FireflyException
*/ */
public function postJournalFromStore(SplitJournalFormRequest $request, JournalInterface $repository) public function postJournalFromStore(SplitJournalFormRequest $request, JournalInterface $repository)
{ {

View File

@ -12,6 +12,7 @@ namespace FireflyIII\Http\Controllers;
use Amount; use Amount;
use Auth; use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use DB;
use ExpandedForm; use ExpandedForm;
use FireflyIII\Events\TransactionJournalStored; use FireflyIII\Events\TransactionJournalStored;
use FireflyIII\Events\TransactionJournalUpdated; use FireflyIII\Events\TransactionJournalUpdated;
@ -21,7 +22,6 @@ use FireflyIII\Http\Requests\MassDeleteJournalRequest;
use FireflyIII\Http\Requests\MassEditJournalRequest; use FireflyIII\Http\Requests\MassEditJournalRequest;
use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankEvent; use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI; use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
@ -147,6 +147,10 @@ class TransactionController extends Controller
*/ */
public function edit(TransactionJournal $journal) public function edit(TransactionJournal $journal)
{ {
$count = $journal->transactions()->count();
if ($count > 2) {
return redirect(route('split.journal.edit', [$journal->id]));
}
/** @var ARI $accountRepository */ /** @var ARI $accountRepository */
$accountRepository = app(ARI::class); $accountRepository = app(ARI::class);
/** @var BudgetRepositoryInterface $budgetRepository */ /** @var BudgetRepositoryInterface $budgetRepository */
@ -400,12 +404,11 @@ class TransactionController extends Controller
} }
/** /**
* @param JournalRepositoryInterface $repository * @param TransactionJournal $journal
* @param TransactionJournal $journal
* *
* @return \Illuminate\View\View * @return \Illuminate\View\View
*/ */
public function show(JournalRepositoryInterface $repository, TransactionJournal $journal) public function show(TransactionJournal $journal)
{ {
/** @var Collection $set */ /** @var Collection $set */
@ -415,17 +418,13 @@ class TransactionController extends Controller
$event->piggyBank = $event->piggyBank()->withTrashed()->first(); $event->piggyBank = $event->piggyBank()->withTrashed()->first();
} }
); );
$transactions = $journal->transactions()->groupBy('transactions.account_id')->orderBy('amount', 'ASC')->get(
$journal->transactions->each( ['transactions.*', DB::raw('SUM(`transactions`.`amount`) as `sum`')]
function (Transaction $t) use ($journal, $repository) {
$t->before = $repository->getAmountBefore($journal, $t);
$t->after = bcadd($t->before, $t->amount);
}
); );
$what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type); $what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
$subTitle = trans('firefly.' . $what) . ' "' . e($journal->description) . '"'; $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'));
} }
/** /**

View File

@ -132,7 +132,7 @@
{% endif %} {% endif %}
</td> </td>
<td style="width:100px;"> <td style="width:100px;">
<img src="{{ route('attachments.preview', att.id) }}" /> <img src="{{ route('attachments.preview', att.id) }}"/>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
@ -154,54 +154,103 @@
{% endif %} {% endif %}
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-12"> <div class="col-lg-6 col-md-6 col-sm-12">
{% if transactions.count == 2 %}
{% for t in journal.transactions %} {% for t in transactions %}
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">{{ t.account.name }}</h3> <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> </div>
<table class="table table-bordered table-striped"> {% endfor %}
<tr> {% endif %}
<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>{{ t.before|formatAmount }} &rarr; {{ 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>
<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 %}
</div> </div>
</div> </div>
<!-- more than two start-->
{% if transactions.count > 2 %}
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Transactions</h3>
</div>
<table class="table table-bordered table-striped">
<thead>
<tr>
<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><a href="{{ route('accounts.show',t.account.id) }}">{{ t.account.name }}</a></td>
<td>{{ t.account.accounttype.type|_ }}</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>
{% endif %}
</td>
<td>
{% if t.budgets[0] %}
<a href="{{ route('budgets.show',t.budgets[0].id) }}">{{ t.budgets[0].name }}</a>
{% endif %}
</td>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
<!-- end -->
{% endblock %} {% endblock %}