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

@@ -4,9 +4,7 @@ namespace App\Imports\Sales\Sheets;
use App\Abstracts\Import;
use App\Http\Requests\Sale\Invoice as Request;
use App\Models\Common\Contact;
use App\Models\Sale\Invoice as Model;
use App\Models\Setting\Category;
class Invoices extends Import
{
@@ -20,37 +18,15 @@ class Invoices extends Import
$row = parent::map($row);
if (empty($row['contact_id']) && !empty($row['contact_name'])) {
$row['contact_id'] = Contact::firstOrCreate([
'name' => $row['contact_name'],
], [
'company_id' => session('company_id'),
'type' => 'customer',
'currency_code' => setting('default.currency'),
'enabled' => 1,
])->id;
$row['contact_id'] = $this->getContactIdFromName($row, 'customer');
}
if (empty($row['contact_id']) && !empty($row['contact_email'])) {
$row['contact_id'] = Contact::firstOrCreate([
'email' => $row['contact_email'],
], [
'company_id' => session('company_id'),
'type' => 'customer',
'name' => $row['contact_email'],
'currency_code' => setting('default.currency'),
'enabled' => 1,
])->id;
$row['contact_id'] = $this->getContactIdFromEmail($row, 'customer');
}
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, 'income');
}
return $row;