mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
Fix currency settings error (#821)
* Fixed issue with currency error on change after transactions * organized imports
This commit is contained in:
@ -6,6 +6,7 @@ use Crater\Http\Controllers\Controller;
|
||||
use Crater\Http\Requests\UpdateSettingsRequest;
|
||||
use Crater\Models\Company;
|
||||
use Crater\Models\CompanySetting;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class UpdateCompanySettingsController extends Controller
|
||||
{
|
||||
@ -20,10 +21,13 @@ class UpdateCompanySettingsController extends Controller
|
||||
$company = Company::find($request->header('company'));
|
||||
$this->authorize('manage company', $company);
|
||||
|
||||
$companyCurrency = CompanySetting::getSetting('currency', $request->header('company'));
|
||||
$data = $request->settings;
|
||||
|
||||
if ($companyCurrency !== $data['currency'] && $company->hasTransactions()) {
|
||||
if (
|
||||
Arr::exists($data, 'currency') &&
|
||||
(CompanySetting::getSetting('currency', $company->id) !== $data['currency']) &&
|
||||
$company->hasTransactions()
|
||||
) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Cannot update company currency after transactions are created.'
|
||||
|
||||
Reference in New Issue
Block a user