issue #736
This commit is contained in:
parent
179ac647d8
commit
0002f7caaa
|
|
@ -19,7 +19,7 @@ class TaxRateDataGrid extends DataGrid
|
|||
|
||||
public function prepareQueryBuilder()
|
||||
{
|
||||
$queryBuilder = DB::table('tax_rates')->addSelect('id', 'identifier', 'state', 'country', 'tax_rate');
|
||||
$queryBuilder = DB::table('tax_rates')->addSelect('id', 'identifier', 'state', 'country', 'zip_code', 'zip_from', 'zip_to', 'tax_rate');
|
||||
|
||||
$this->setQueryBuilder($queryBuilder);
|
||||
}
|
||||
|
|
@ -62,6 +62,33 @@ class TaxRateDataGrid extends DataGrid
|
|||
'filterable' => true
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'zip_code',
|
||||
'label' => trans('admin::app.configuration.tax-rates.zip_code'),
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => true
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'zip_from',
|
||||
'label' => trans('admin::app.configuration.tax-rates.zip_from'),
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => true
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'zip_to',
|
||||
'label' => trans('admin::app.configuration.tax-rates.zip_to'),
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => true
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'tax_rate',
|
||||
'label' => trans('admin::app.datagrid.tax-rate'),
|
||||
|
|
|
|||
|
|
@ -189,11 +189,20 @@ class TaxRateController extends Controller
|
|||
|
||||
foreach ($excelData as $data) {
|
||||
foreach ($data as $column => $uploadData) {
|
||||
|
||||
if (!is_null($uploadData['zip_from']) && !is_null($uploadData['zip_to'])) {
|
||||
$uploadData['is_zip'] = 1;
|
||||
}
|
||||
|
||||
$validator = Validator::make($uploadData, [
|
||||
'identifier' => 'required|string',
|
||||
'state' => 'required|string',
|
||||
'country' => 'required|string',
|
||||
'tax_rate' => 'required|numeric'
|
||||
'tax_rate' => 'required|numeric',
|
||||
'is_zip' => 'sometimes',
|
||||
'zip_code' => 'sometimes|required_without:is_zip',
|
||||
'zip_from' => 'nullable|required_with:is_zip',
|
||||
'zip_to' => 'nullable|required_with:is_zip,zip_from',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
|
@ -230,6 +239,12 @@ class TaxRateController extends Controller
|
|||
$errorMsg[$coulmn] = $fail->first('country');
|
||||
} else if ($fail->first('state')) {
|
||||
$errorMsg[$coulmn] = $fail->first('state');
|
||||
} else if ($fail->first('zip_code')) {
|
||||
$errorMsg[$coulmn] = $fail->first('zip_code');
|
||||
} else if ($fail->first('zip_from')) {
|
||||
$errorMsg[$coulmn] = $fail->first('zip_from');
|
||||
} else if ($fail->first('zip_to')) {
|
||||
$errorMsg[$coulmn] = $fail->first('zip_to');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -250,6 +265,11 @@ class TaxRateController extends Controller
|
|||
|
||||
foreach ($excelData as $data) {
|
||||
foreach ($data as $column => $uploadData) {
|
||||
if (!is_null($uploadData['zip_from']) && !is_null($uploadData['zip_to'])) {
|
||||
$uploadData['is_zip'] = 1;
|
||||
$uploadData['zip_code'] = NULL;
|
||||
}
|
||||
|
||||
if (isset($rateIdentifier)) {
|
||||
$id = array_search($uploadData['identifier'], $rateIdentifier);
|
||||
if ($id) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue