Improvements for #616 and others.

This commit is contained in:
James Cole 2017-08-23 21:21:42 +02:00
parent 1a89e379a4
commit 394e92d538
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
19 changed files with 383 additions and 55 deletions

View File

@ -152,6 +152,18 @@ class LinkController extends Controller
return view('admin.link.index', compact('subTitle', 'subTitleIcon', 'linkTypes')); return view('admin.link.index', compact('subTitle', 'subTitleIcon', 'linkTypes'));
} }
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show(LinkType $linkType)
{
$subTitle = trans('firefly.overview_for_link', ['name' => $linkType->name]);
$subTitleIcon = 'fa-link';
$links = $linkType->transactionJournalLinks()->get();
return view('admin.link.show', compact('subTitle', 'subTitleIcon', 'linkType', 'links'));
}
/** /**
* @param LinkTypeFormRequest $request * @param LinkTypeFormRequest $request
* @param LinkTypeRepositoryInterface $repository * @param LinkTypeRepositoryInterface $repository

View File

@ -13,17 +13,83 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Transaction; namespace FireflyIII\Http\Controllers\Transaction;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\JournalLinkRequest; use FireflyIII\Http\Requests\JournalLinkRequest;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionJournalLink; use FireflyIII\Models\TransactionJournalLink;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface; use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
use Log; use Log;
use Preferences;
use Session; use Session;
use URL;
use View;
class LinkController /**
* Class LinkController
*
* @package FireflyIII\Http\Controllers\Transaction
*/
class LinkController extends Controller
{ {
/**
*
*/
public function __construct()
{
parent::__construct();
// some useful repositories:
$this->middleware(
function ($request, $next) {
View::share('title', trans('firefly.transactions'));
View::share('mainTitleIcon', 'fa-repeat');
return $next($request);
}
);
}
/**
* @param TransactionJournalLink $link
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function delete(TransactionJournalLink $link)
{
$subTitleIcon = 'fa-link';
$subTitle = trans('breadcrumbs.delete_journal_link');
$this->rememberPreviousUri('journal_links.delete.uri');
return view('transactions.links.delete', compact('link', 'subTitle', 'subTitleIcon'));
}
/**
* @param LinkTypeRepositoryInterface $repository
* @param TransactionJournalLink $link
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function destroy(LinkTypeRepositoryInterface $repository, TransactionJournalLink $link)
{
$repository->destroyLink($link);
Session::flash('success', strval(trans('firefly.deleted_link')));
Preferences::mark();
return redirect(strval(session('journal_links.delete.uri')));
}
public function switch(LinkTypeRepositoryInterface $repository, TransactionJournalLink $link) {
$repository->switchLink($link);
return redirect(URL::previous());
}
/** /**
* @param JournalLinkRequest $request * @param JournalLinkRequest $request
* @param LinkTypeRepositoryInterface $repository * @param LinkTypeRepositoryInterface $repository

View File

@ -28,6 +28,7 @@ use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\Tag; use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionJournalLink;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@ -167,6 +168,13 @@ Breadcrumbs::register(
} }
); );
Breadcrumbs::register(
'admin.links.show', function (BreadCrumbGenerator $breadcrumbs, LinkType $linkType) {
$breadcrumbs->parent('admin.links.index');
$breadcrumbs->push(trans('firefly.overview_for_link', [$linkType->name]), route('admin.links.show', [$linkType->id]));
}
);
Breadcrumbs::register( Breadcrumbs::register(
'admin.links.edit', function (BreadCrumbGenerator $breadcrumbs, LinkType $linkType) { 'admin.links.edit', function (BreadCrumbGenerator $breadcrumbs, LinkType $linkType) {
$breadcrumbs->parent('admin.links.index'); $breadcrumbs->parent('admin.links.index');
@ -181,6 +189,14 @@ Breadcrumbs::register(
} }
); );
Breadcrumbs::register(
'transactions.link.delete', function (BreadCrumbGenerator $breadcrumbs, TransactionJournalLink $link) {
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.delete_journal_link'), route('transactions.link.delete', $link->id));
}
);
/** /**
* ATTACHMENTS * ATTACHMENTS
*/ */

View File

@ -14,6 +14,7 @@ namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* @property int $journalCount * @property int $journalCount
@ -36,7 +37,25 @@ class LinkType extends Model
'editable' => 'boolean', 'editable' => 'boolean',
]; ];
public function transactionJournalLinks() { /**
* @param $value
*
* @return mixed
* @throws NotFoundHttpException
*/
public static function routeBinder($value)
{
if (auth()->check()) {
$model = self::where('id', $value)->first();
if (!is_null($model)) {
return $model;
}
}
throw new NotFoundHttpException;
}
public function transactionJournalLinks()
{
return $this->hasMany(TransactionJournalLink::class); return $this->hasMany(TransactionJournalLink::class);
} }

