check account currency

This commit is contained in:
denisdulici 2018-11-29 13:10:52 +03:00
parent 9934ebda30
commit 8467209bde
3 changed files with 14 additions and 4 deletions

View File

@ -98,8 +98,15 @@ class Accounts extends Controller
*/
public function update(Account $account, Request $request)
{
// Check if we can disable it
if (!$request['enabled']) {
// Check if we can disable or change the code
if (!$request['enabled'] || ($account->currency_code != $request['currency_code'])) {
$relationships = $this->countRelationships($account, [
'invoice_payments' => 'invoices',
'revenues' => 'revenues',
'bill_payments' => 'bills',
'payments' => 'payments',
]);
if ($account->id == setting('general.default_account')) {
$relationships[] = strtolower(trans_choice('general.companies', 1));
}
@ -120,7 +127,7 @@ class Accounts extends Controller
return redirect('banking/accounts');
} else {
$message = trans('messages.warning.disabled', ['name' => $account->name, 'text' => implode(', ', $relationships)]);
$message = trans('messages.warning.disable_code', ['name' => $account->name, 'text' => implode(', ', $relationships)]);
flash($message)->warning();

View File

@ -162,7 +162,7 @@ class Currencies extends Controller
return redirect('settings/currencies');
} else {
$message = trans('messages.warning.disabled', ['name' => $currency->name, 'text' => implode(', ', $relationships)]);
$message = trans('messages.warning.disable_code', ['name' => $currency->name, 'text' => implode(', ', $relationships)]);
flash($message)->warning();

View File

@ -11,6 +11,7 @@ return [
'enabled' => ':type enabled!',
'disabled' => ':type disabled!',
],
'error' => [
'over_payment' => 'Error: Payment not added! The amount you entered passes the total: :amount',
'not_user_company' => 'Error: You are not allowed to manage this company!',
@ -21,9 +22,11 @@ return [
'import_column' => 'Error: :message Sheet name: :sheet. Line number: :line.',
'import_sheet' => 'Error: Sheet name is not valid. Please, check the sample file.',
],
'warning' => [
'deleted' => 'Warning: You are not allowed to delete <b>:name</b> because it has :text related.',
'disabled' => 'Warning: You are not allowed to disable <b>:name</b> because it has :text related.',
'disable_code' => 'Warning: You are not allowed to disable or change the currency of <b>:name</b> because it has :text related.',
],
];