mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Import CSV
This commit is contained in:
parent
864892a7d2
commit
57ee54032f
@ -12,9 +12,11 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Import\ImportRequest;
|
||||
use App\Http\Requests\Import\PreImportRequest;
|
||||
use App\Import\Definitions\Import\ImportMap;
|
||||
use App\Import\Definitions\InvoiceMap;
|
||||
use App\Jobs\Import\CSVImport;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Str;
|
||||
@ -91,6 +93,12 @@ class ImportController extends Controller
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public function import(ImportRequest $request)
|
||||
{
|
||||
CSVImport::dispatch($request, auth()->user()->company());
|
||||
|
||||
return response()->json(['message' => 'Importing data, email will be sent on completion'], 200);
|
||||
}
|
||||
|
||||
private function getCsvData($csvfile)
|
||||
{
|
||||
|
37
app/Http/Requests/Import/ImportRequest.php
Normal file
37
app/Http/Requests/Import/ImportRequest.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests\Import;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class ImportRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize() : bool
|
||||
{
|
||||
return auth()->user()->isAdmin();
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
|
||||
return [
|
||||
'hash' => 'required',
|
||||
'entity_type' => 'required',
|
||||
];
|
||||
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@
|
||||
namespace App\Http\Requests\Import;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\GroupSetting;
|
||||
|
||||
class PreImportRequest extends Request
|
||||
{
|
||||
@ -30,7 +29,8 @@ class PreImportRequest extends Request
|
||||
{
|
||||
|
||||
return [
|
||||
'file' => 'required|file|mimes:csv,txt'
|
||||
'file' => 'required|file|mimes:csv,txt',
|
||||
'entity_type' => 'required',
|
||||
];
|
||||
|
||||
}
|
||||
|
@ -54,6 +54,9 @@ class InvoiceMap
|
||||
34 => 'invoice.line_items',
|
||||
35 => 'client.name',
|
||||
36 => 'client.email',
|
||||
37 => 'payment.date',
|
||||
38 => 'payment.amount',
|
||||
39 => 'payment.transaction_reference',
|
||||
];
|
||||
}
|
||||
|
||||
@ -75,7 +78,7 @@ class InvoiceMap
|
||||
12 => 'texts.public_notes',
|
||||
13 => 'texts.private_notes',
|
||||
14 => 'texts.uses_inclusive_taxes',
|
||||
15 => 'texts.tax_name1',
|
||||
15 => 'texts.tax_name',
|
||||
16 => 'texts.tax_rate',
|
||||
17 => 'texts.tax_name',
|
||||
18 => 'texts.tax_rate',
|
||||
@ -95,6 +98,11 @@ class InvoiceMap
|
||||
32 => 'texts.surcharge',
|
||||
33 => 'texts.exchange_rate',
|
||||
34 => 'texts.items',
|
||||
35 => 'texts.client_name',
|
||||
36 => 'texts.email',
|
||||
37 => 'texts.payment_date',
|
||||
38 => 'texts.payment_amount',
|
||||
39 => 'texts.transaction_reference',
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user