View File

@ -16,6 +16,7 @@ namespace FireflyIII\Models;
use Crypt; use Crypt;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* Class TransactionJournalLink * Class TransactionJournalLink
@ -26,6 +27,28 @@ class TransactionJournalLink extends Model
{ {
protected $table = 'journal_links'; protected $table = 'journal_links';
/**
* @param $value
*
* @return mixed
* @throws NotFoundHttpException
*/
public static function routeBinder($value)
{
if (auth()->check()) {
$model = self::where('journal_links.id', $value)
->leftJoin('transaction_journals as t_a', 't_a.id', '=', 'source_id')
->leftJoin('transaction_journals as t_b', 't_b.id', '=', 'destination_id')
->where('t_a.user_id', auth()->user()->id)
->where('t_b.user_id', auth()->user()->id)
->first(['journal_links.*']);
if (!is_null($model)) {
return $model;
}
}
throw new NotFoundHttpException;
}
/** /**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */

View File

@ -54,6 +54,18 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
return true; return true;
} }
/**
* @param TransactionJournalLink $link
*
* @return bool
*/
public function destroyLink(TransactionJournalLink $link): bool
{
$link->delete();
return true;
}
/** /**
* @param int $id * @param int $id
* *
@ -135,6 +147,21 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
return $linkType; return $linkType;
} }
/**
* @param TransactionJournalLink $link
*
* @return bool
*/
public function switchLink(TransactionJournalLink $link): bool
{
$source = $link->source_id;
$link->source_id = $link->destination_id;
$link->destination_id = $source;
$link->save();
return true;
}
/** /**
* @param LinkType $linkType * @param LinkType $linkType
* @param array $data * @param array $data

View File

@ -14,6 +14,7 @@ namespace FireflyIII\Repositories\LinkType;
use FireflyIII\Models\LinkType; use FireflyIII\Models\LinkType;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionJournalLink;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
@ -45,6 +46,20 @@ interface LinkTypeRepositoryInterface
*/ */
public function find(int $id): LinkType; public function find(int $id): LinkType;
/**
* @param TransactionJournalLink $link
*
* @return bool
*/
public function destroyLink(TransactionJournalLink $link):bool;
/**
* @param TransactionJournalLink $link
*
* @return bool
*/
public function switchLink(TransactionJournalLink $link): bool;
/** /**
* Check if link exists between journals. * Check if link exists between journals.
* *

View File

@ -300,6 +300,7 @@ class Amount
public function transactionAmount(TransactionModel $transaction, bool $coloured = true): string public function transactionAmount(TransactionModel $transaction, bool $coloured = true): string
{ {
$amount = bcmul(app('steam')->positive(strval($transaction->transaction_amount)), '-1'); $amount = bcmul(app('steam')->positive(strval($transaction->transaction_amount)), '-1');
$format = '%s'; $format = '%s';
if ($transaction->transaction_type_type === TransactionType::DEPOSIT) { if ($transaction->transaction_type_type === TransactionType::DEPOSIT) {
@ -322,7 +323,11 @@ class Amount
if (!is_null($transaction->transaction_foreign_amount)) { if (!is_null($transaction->transaction_foreign_amount)) {
$amount = strval($transaction->transaction_foreign_amount); $amount = bcmul(app('steam')->positive(strval($transaction->transaction_foreign_amount)), '-1');
if ($transaction->transaction_type_type === TransactionType::DEPOSIT) {
$amount = bcmul($amount, '-1');
}
if ($transaction->transaction_type_type === TransactionType::TRANSFER) { if ($transaction->transaction_type_type === TransactionType::TRANSFER) {
$amount = app('steam')->positive($amount); $amount = app('steam')->positive($amount);

View File

@ -46,6 +46,7 @@ class AmountFormat extends Twig_Extension
{ {
return [ return [
$this->formatAmountByAccount(), $this->formatAmountByAccount(),
$this->formatAmountBySymbol(),
$this->transactionAmount(), $this->transactionAmount(),
$this->journalAmount(), $this->journalAmount(),
$this->formatDestinationAfter(), $this->formatDestinationAfter(),
@ -108,6 +109,26 @@ class AmountFormat extends Twig_Extension
); );
} }
/**
* Will format the amount by the currency related to the given account.
*
* @return Twig_SimpleFunction
*/
protected function formatAmountBySymbol(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'formatAmountBySymbol', function (string $amount, string $symbol, int $decimalPlaces = 2, bool $coloured = true): string {
$currency = new TransactionCurrency;
$currency->symbol = $symbol;
$currency->decimal_places = $decimalPlaces;
return app('amount')->formatAnything($currency, $amount, $coloured);
}, ['is_safe' => ['html']]
);
}
/** /**
* Will format the amount by the currency related to the given account. * Will format the amount by the currency related to the given account.
* *

View File

@ -13,31 +13,32 @@ declare(strict_types=1);
*/ */
return [ return [
'home' => 'Home', 'home' => 'Home',
'edit_currency' => 'Edit currency ":name"', 'edit_currency' => 'Edit currency ":name"',
'delete_currency' => 'Delete currency ":name"', 'delete_currency' => 'Delete currency ":name"',
'newPiggyBank' => 'Create a new piggy bank', 'newPiggyBank' => 'Create a new piggy bank',
'edit_piggyBank' => 'Edit piggy bank ":name"', 'edit_piggyBank' => 'Edit piggy bank ":name"',
'preferences' => 'Preferences', 'preferences' => 'Preferences',
'profile' => 'Profile', 'profile' => 'Profile',
'changePassword' => 'Change your password', 'changePassword' => 'Change your password',
'bills' => 'Bills', 'bills' => 'Bills',
'newBill' => 'New bill', 'newBill' => 'New bill',
'edit_bill' => 'Edit bill ":name"', 'edit_bill' => 'Edit bill ":name"',
'delete_bill' => 'Delete bill ":name"', 'delete_bill' => 'Delete bill ":name"',
'reports' => 'Reports', 'reports' => 'Reports',
'search_result' => 'Search results for ":query"', 'search_result' => 'Search results for ":query"',
'withdrawal_list' => 'Expenses', 'withdrawal_list' => 'Expenses',
'deposit_list' => 'Revenue, income and deposits', 'deposit_list' => 'Revenue, income and deposits',
'transfer_list' => 'Transfers', 'transfer_list' => 'Transfers',
'transfers_list' => 'Transfers', 'transfers_list' => 'Transfers',
'create_withdrawal' => 'Create new withdrawal', 'create_withdrawal' => 'Create new withdrawal',
'create_deposit' => 'Create new deposit', 'create_deposit' => 'Create new deposit',
'create_transfer' => 'Create new transfer', 'create_transfer' => 'Create new transfer',
'edit_journal' => 'Edit transaction ":description"', 'edit_journal' => 'Edit transaction ":description"',
'delete_journal' => 'Delete transaction ":description"', 'delete_journal' => 'Delete transaction ":description"',
'tags' => 'Tags', 'tags' => 'Tags',
'createTag' => 'Create new tag', 'createTag' => 'Create new tag',
'edit_tag' => 'Edit tag ":tag"', 'edit_tag' => 'Edit tag ":tag"',
'delete_tag' => 'Delete tag ":tag"', 'delete_tag' => 'Delete tag ":tag"',
'delete_journal_link' => 'Delete link between journals',
]; ];

