1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Support for vendor and vendor contact imports

This commit is contained in:
David Bomba 2022-09-01 16:09:25 +10:00
parent e1edac0da1
commit 0c8aaa6782
4 changed files with 84 additions and 10 deletions

View File

@ -33,6 +33,15 @@ class VendorMap
14 => 'vendor.state', 14 => 'vendor.state',
15 => 'vendor.postal_code', 15 => 'vendor.postal_code',
16 => 'vendor.country_id', 16 => 'vendor.country_id',
17 => 'contact.first_name',
18 => 'contact.last_name',
19 => 'contact.email',
20 => 'contact.phone',
21 => 'contact.custom_value1',
22 => 'contact.custom_value2',
23 => 'contact.custom_value3',
24 => 'contact.custom_value4',
]; ];
} }
@ -56,6 +65,14 @@ class VendorMap
14 => 'texts.state', 14 => 'texts.state',
15 => 'texts.postal_code', 15 => 'texts.postal_code',
16 => 'texts.country', 16 => 'texts.country',
17 => 'texts.first_name',
18 => 'texts.last_name',
19 => 'texts.email',
20 => 'texts.phone',
21 => 'texts.custom_value',
22 => 'texts.custom_value',
23 => 'texts.custom_value',
24 => 'texts.custom_value',
]; ];
} }
} }

View File

@ -16,12 +16,14 @@ use App\Factory\ExpenseFactory;
use App\Factory\InvoiceFactory; use App\Factory\InvoiceFactory;
use App\Factory\PaymentFactory; use App\Factory\PaymentFactory;
use App\Factory\ProductFactory; use App\Factory\ProductFactory;
use App\Factory\QuoteFactory;
use App\Factory\VendorFactory; use App\Factory\VendorFactory;
use App\Http\Requests\Client\StoreClientRequest; use App\Http\Requests\Client\StoreClientRequest;
use App\Http\Requests\Expense\StoreExpenseRequest; use App\Http\Requests\Expense\StoreExpenseRequest;
use App\Http\Requests\Invoice\StoreInvoiceRequest; use App\Http\Requests\Invoice\StoreInvoiceRequest;
use App\Http\Requests\Payment\StorePaymentRequest; use App\Http\Requests\Payment\StorePaymentRequest;
use App\Http\Requests\Product\StoreProductRequest; use App\Http\Requests\Product\StoreProductRequest;
use App\Http\Requests\Quote\StoreQuoteRequest;
use App\Http\Requests\Vendor\StoreVendorRequest; use App\Http\Requests\Vendor\StoreVendorRequest;
use App\Import\ImportException; use App\Import\ImportException;
use App\Import\Providers\BaseImport; use App\Import\Providers\BaseImport;
@ -31,12 +33,14 @@ use App\Import\Transformer\Csv\ExpenseTransformer;
use App\Import\Transformer\Csv\InvoiceTransformer; use App\Import\Transformer\Csv\InvoiceTransformer;
use App\Import\Transformer\Csv\PaymentTransformer; use App\Import\Transformer\Csv\PaymentTransformer;
use App\Import\Transformer\Csv\ProductTransformer; use App\Import\Transformer\Csv\ProductTransformer;
use App\Import\Transformer\Csv\QuoteTransformer;
use App\Import\Transformer\Csv\VendorTransformer; use App\Import\Transformer\Csv\VendorTransformer;
use App\Repositories\ClientRepository; use App\Repositories\ClientRepository;
use App\Repositories\ExpenseRepository; use App\Repositories\ExpenseRepository;
use App\Repositories\InvoiceRepository; use App\Repositories\InvoiceRepository;
use App\Repositories\PaymentRepository; use App\Repositories\PaymentRepository;
use App\Repositories\ProductRepository; use App\Repositories\ProductRepository;
use App\Repositories\QuoteRepository;
use App\Repositories\VendorRepository; use App\Repositories\VendorRepository;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\ParameterBag;
@ -55,6 +59,7 @@ class Csv extends BaseImport implements ImportInterface
'payment', 'payment',
'vendor', 'vendor',
'expense', 'expense',
'quote',
]) ])
) { ) {
$this->{$entity}(); $this->{$entity}();
@ -151,6 +156,35 @@ class Csv extends BaseImport implements ImportInterface
$this->entity_count['invoices'] = $invoice_count; $this->entity_count['invoices'] = $invoice_count;
} }
public function quote()
{
$entity_type = 'quote';
$data = $this->getCsvData($entity_type);
if (is_array($data)) {
$data = $this->preTransformCsv($data, $entity_type);
}
if (empty($data)) {
$this->entity_count['quotes'] = 0;
return;
}
$this->request_name = StoreQuoteRequest::class;
$this->repository_name = QuoteRepository::class;
$this->factory_name = QuoteFactory::class;
$this->repository = app()->make($this->repository_name);
$this->repository->import_mode = true;
$this->transformer = new QuoteTransformer($this->company);
$quote_count = $this->ingestQuotes($data, 'quote.number');
$this->entity_count['quotes'] = $quote_count;
}
public function payment() public function payment()
{ {
$entity_type = 'payment'; $entity_type = 'payment';
@ -241,10 +275,6 @@ class Csv extends BaseImport implements ImportInterface
$this->entity_count['expenses'] = $expense_count; $this->entity_count['expenses'] = $expense_count;
} }
public function quote()
{
}
public function task() public function task()
{ {
} }

