mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
Minor fixes
This commit is contained in:
@ -8,7 +8,7 @@ use Crater\Models\CompanySetting;
|
||||
use Crater\Models\Currency;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CompanyCurrencyTransactionController extends Controller
|
||||
class CompanyCurrencyCheckTransactionsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
@ -24,15 +24,7 @@ class CompanyCurrencyTransactionController extends Controller
|
||||
|
||||
$currency = Currency::find((int)$companyCurrency);
|
||||
|
||||
if (
|
||||
$currency->customers()->exists() ||
|
||||
$currency->items()->exists() ||
|
||||
$currency->invoices()->exists() ||
|
||||
$currency->estimates()->exists() ||
|
||||
$currency->expenses()->exists() ||
|
||||
$currency->payments()->exists() ||
|
||||
$currency->recurringInvoices()->exists()
|
||||
) {
|
||||
if ($currency->checkTransactions()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
]);
|
||||
@ -6,6 +6,7 @@ use Crater\Http\Controllers\Controller;
|
||||
use Crater\Http\Requests\UpdateSettingsRequest;
|
||||
use Crater\Models\Company;
|
||||
use Crater\Models\CompanySetting;
|
||||
use Crater\Models\Currency;
|
||||
|
||||
class UpdateCompanySettingsController extends Controller
|
||||
{
|
||||
@ -19,7 +20,19 @@ class UpdateCompanySettingsController extends Controller
|
||||
{
|
||||
$this->authorize('manage company', Company::find($request->header('company')));
|
||||
|
||||
CompanySetting::setSettings($request->settings, $request->header('company'));
|
||||
$companyCurrency = CompanySetting::getSetting('currency', $request->header('company'));
|
||||
|
||||
$data = $request->settings;
|
||||
$currency = Currency::find((int)$companyCurrency);
|
||||
|
||||
if ($companyCurrency !== $data['currency'] && $currency->checkTransactions()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'You cannot change currency once transaction is created.'
|
||||
]);
|
||||
}
|
||||
|
||||
CompanySetting::setSettings($data, $request->header('company'));
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
|
||||
Reference in New Issue
Block a user