revenues import/export

This commit is contained in:
denisdulici
2020-01-20 23:50:19 +03:00
parent b119deca9f
commit a3372aeb63
10 changed files with 163 additions and 123 deletions

View File

@ -5,8 +5,6 @@ namespace App\Imports\Common;
use App\Abstracts\Import;
use App\Http\Requests\Common\Item as Request;
use App\Models\Common\Item as Model;
use App\Models\Setting\Category;
use App\Models\Setting\Tax;
class Items extends Import
{
@ -20,25 +18,11 @@ class Items extends Import
$row = parent::map($row);
if (empty($row['category_id']) && !empty($row['category_name'])) {
$row['category_id'] = Category::firstOrCreate([
'name' => $row['category_name'],
], [
'company_id' => session('company_id'),
'type' => 'income',
'color' => '#' . dechex(rand(0x000000, 0xFFFFFF)),
'enabled' => 1,
])->id;
$row['category_id'] = $this->getCategoryIdFromName($row, 'item');
}
if (empty($row['tax_id']) && !empty($row['tax_rate'])) {
$row['tax_id'] = Tax::firstOrCreate([
'rate' => $row['tax_rate'],
], [
'company_id' => session('company_id'),
'type' => 'normal',
'name' => $row['tax_rate'],
'enabled' => 1,
])->id;
$row['tax_id'] = $this->getTaxIdFromRate($row);
}
return $row;