View File

@ -965,6 +965,9 @@ return [
'this_withdrawal' => 'This withdrawal', 'this_withdrawal' => 'This withdrawal',
'this_deposit' => 'This deposit', 'this_deposit' => 'This deposit',
'this_transfer' => 'This transfer', 'this_transfer' => 'This transfer',
'overview_for_link' => 'Overview for link type ":name"',
'delete_journal_link' => 'Delete the link between <a href=":source_link">:source</a> and <a href=":destination_link">:destination</a>',
'deleted_link' => 'Deleted link',
// split a transaction: // split a transaction:

View File

@ -148,13 +148,14 @@ return [
'journal_areYouSure' => 'Are you sure you want to delete the transaction described ":description"?', 'journal_areYouSure' => 'Are you sure you want to delete the transaction described ":description"?',
'mass_journal_are_you_sure' => 'Are you sure you want to delete these transactions?', 'mass_journal_are_you_sure' => 'Are you sure you want to delete these transactions?',
'tag_areYouSure' => 'Are you sure you want to delete the tag ":tag"?', 'tag_areYouSure' => 'Are you sure you want to delete the tag ":tag"?',
'journal_link_areYouSure' => 'Are you sure you want to delete the link between <a href=":source_link">:source</a> and <a href=":destination_link">:destination</a>?',
'linkType_areYouSure' => 'Are you sure you want to delete the link type ":name" (":inward" / ":outward")?', 'linkType_areYouSure' => 'Are you sure you want to delete the link type ":name" (":inward" / ":outward")?',
'permDeleteWarning' => 'Deleting stuff from Firely is permanent and cannot be undone.', 'permDeleteWarning' => 'Deleting stuff from Firely is permanent and cannot be undone.',
'mass_make_selection' => 'You can still prevent items from being deleted by removing the checkbox.', 'mass_make_selection' => 'You can still prevent items from being deleted by removing the checkbox.',
'delete_all_permanently' => 'Delete selected permanently', 'delete_all_permanently' => 'Delete selected permanently',
'update_all_journals' => 'Update these transactions', 'update_all_journals' => 'Update these transactions',
'also_delete_transactions' => 'The only transaction connected to this account will be deleted as well.|All :count transactions connected to this account will be deleted as well.', 'also_delete_transactions' => 'The only transaction connected to this account will be deleted as well.|All :count transactions connected to this account will be deleted as well.',
'also_delete_connections' => 'The only transaction linked with this link type will lose this connection.|All :count transactions linked with this link type will lose their connection.', 'also_delete_connections' => 'The only transaction linked with this link type will lose this connection.|All :count transactions linked with this link type will lose their connection.',
'also_delete_rules' => 'The only rule connected to this rule group will be deleted as well.|All :count rules connected to this rule group will be deleted as well.', 'also_delete_rules' => 'The only rule connected to this rule group will be deleted as well.|All :count rules connected to this rule group will be deleted as well.',
'also_delete_piggyBanks' => 'The only piggy bank connected to this account will be deleted as well.|All :count piggy bank connected to this account will be deleted as well.', 'also_delete_piggyBanks' => 'The only piggy bank connected to this account will be deleted as well.|All :count piggy bank connected to this account will be deleted as well.',
'bill_keep_transactions' => 'The only transaction connected to this bill will not be deleted.|All :count transactions connected to this bill will spared deletion.', 'bill_keep_transactions' => 'The only transaction connected to this bill will not be deleted.|All :count transactions connected to this bill will spared deletion.',

View File

@ -42,7 +42,7 @@
{{ linkType.outward }} {{ linkType.outward }}
</td> </td>
<td data-value="{{ linkType.journalCount }}"> <td data-value="{{ linkType.journalCount }}">
{{ linkType.journalCount }} <a href="{{ route('admin.links.show', [linkType.id]) }}">{{ linkType.journalCount }}</a>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
@ -55,6 +55,12 @@
</div> </div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
{% block scripts %}
<script type="text/javascript" src="js/lib/bootstrap-sortable.js"></script>
{% endblock %}
{% block styles %}
<link rel="stylesheet" href="css/bootstrap-sortable.css" type="text/css" media="all"/>
{% endblock %}

View File

@ -0,0 +1,62 @@
{% extends "./layout/default" %}
{% block breadcrumbs %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, linkType) }}
{% endblock %}
{% block content %}
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('firefly.overview_for_link', {name: linkType.name}) }}</h3>
</div>
<div class="box-body no-padding">
<table class="table table-hover sortable">
<thead>
<tr>
<th>&nbsp;</th>
<th>Source transaction</th>
<th>&nbsp;</th>
<th>Link description</th>
<th>Destination transaction</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{% for link in links %}
<tr>
<td>
<div class="btn-group btn-group-xs">
<a href="{{ route('transactions.link.delete', [link.id]) }}" class="btn btn-danger"><i class="fa fa-trash"></i></a>
<a href="{{ route('transactions.link.switch', [link.id]) }}" class="btn btn-default"><i class="fa fa-fw fa-arrows-h"></i></a>
</div>
</td>
<td data-value="{{ link.source.description }}">
<a href="{{ route('transactions.show', [link.source_id]) }}">{{ link.source.description }}</a>
</td>
<td>{{ journalAmount(link.source) }}</td>
<td>{{ linkType.outward }}</td>
<td data-value="{{ link.destination.description }}">
<a href="{{ route('transactions.show', [link.destination_id]) }}">{{ link.destination.description }}</a>
</td>
<td>
{{ journalAmount(link.destination) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script type="text/javascript" src="js/lib/bootstrap-sortable.js"></script>
{% endblock %}
{% block styles %}
<link rel="stylesheet" href="css/bootstrap-sortable.css" type="text/css" media="all"/>
{% endblock %}

View File

@ -138,7 +138,7 @@
<!-- options and preferences --> <!-- options and preferences -->
<li id="option-menu" <li id="option-menu"
class="{{ activeRoutePartial('admin') }} {{ activeRoutePartial('profile') }} {{ activeRoutePartial('preferences') }} {{ activeRoutePartial('currency') }} treeview"> class="{{ activeRoutePartial('admin') }} {{ activeRoutePartial('profile') }} {{ activeRoutePartial('preferences') }} {{ activeRoutePartial('currencies') }} treeview">
<a href="#"> <a href="#">
<i class="fa fa-gears fa-fw"></i> <i class="fa fa-gears fa-fw"></i>
<span>{{ 'options'|_ }}</span> <span>{{ 'options'|_ }}</span>
@ -158,8 +158,8 @@
<a class="{{ activeRouteStrict('preferences.index') }}" href="{{ route('preferences.index') }}"><i <a class="{{ activeRouteStrict('preferences.index') }}" href="{{ route('preferences.index') }}"><i
class="fa fa-gear fa-fw"></i> {{ 'preferences'|_ }}</a> class="fa fa-gear fa-fw"></i> {{ 'preferences'|_ }}</a>
</li> </li>
<li class="{{ activeRoutePartial('currency') }}"> <li class="{{ activeRoutePartial('currencies') }}">
<a class="{{ activeRoutePartial('currency') }}" href="{{ route('currencies.index') }}"><i class="fa fa-usd fa-fw"></i> {{ 'currencies'|_ }}</a> <a class="{{ activeRoutePartial('currencies') }}" href="{{ route('currencies.index') }}"><i class="fa fa-usd fa-fw"></i> {{ 'currencies'|_ }}</a>
</li> </li>
<!-- admin (if user admin) --> <!-- admin (if user admin) -->
{% if Auth.user.hasRole('owner') %} {% if Auth.user.hasRole('owner') %}

View File

@ -12,7 +12,7 @@
<div class="col-lg-6 col-lg-offset-3 col-md-6 col-sm-12"> <div class="col-lg-6 col-lg-offset-3 col-md-6 col-sm-12">
<div class="box box-danger"> <div class="box box-danger">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Delete tag "{{ tag.tag }}"</h3> <h3 class="box-title">{{ trans('firefly.delete_tag',{tag: tag.tag}) }}</h3>
</div> </div>
<div class="box-body"> <div class="box-body">
<p class="text-danger"> <p class="text-danger">

View File

@ -0,0 +1,33 @@
{% extends "./layout/default" %}
{% block breadcrumbs %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, link) }}
{% endblock %}
{% block content %}
<form method="POST" action="{{ route('transactions.link.destroy', [link.id]) }}" accept-charset="UTF-8" class="form-horizontal" id="destroy">
<input name="_token" type="hidden" value="{{ csrf_token() }}">
<div class="row">
<div class="col-lg-6 col-lg-offset-3 col-md-6 col-sm-12">
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('firefly.delete_journal_link', {source: link.source.description, destination: link.destination.description, source_link: route('transactions.show', [link.source_id]) , destination_link: route('transactions.show',link.destination_id)})|raw }}</h3>
</div>
<div class="box-body">
<p class="text-danger">
{{ trans('form.permDeleteWarning') }}
</p>
<p>
{{ trans('form.journal_link_areYouSure', {source: link.source.description, destination: link.destination.description, source_link: route('transactions.show', [link.source_id]) , destination_link: route('transactions.show',link.destination_id)})|raw }}
</p>
</div>
<div class="box-footer">
<input type="submit" name="submit" value="{{ trans('form.deletePermanently') }}" class="btn pull-right btn-danger"/>
<a href="{{ URL.previous() }}" class="btn-default btn">{{ trans('form.cancel') }}</a>
</div>
</div>
</div>
</div>
</form>
{% endblock %}

