diff --git a/app/Http/Controllers/Banking/Accounts.php b/app/Http/Controllers/Banking/Accounts.php
index 244001487..51765fe0c 100644
--- a/app/Http/Controllers/Banking/Accounts.php
+++ b/app/Http/Controllers/Banking/Accounts.php
@@ -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();
diff --git a/app/Http/Controllers/Settings/Currencies.php b/app/Http/Controllers/Settings/Currencies.php
index f7c51b70c..4620ff2f0 100644
--- a/app/Http/Controllers/Settings/Currencies.php
+++ b/app/Http/Controllers/Settings/Currencies.php
@@ -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();
diff --git a/resources/lang/en-GB/messages.php b/resources/lang/en-GB/messages.php
index 57f839c31..c7f588af4 100644
--- a/resources/lang/en-GB/messages.php
+++ b/resources/lang/en-GB/messages.php
@@ -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 :name because it has :text related.',
'disabled' => 'Warning: You are not allowed to disable :name because it has :text related.',
+ 'disable_code' => 'Warning: You are not allowed to disable or change the currency of :name because it has :text related.',
],
];