Translations.

This commit is contained in:
James Cole
2016-10-29 17:30:55 +02:00
parent e9c2446cba
commit c9f14da294
4 changed files with 126 additions and 42 deletions

View File

@@ -64,30 +64,35 @@ class ConvertController extends Controller
$positiveAmount = TransactionJournal::amountPositive($journal); $positiveAmount = TransactionJournal::amountPositive($journal);
$assetAccounts = ExpandedForm::makeSelectList($this->accounts->getActiveAccountsByType([AccountType::DEFAULT, AccountType::ASSET])); $assetAccounts = ExpandedForm::makeSelectList($this->accounts->getActiveAccountsByType([AccountType::DEFAULT, AccountType::ASSET]));
$sourceType = $journal->transactionType; $sourceType = $journal->transactionType;
$subTitle = trans('firefly.convert_to_' . $destinationType->type, ['description' => $journal->description]);
$subTitleIcon = 'fa-exchange';
$subTitle = trans('firefly.convert_to_' . $destinationType->type, ['description' => $journal->description]); // cannot convert to its own type.
$subTitleIcon = 'fa-exchange';
if ($sourceType->type === $destinationType->type) { if ($sourceType->type === $destinationType->type) {
Session::flash('info', trans('firefly.convert_is_already_type_' . $destinationType->type)); Session::flash('info', trans('firefly.convert_is_already_type_' . $destinationType->type));
return redirect(route('transactions.show', [$journal->id])); return redirect(route('transactions.show', [$journal->id]));
} }
// cannot convert split.
if ($journal->transactions()->count() > 2) { if ($journal->transactions()->count() > 2) {
Session::flash('error', trans('firefly.cannot_convert_split_journl')); Session::flash('error', trans('firefly.cannot_convert_split_journl'));
return redirect(route('transactions.show', [$journal->id])); return redirect(route('transactions.show', [$journal->id]));
} }
// get source and destination account:
$sourceAccount = TransactionJournal::sourceAccountList($journal)->first(); $sourceAccount = TransactionJournal::sourceAccountList($journal)->first();
$destinationAccount = TransactionJournal::destinationAccountList($journal)->first(); $destinationAccount = TransactionJournal::destinationAccountList($journal)->first();
return view( return view(
'transactions.convert', compact( 'transactions.convert',
'sourceType', 'destinationType', 'journal', 'assetAccounts', compact(
'positiveAmount', 'sourceAccount', 'destinationAccount', 'sourceType', 'sourceType', 'destinationType', 'journal', 'assetAccounts',
'subTitle', 'subTitleIcon' 'positiveAmount', 'sourceAccount', 'destinationAccount', 'sourceType',
'subTitle', 'subTitleIcon'
) )
); );
@@ -95,8 +100,35 @@ class ConvertController extends Controller
// or to transfer requires // or to transfer requires
} }
public function submit(Request $request) /**
* @param Request $request
* @param TransactionType $destinationType
* @param TransactionJournal $journal
*/
public function submit(Request $request, TransactionType $destinationType, TransactionJournal $journal)
{ {
$sourceType = $journal->transactionType;
// cannot convert to its own type.
if ($sourceType->type === $destinationType->type) {
Session::flash('info', trans('firefly.convert_is_already_type_' . $destinationType->type));
return redirect(route('transactions.show', [$journal->id]));
}
// cannot convert split.
if ($journal->transactions()->count() > 2) {
Session::flash('error', trans('firefly.cannot_convert_split_journl'));
return redirect(route('transactions.show', [$journal->id]));
}
// try the conversion with the given data:
echo '<pre>'; echo '<pre>';
var_dump($request->all()); var_dump($request->all());

View File

@@ -366,8 +366,23 @@ return [
'convert_options_DepositWithdrawal' => 'Convert a deposit into a withdrawal', 'convert_options_DepositWithdrawal' => 'Convert a deposit into a withdrawal',
'convert_options_TransferWithdrawal' => 'Convert a transfer into a withdrawal', 'convert_options_TransferWithdrawal' => 'Convert a transfer into a withdrawal',
'convert_options_TransferDeposit' => 'Convert a transfer into a deposit', 'convert_options_TransferDeposit' => 'Convert a transfer into a deposit',
'transaction_journal_convert_options' => 'Convert this transaction',
'convert_Withdrawal_to_deposit' => 'Convert this withdrawal to a deposit',
'convert_Withdrawal_to_transfer' => 'Convert this withdrawal to a transfer',
'convert_Deposit_to_withdrawal' => 'Convert this deposit to a withdrawal',
'convert_Deposit_to_transfer' => 'Convert this deposit to a transfer',
'convert_Transfer_to_deposit' => 'Convert this transfer to a deposit',
'convert_Transfer_to_withdrawal' => 'Convert this transfer to a withdrawal',
'convert_please_set_revenue_source' => 'Please pick the revenue account where the money will come from.',
'convert_please_set_asset_destination' => 'Please pick the asset account where the money will go to.',
'convert_please_set_expense_destination' => 'Please pick the expense account where the money will go to.',
'convert_please_set_asset_source' => 'Please pick the asset account where the money will come from.',
'convert_explanation_withdrawal_deposit' => 'If you convert this withdrawal into a deposit, :amount will be deposited into <a href=":sourceRoute">:sourceName</a> instead of taken from it.',
'convert_explanation_withdrawal_transfer' => 'If you convert this withdrawal into a transfer, :amount will be transferred from <a href=":sourceRoute">:sourceName</a> to a new asset account, instead of being paid to <a href=":destinationRoute">:destinationName</a>.',
'convert_explanation_deposit_withdrawal' => 'If you convert this deposit into a withdrawal, :amount will be removed from <a href=":destinationRoute">:destinationName</a> instead of added to it.',
'convert_explanation_deposit_transfer' => 'If you convert this deposit into a transfer, :amount will be transferred from an asset account of your choice into <a href=":destinationRoute">:destinationName</a>.',
'convert_explanation_transfer_withdrawal' => 'If you convert this transfer into a withdrawal, :amount will go from <a href=":sourceRoute">:sourceName</a> to a new destination as an expense, instead of to <a href=":destinationRoute">:destinationName</a> as a transfer.',
'convert_explanation_transfer_deposit' => 'If you convert this transfer into a deposit, :amount will be deposited into account <a href=":destinationRoute">:destinationName</a> instead of being transferred there.',
// create new stuff: // create new stuff:
'create_new_withdrawal' => 'Create new withdrawal', 'create_new_withdrawal' => 'Create new withdrawal',
'create_new_deposit' => 'Create new deposit', 'create_new_deposit' => 'Create new deposit',

View File

@@ -40,13 +40,19 @@
{# ONE #} {# ONE #}
{% if sourceType.type == 'Withdrawal' and destinationType.type == 'Deposit' %} {% if sourceType.type == 'Withdrawal' and destinationType.type == 'Deposit' %}
<p><em> <p><em>
If you convert this withdrawal into a deposit, {{ positiveAmount|formatAmount }} {{ trans('firefly.convert_explanation_withdrawal_deposit',
will be deposited into <a href="{{ route('accounts.show',[sourceAccount.id]) }}">{{ sourceAccount.name }}</a> {
instead of taken from it. amount: positiveAmount|formatAmount,
sourceRoute: route('accounts.show', [sourceAccount.id]),
sourceName: sourceAccount.name,
destinationRoute: route('accounts.show', [destinationAccount.id]),
destinationName: destinationAccount.name,
})|raw
}}
</em> </em>
</p> </p>
<p><em> <p><em>
Please pick the revenue account where the money will come from. {{ 'convert_please_set_revenue_source'|_ }}
</em> </em>
</p> </p>
@@ -56,15 +62,21 @@
{# TWO #} {# TWO #}
{% if sourceType.type == 'Withdrawal' and destinationType.type == 'Transfer' %} {% if sourceType.type == 'Withdrawal' and destinationType.type == 'Transfer' %}
<p><em> <p><em>
If you convert this withdrawal into a transfer, {{ positiveAmount|formatAmount }} {{ trans('firefly.convert_explanation_withdrawal_transfer',
will be transferred from <a href="{{ route('accounts.show',[sourceAccount.id]) }}">{{ sourceAccount.name }}</a> {
to a new asset account, instead of being paid to amount: positiveAmount|formatAmount,
<a href="{{ route('accounts.show',[destinationAccount.id]) }}">{{ destinationAccount.name }}</a>. sourceRoute: route('accounts.show', [sourceAccount.id]),
sourceName: sourceAccount.name,
destinationRoute: route('accounts.show', [destinationAccount.id]),
destinationName: destinationAccount.name,
})|raw
}}
</em></p> </em></p>
<p> <p>
<em> <em>
Please pick the asset account where the money will go to. {{ 'convert_please_set_asset_destination'|_ }}
</em> </em>
</p> </p>
{{ ExpandedForm.select('destination_account_asset', assetAccounts) }} {{ ExpandedForm.select('destination_account_asset', assetAccounts) }}
@@ -76,14 +88,21 @@
{% if sourceType.type == 'Deposit' and destinationType.type == 'Withdrawal' %} {% if sourceType.type == 'Deposit' and destinationType.type == 'Withdrawal' %}
<p> <p>
<em> <em>
If you convert this deposit into a withdrawal, {{ positiveAmount|formatAmount }} {{ trans('firefly.convert_explanation_deposit_withdrawal',
will be removed from <a href="{{ route('accounts.show',[destinationAccount.id]) }}">{{ destinationAccount.name }}</a> {
instead of added to it. amount: positiveAmount|formatAmount,
sourceRoute: route('accounts.show', [sourceAccount.id]),
sourceName: sourceAccount.name,
destinationRoute: route('accounts.show', [destinationAccount.id]),
destinationName: destinationAccount.name,
})|raw
}}
</em> </em>
</p> </p>
<p> <p>
<em> <em>
Please pick the expense account where the money will go to. {{ 'convert_please_set_expense_destination'|_ }}
</em> </em>
</p> </p>
{{ ExpandedForm.text('destination_account_expense', destinationAccount.name) }} {{ ExpandedForm.text('destination_account_expense', destinationAccount.name) }}
@@ -95,14 +114,21 @@
<p> <p>
<em> <em>
If you convert this deposit into a transfer, {{ positiveAmount|formatAmount }} will be transferred {{ trans('firefly.convert_explanation_deposit_transfer',
from an asset account of your choice into {
<a href="{{ route('accounts.show',[destinationAccount.id]) }}">{{ destinationAccount.name }}</a>. amount: positiveAmount|formatAmount,
sourceRoute: route('accounts.show', [sourceAccount.id]),
sourceName: sourceAccount.name,
destinationRoute: route('accounts.show', [destinationAccount.id]),
destinationName: destinationAccount.name,
})|raw
}}
</em> </em>
</p> </p>
<p> <p>
<em> <em>
Please pick the asset account where the money will come from. {{ 'convert_please_set_asset_source'|_ }}
</em> </em>
</p> </p>
@@ -114,17 +140,21 @@
<p> <p>
<em> <em>
If you convert this transfer into a withdrawal, {{ positiveAmount|formatAmount }} {{ trans('firefly.convert_explanation_transfer_withdrawal',
will go from <a href="{{ route('accounts.show',[sourceAccount.id]) }}">{{ sourceAccount.name }}</a> {
to a new destination as an expense, instead of to amount: positiveAmount|formatAmount,
<a href="{{ route('accounts.show',[destinationAccount.id]) }}">{{ destinationAccount.name }}</a> sourceRoute: route('accounts.show', [sourceAccount.id]),
as a transfer. sourceName: sourceAccount.name,
destinationRoute: route('accounts.show', [destinationAccount.id]),
destinationName: destinationAccount.name,
})|raw
}}
</em> </em>
</p> </p>
<p> <p>
<em> <em>
Please pick the expense account where the money will go to. {{ 'convert_please_set_expense_destination'|_ }}
</em> </em>
</p> </p>
@@ -135,17 +165,24 @@
{# SIX #} {# SIX #}
{% if sourceType.type == 'Transfer' and destinationType.type == 'Deposit' %} {% if sourceType.type == 'Transfer' and destinationType.type == 'Deposit' %}
<p> <p>
<em> <em>
If you convert this transfer into a deposit, {{ positiveAmount|formatAmount }} {{ trans('firefly.convert_explanation_transfer_deposit',
will be deposited into account <a href="{{ route('accounts.show',[destinationAccount.id]) }}">{{ destinationAccount.name }}</a> {
instead of being transferred there. amount: positiveAmount|formatAmount,
sourceRoute: route('accounts.show', [sourceAccount.id]),
sourceName: sourceAccount.name,
destinationRoute: route('accounts.show', [destinationAccount.id]),
destinationName: destinationAccount.name,
})|raw
}}
</em> </em>
</p> </p>
<p> <p>
<em> <em>
Please pick the revenue account where the money will come from. {{ 'convert_please_set_revenue_source'|_ }}
</em> </em>
</p> </p>

View File

@@ -218,7 +218,7 @@
<p> <p>
<i class="fa fa-exchange" aria-hidden="true"></i> <i class="fa fa-exchange" aria-hidden="true"></i>
<a href="{{ route('transactions.convert', ['withdrawal', journal.id]) }}"> <a href="{{ route('transactions.convert', ['withdrawal', journal.id]) }}">
Convert this {{ journal.transactionType.type }} to a withdrawal. {{ ('convert_'~journal.transactionType.type~'_to_withdrawal')|_ }}
</a> </a>
</p> </p>
{% endif %} {% endif %}
@@ -226,7 +226,7 @@
<p> <p>
<i class="fa fa-exchange" aria-hidden="true"></i> <i class="fa fa-exchange" aria-hidden="true"></i>
<a href="{{ route('transactions.convert', ['deposit', journal.id]) }}"> <a href="{{ route('transactions.convert', ['deposit', journal.id]) }}">
Convert this {{ journal.transactionType.type }} to a deposit. {{ ('convert_'~journal.transactionType.type~'_to_deposit')|_ }}
</a> </a>
</p> </p>
{% endif %} {% endif %}
@@ -235,7 +235,7 @@
<p> <p>
<i class="fa fa-exchange" aria-hidden="true"></i> <i class="fa fa-exchange" aria-hidden="true"></i>
<a href="{{ route('transactions.convert', ['transfer', journal.id]) }}"> <a href="{{ route('transactions.convert', ['transfer', journal.id]) }}">
Convert this {{ journal.transactionType.type }} to a transfer. {{ ('convert_'~journal.transactionType.type~'_to_transfer')|_ }}
</a> </a>
</p> </p>
{% endif %} {% endif %}
@@ -251,7 +251,7 @@
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Transactions</h3> <h3 class="box-title">{{ 'transactions'|_ }}</h3>
</div> </div>
<table class="table table-bordered table-striped"> <table class="table table-bordered table-striped">
<thead> <thead>