View File

@ -322,21 +322,22 @@
<tr> <tr>
<td> <td>
<div class="btn-group btn-group-xs"> <div class="btn-group btn-group-xs">
<a href="{{ route('attachments.delete', att.id) }}" class="btn btn-danger"><i class="fa fa-trash"></i></a> <a href="{{ route('transactions.link.delete', [link.id]) }}" class="btn btn-danger"><i class="fa fa-trash"></i></a>
<a href="{{ route('transactions.link.switch', [link.id]) }}" class="btn btn-default"><i class="fa fa-fw fa-arrows-h"></i></a>
</div> </div>
</td> </td>
<td> <td>
{{ ('this_'~(what|lower))|_ }} {{ ('this_'~(what|lower))|_ }}
(<a href="{{ route('transactions.show',journal.id) }}">#{{ journal.id }}</a>)
{% if link.source.id == journal.id %} {% if link.source.id == journal.id %}
{{ link.linkType.outward }} {{ link.linkType.outward }}
<a href="{{ route('transactions.show',link.destination.id) }}">#{{ link.destination.id }}</a>: <a href="{{ route('transactions.show',link.destination.id) }}">
<a href="{{ route('transactions.show',link.destination.id) }}">{{ link.destination.description }}</a> #{{ link.destination.id }}: {{ link.destination.description }}
</a>
({{ journalAmount(link.destination) }}) ({{ journalAmount(link.destination) }})
{% else %} {% else %}
{{ link.linkType.inward }} {{ link.linkType.inward }}
<a href="{{ route('transactions.show',link.source.id) }}">#{{ link.source.id }}</a>: <a href="{{ route('transactions.show',link.source.id) }}">
<a href="{{ route('transactions.show',link.source.id) }}">{{ link.source.description }}</a> #{{ link.source.id }}: {{ link.source.description }}</a>
({{ journalAmount(link.source) }}) ({{ journalAmount(link.source) }})
{% endif %} {% endif %}
{% if link.comment != "" %} {% if link.comment != "" %}
@ -364,20 +365,20 @@
<table class="table table-bordered table-striped"> <table class="table table-bordered table-striped">
<thead> <thead>
<tr> <tr>
<th>{{ trans('list.description') }}</th> <th class="hidden-md hidden-sm hidden-xs">{{ trans('list.description') }}</th>
<th>{{ trans('list.source_account') }}</th> <th>{{ trans('list.source_account') }}</th>
<th>&#916;</th> <th class="hidden-sm hidden-xs">&#916;</th>
<th>{{ trans('list.destination_account') }}</th> <th>{{ trans('list.destination_account') }}</th>
<th>&#916;</th> <th class="hidden-sm hidden-xs">&#916;</th>
<th>{{ trans('list.amount') }}</th> <th>{{ trans('list.amount') }}</th>
<th>{{ trans('list.budget') }}</th> <th class="hidden-md hidden-xs">{{ trans('list.budget') }}</th>
<th>{{ trans('list.category') }}</th> <th class="hidden-md hidden-xs">{{ trans('list.category') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for transaction in transactions %} {% for transaction in transactions %}
<tr> <tr>
<td> <td class="hidden-md hidden-sm hidden-xs">
{% if transaction.description == "" %} {% if transaction.description == "" %}
{{ journal.description }} {{ journal.description }}
{% else %} {% else %}
@ -392,7 +393,7 @@
{% endif %} {% endif %}
</td> </td>
<td> <td class="hidden-sm hidden-xs">
{{ formatSourceBefore(transaction) }} &rarr; {{ formatSourceAfter(transaction) }} {{ formatSourceBefore(transaction) }} &rarr; {{ formatSourceAfter(transaction) }}
</td> </td>
<td> <td>
@ -403,16 +404,27 @@
{% endif %} {% endif %}
</td> </td>
<td> <td class="hidden-sm hidden-xs">
{{ formatDestinationBefore(transaction) }} &rarr; {{ formatDestinationAfter(transaction) }} {{ formatDestinationBefore(transaction) }} &rarr; {{ formatDestinationAfter(transaction) }}
</td> </td>
<td> <td>
{{ journalAmount(journal) }} {% if journal.transactionType.type == "Withdrawal" %}
{{ formatAmountBySymbol(transaction.source_amount, transaction.transaction_currency_symbol, transaction.transaction_currency_dp, true) }}
{% if(transaction.foreign_source_amount) %}
({{ formatAmountBySymbol(transaction.foreign_source_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_dp, true) }})
{% endif %}
{% else %}
{{ formatAmountBySymbol(transaction.destination_amount, transaction.transaction_currency_symbol,2) }}
{% if(transaction.foreign_source_amount) %}
({{ formatAmountBySymbol(transaction.foreign_destination_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_dp, true) }})
{% endif %}
{% endif %}
</td> </td>
<td> <td class="hidden-md hidden-xs">
{{ transactionIdBudgets(transaction.source_id) }} {{ transactionIdBudgets(transaction.source_id) }}
</td> </td>
<td> <td class="hidden-md hidden-xs">
{{ transactionIdCategories(transaction.source_id) }} {{ transactionIdCategories(transaction.source_id) }}
</td> </td>
</tr> </tr>

View File

@ -740,6 +740,11 @@ Route::group(
Route::group( Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'Transaction', 'prefix' => 'transactions/link', 'as' => 'transactions.link.'], function () { ['middleware' => 'user-full-auth', 'namespace' => 'Transaction', 'prefix' => 'transactions/link', 'as' => 'transactions.link.'], function () {
Route::post('store/{tj}', ['uses' => 'LinkController@store', 'as' => 'store']); Route::post('store/{tj}', ['uses' => 'LinkController@store', 'as' => 'store']);
Route::get('delete/{journalLink}', ['uses' => 'LinkController@delete', 'as' => 'delete']);
Route::get('switch/{journalLink}', ['uses' => 'LinkController@switch', 'as' => 'switch']);
Route::post('destroy/{journalLink}', ['uses' => 'LinkController@destroy', 'as' => 'destroy']);
} }
); );
@ -771,6 +776,7 @@ Route::group(
// journal links manager // journal links manager
Route::get('links', ['uses' => 'LinkController@index', 'as' => 'links.index']); Route::get('links', ['uses' => 'LinkController@index', 'as' => 'links.index']);
Route::get('links/create', ['uses' => 'LinkController@create', 'as' => 'links.create']); Route::get('links/create', ['uses' => 'LinkController@create', 'as' => 'links.create']);
Route::get('links/show/{linkType}', ['uses' => 'LinkController@show', 'as' => 'links.show']);
Route::get('links/edit/{linkType}', ['uses' => 'LinkController@edit', 'as' => 'links.edit']); Route::get('links/edit/{linkType}', ['uses' => 'LinkController@edit', 'as' => 'links.edit']);
Route::get('links/delete/{linkType}', ['uses' => 'LinkController@delete', 'as' => 'links.delete']); Route::get('links/delete/{linkType}', ['uses' => 'LinkController@delete', 'as' => 'links.delete']);