Merge branch 'master' of github.com:akaunting/akaunting

This commit is contained in:
Cüneyt Şentürk 2021-01-18 11:24:08 +03:00
commit 9fe6d0df22
4 changed files with 39 additions and 3 deletions

View File

@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Common;
use App\Abstracts\Http\FormRequest;
class ItemTax extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'item_id' => 'required|integer',
'tax_id' => 'required|integer',
];
}
}

View File

@ -4,13 +4,17 @@ namespace App\Imports\Common\Sheets;
use App\Abstracts\Import; use App\Abstracts\Import;
use App\Http\Requests\Common\ItemTax as Request; use App\Http\Requests\Common\ItemTax as Request;
use App\Models\Common\Item;
use App\Models\Common\ItemTax as Model; use App\Models\Common\ItemTax as Model;
class ItemTaxes extends Import class ItemTaxes extends Import
{ {
public function model(array $row) public function model(array $row)
{ {
// @todo remove after laravel-excel 3.2 release
if ($row['item_name'] === $this->empty_field) {
return null;
}
return new Model($row); return new Model($row);
} }
@ -18,6 +22,7 @@ class ItemTaxes extends Import
{ {
$row = parent::map($row); $row = parent::map($row);
$row['item_id'] = $this->getItemIdFromName($row);
$row['tax_id'] = $this->getTaxId($row); $row['tax_id'] = $this->getTaxId($row);
return $row; return $row;

View File

@ -191,8 +191,8 @@ trait Import
'name' => $row['item_name'], 'name' => $row['item_name'],
], [ ], [
'company_id' => session('company_id'), 'company_id' => session('company_id'),
'sale_price' => !empty($row['sale_price']) ? $row['sale_price'] : $row['price'], 'sale_price' => !empty($row['sale_price']) ? $row['sale_price'] : (!empty($row['price']) ? $row['price'] : 0),
'purchase_price' => !empty($row['purchase_price']) ? $row['purchase_price'] : $row['price'], 'purchase_price' => !empty($row['purchase_price']) ? $row['purchase_price'] : (!empty($row['price']) ? $row['price'] : 0),
'enabled' => 1, 'enabled' => 1,
])->id; ])->id;
} }

Binary file not shown.