Tax type compound just add once.
This commit is contained in:
parent
1411bd879c
commit
654f7bbb2c
@ -43,7 +43,13 @@ class Taxes extends Controller
|
|||||||
|
|
||||||
$rand = rand();
|
$rand = rand();
|
||||||
|
|
||||||
$html = view('modals.taxes.create', compact('types', 'tax_selector', 'rand'))->render();
|
$disable_options = [];
|
||||||
|
|
||||||
|
if ($compound = Tax::compound()->first()) {
|
||||||
|
$disable_options = ['compound'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$html = view('modals.taxes.create', compact('types', 'tax_selector', 'disable_options', 'rand'))->render();
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
|
@ -57,7 +57,13 @@ class Taxes extends Controller
|
|||||||
'compound' => trans('taxes.compound'),
|
'compound' => trans('taxes.compound'),
|
||||||
];
|
];
|
||||||
|
|
||||||
return view('settings.taxes.create', compact('types'));
|
$disable_options = [];
|
||||||
|
|
||||||
|
if ($compound = Tax::compound()->first()) {
|
||||||
|
$disable_options = ['compound'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('settings.taxes.create', compact('types', 'disable_options'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,7 +111,13 @@ class Taxes extends Controller
|
|||||||
'compound' => trans('taxes.compound'),
|
'compound' => trans('taxes.compound'),
|
||||||
];
|
];
|
||||||
|
|
||||||
return view('settings.taxes.edit', compact('tax', 'types'));
|
$disable_options = [];
|
||||||
|
|
||||||
|
if ($tax->type != 'compound' && $compound = Tax::compound()->first()) {
|
||||||
|
$disable_options = ['compound'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('settings.taxes.edit', compact('tax', 'types', 'disable_options'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,10 +23,25 @@ class Tax extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
// Check if store or update
|
||||||
|
if ($this->getMethod() == 'PATCH') {
|
||||||
|
$id = is_numeric($this->tax) ? $this->tax : $this->tax->getAttribute('id');
|
||||||
|
} else {
|
||||||
|
$id = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$company_id = $this->request->get('company_id');
|
||||||
|
|
||||||
|
$type = 'required|string';
|
||||||
|
|
||||||
|
if (!empty($this->request->get('type')) && $this->request->get('type') == 'compound') {
|
||||||
|
$type .= '|unique:taxes,NULL,' . $id . ',id,company_id,' . $company_id . ',type,compound,deleted_at,NULL';
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => 'required|string',
|
'name' => 'required|string',
|
||||||
'rate' => 'required|min:0|max:100',
|
'rate' => 'required|min:0|max:100',
|
||||||
'type' => 'required|string',
|
'type' => $type,
|
||||||
'enabled' => 'integer|boolean',
|
'enabled' => 'integer|boolean',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
5
public/css/custom.css
vendored
5
public/css/custom.css
vendored
@ -934,3 +934,8 @@ table .align-items-center td span.badge {
|
|||||||
border: none;
|
border: none;
|
||||||
color: #8898aa;
|
color: #8898aa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.el-select-dropdown__item.is-disabled {
|
||||||
|
color: #C0C4CC !important;
|
||||||
|
cursor: not-allowed !important;
|
||||||
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
{{ Form::textGroup('rate', trans('taxes.rate'), 'percent', ['@input' => 'onChangeTaxRate']) }}
|
{{ Form::textGroup('rate', trans('taxes.rate'), 'percent', ['@input' => 'onChangeTaxRate']) }}
|
||||||
|
|
||||||
{{ Form::selectGroup('type', trans_choice('general.types', 1), 'bars', $types, 'normal') }}
|
{{ Form::selectGroup('type', trans_choice('general.types', 1), 'bars', $types, 'normal', ['disabledOptions' => $disable_options]) }}
|
||||||
|
|
||||||
{{ Form::radioGroup('enabled', trans('general.enabled'), true) }}
|
{{ Form::radioGroup('enabled', trans('general.enabled'), true) }}
|
||||||
</div>
|
</div>
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
{{ Form::textGroup('rate', trans('taxes.rate'), 'percent', ['@input' => 'onChangeTaxRate']) }}
|
{{ Form::textGroup('rate', trans('taxes.rate'), 'percent', ['@input' => 'onChangeTaxRate']) }}
|
||||||
|
|
||||||
{{ Form::selectGroup('type', trans_choice('general.types', 1), 'bars', $types, $tax->type) }}
|
{{ Form::selectGroup('type', trans_choice('general.types', 1), 'bars', $types, $tax->type, ['disabledOptions' => $disable_options]) }}
|
||||||
|
|
||||||
{{ Form::radioGroup('enabled', trans('general.enabled'), $tax->enabled) }}
|
{{ Form::radioGroup('enabled', trans('general.enabled'), $tax->enabled) }}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user