View File

@ -52,15 +52,42 @@ class VendorTransformer extends BaseTransformer
'custom_value2' => $this->getString($data, 'vendor.custom_value2'), 'custom_value2' => $this->getString($data, 'vendor.custom_value2'),
'custom_value3' => $this->getString($data, 'vendor.custom_value3'), 'custom_value3' => $this->getString($data, 'vendor.custom_value3'),
'custom_value4' => $this->getString($data, 'vendor.custom_value4'), 'custom_value4' => $this->getString($data, 'vendor.custom_value4'),
'vendor_contacts' => [ // 'vendor_contacts' => [
// [
// 'first_name' => $this->getString(
// $data,
// 'vendor.first_name'
// ),
// 'last_name' => $this->getString($data, 'vendor.last_name'),
// 'email' => $this->getString($data, 'vendor.email'),
// 'phone' => $this->getString($data, 'vendor.phone'),
// ],
// ],
'contacts' => [
[ [
'first_name' => $this->getString( 'first_name' => $this->getString(
$data, $data,
'vendor.first_name' 'contact.first_name'
),
'last_name' => $this->getString($data, 'contact.last_name'),
'email' => $this->getString($data, 'contact.email'),
'phone' => $this->getString($data, 'contact.phone'),
'custom_value1' => $this->getString(
$data,
'contact.custom_value1'
),
'custom_value2' => $this->getString(
$data,
'contact.custom_value2'
),
'custom_value3' => $this->getString(
$data,
'contact.custom_value3'
),
'custom_value4' => $this->getString(
$data,
'contact.custom_value4'
), ),
'last_name' => $this->getString($data, 'vendor.last_name'),
'email' => $this->getString($data, 'vendor.email'),
'phone' => $this->getString($data, 'vendor.phone'),
], ],
], ],
'country_id' => isset($data['vendor.country_id']) 'country_id' => isset($data['vendor.country_id'])

View File

@ -74,7 +74,7 @@ class CSVIngest implements ShouldQueue
$engine = $this->bootEngine(); $engine = $this->bootEngine();
foreach (['client', 'product', 'invoice', 'payment', 'vendor', 'expense'] as $entity) { foreach (['client', 'product', 'invoice', 'payment', 'vendor', 'expense', 'quote'] as $entity) {
$engine->import($entity); $engine->import($entity);
} }