mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Fixes for tests
This commit is contained in:
parent
e3f48f9b8b
commit
4df646f93b
@ -17,6 +17,7 @@ use App\Http\ValidationRules\Project\ValidProjectForClient;
|
|||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Utils\Traits\CleanLineItems;
|
use App\Utils\Traits\CleanLineItems;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class StoreInvoiceRequest extends Request
|
class StoreInvoiceRequest extends Request
|
||||||
{
|
{
|
||||||
|
@ -171,8 +171,14 @@ class CSVImport implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
$unique_array_filter = array_unique($records[$invoice_number_key]);
|
$unique_array_filter = array_unique($records[$invoice_number_key]);
|
||||||
|
|
||||||
|
info(print_r($unique_array_filter,1));
|
||||||
|
|
||||||
$unique_invoices = array_intersect_key( $records, $unique_array_filter );
|
$unique_invoices = array_intersect_key( $records, $unique_array_filter );
|
||||||
|
|
||||||
|
info(print_r($unique_invoices,1));
|
||||||
|
|
||||||
|
|
||||||
foreach($unique_invoices as $unique)
|
foreach($unique_invoices as $unique)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -190,6 +196,8 @@ class CSVImport implements ShouldQueue
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
info(print_r($invoices,1));
|
||||||
|
|
||||||
$this->processInvoice($invoices, $invoice);
|
$this->processInvoice($invoices, $invoice);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ namespace Tests\Feature\Import;
|
|||||||
|
|
||||||
use App\Jobs\Import\CSVImport;
|
use App\Jobs\Import\CSVImport;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
use App\Models\Invoice;
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||||
@ -53,6 +54,56 @@ class ImportCsvTest extends TestCase
|
|||||||
$this->assertTrue(is_array($this->getCsvData($csv)));
|
$this->assertTrue(is_array($this->getCsvData($csv)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testInvoiceCsvImport()
|
||||||
|
{
|
||||||
|
$csv = file_get_contents(base_path().'/tests/Feature/Import/invoice.csv');
|
||||||
|
$hash = Str::random(32);
|
||||||
|
$column_map = [
|
||||||
|
0 => 'invoice.number',
|
||||||
|
4 => 'invoice.client_id',
|
||||||
|
7 => 'invoice.date',
|
||||||
|
8 => 'invoice.due_date',
|
||||||
|
9 => 'invoice.terms',
|
||||||
|
10 => 'invoice.public_notes',
|
||||||
|
11 => 'invoice.is_sent',
|
||||||
|
12 => 'invoice.private_notes',
|
||||||
|
13 => 'invoice.uses_inclusive_taxes',
|
||||||
|
14 => 'invoice.tax_name1',
|
||||||
|
15 => 'invoice.tax_rate1',
|
||||||
|
16 => 'invoice.tax_name2',
|
||||||
|
17 => 'invoice.tax_rate2',
|
||||||
|
18 => 'invoice.tax_name3',
|
||||||
|
19 => 'invoice.tax_rate3',
|
||||||
|
21 => 'invoice.footer',
|
||||||
|
22 => 'invoice.partial',
|
||||||
|
23 => 'invoice.partial_due_date',
|
||||||
|
33 => 'payment.date',
|
||||||
|
34 => 'payment.amount',
|
||||||
|
35 => 'payment.transaction_reference',
|
||||||
|
36 => 'item.quantity',
|
||||||
|
37 => 'item.cost',
|
||||||
|
38 => 'item.product_key',
|
||||||
|
39 => 'item.notes',
|
||||||
|
40 => 'item.discount',
|
||||||
|
41 => 'item.is_amount_discount',
|
||||||
|
];
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'hash' => $hash,
|
||||||
|
'column_map' => $column_map,
|
||||||
|
'skip_header' => true,
|
||||||
|
'entity_type'=> 'invoice',
|
||||||
|
];
|
||||||
|
|
||||||
|
$pre_import = Invoice::count();
|
||||||
|
|
||||||
|
Cache::put($hash, base64_encode($csv), 360);
|
||||||
|
|
||||||
|
CSVImport::dispatchNow($data, $this->company);
|
||||||
|
|
||||||
|
$this->assertGreaterThan($pre_import, Client::count());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testClientCsvImport()
|
public function testClientCsvImport()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user