diff --git a/app/Console/Commands/CreateTestData.php b/app/Console/Commands/CreateTestData.php index df22a2a24b90..7b79178e2bab 100644 --- a/app/Console/Commands/CreateTestData.php +++ b/app/Console/Commands/CreateTestData.php @@ -135,28 +135,44 @@ class CreateTestData extends Command $this->createClient($company, $user); } - foreach ($company->clients as $client) { + for($x=0; $x<$this->count; $x++) + { + $client = $company->clients->random(); + $this->info('creating invoice for client #'.$client->id); $this->createInvoice($client); + $client = $company->clients->random(); + $this->info('creating credit for client #'.$client->id); $this->createCredit($client); + $client = $company->clients->random(); + $this->info('creating quote for client #'.$client->id); $this->createQuote($client); + $client = $company->clients->random(); + $this->info('creating expense for client #'.$client->id); $this->createExpense($client); + $client = $company->clients->random(); + $this->info('creating vendor for client #'.$client->id); $this->createVendor($client); + $client = $company->clients->random(); + $this->info('creating task for client #'.$client->id); $this->createTask($client); + $client = $company->clients->random(); + $this->info('creating project for client #'.$client->id); $this->createProject($client); } + } private function createMediumAccount() @@ -217,49 +233,42 @@ class CreateTestData extends Command $this->createClient($company, $user); } - foreach ($company->clients as $client) { - $this->info('creating invoice for client #'.$client->id); + for($x=0; $x<$this->count; $x++) + { + $client = $company->clients->random(); - for ($i=0; $i<$this->count; $i++) { - $this->createInvoice($client); - } + $this->info('creating invoice for client #'.$client->id); + $this->createInvoice($client); + + $client = $company->clients->random(); $this->info('creating credit for client #'.$client->id); + $this->createCredit($client); - for ($i=0; $i<$this->count; $i++) { - $this->createCredit($client); - } - + $client = $company->clients->random(); $this->info('creating quote for client #'.$client->id); + $this->createQuote($client); - for ($i=0; $i<$this->count; $i++) { - $this->createQuote($client); - } + $client = $company->clients->random(); $this->info('creating expense for client #'.$client->id); - - for ($i=0; $i<$this->count; $i++) { - $this->createExpense($client); - } + $this->createExpense($client); + + $client = $company->clients->random(); $this->info('creating vendor for client #'.$client->id); - - for ($i=0; $i<$this->count; $i++) { - $this->createVendor($client); - } + $this->createVendor($client); + + $client = $company->clients->random(); $this->info('creating task for client #'.$client->id); - - for ($i=0; $i<$this->count; $i++) { - $this->createTask($client); - } + $this->createTask($client); + + $client = $company->clients->random(); $this->info('creating project for client #'.$client->id); - - for ($i=0; $i<$this->count; $i++) { - $this->createProject($client); - } + $this->createProject($client); } } @@ -322,25 +331,40 @@ class CreateTestData extends Command $this->createClient($company, $user); } - foreach ($company->clients as $client) { + for($x=0; $x<$this->count; $x++) + { + $client = $company->clients->random(); + $this->info('creating invoice for client #'.$client->id); $this->createInvoice($client); + $client = $company->clients->random(); + $this->info('creating credit for client #'.$client->id); $this->createCredit($client); + $client = $company->clients->random(); + $this->info('creating quote for client #'.$client->id); $this->createQuote($client); + $client = $company->clients->random(); + $this->info('creating expense for client #'.$client->id); $this->createExpense($client); + $client = $company->clients->random(); + $this->info('creating vendor for client #'.$client->id); $this->createVendor($client); + $client = $company->clients->random(); + $this->info('creating task for client #'.$client->id); $this->createTask($client); + $client = $company->clients->random(); + $this->info('creating project for client #'.$client->id); $this->createProject($client); } diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index 59e43a47009a..cfcb8cdac667 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -533,14 +533,13 @@ class QuoteController extends BaseController $this->entity_type = Invoice::class; $this->entity_transformer = InvoiceTransformer::class; - $invoices = $quotes->map(function ($quote, $key) use ($action) { + $quotes->each(function ($quote, $key) use ($action) { if (auth()->user()->can('edit', $quote) && $quote->service()->isConvertable()) { - $invoice = $quote->service()->convertToInvoice(); - return $invoice->id; + $quote->service()->convertToInvoice(); } }); - return $this->listResponse(Invoice::withTrashed()->whereIn('id', $invoices)->company()); + return $this->listResponse(Quote::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()); } /* diff --git a/database/factories/ClientFactory.php b/database/factories/ClientFactory.php index 270b23dbdc2a..e00726d139dd 100644 --- a/database/factories/ClientFactory.php +++ b/database/factories/ClientFactory.php @@ -12,11 +12,11 @@ $factory->define(App\Models\Client::class, function (Faker $faker) { 'balance' => 0, 'paid_to_date' => 0, 'vat_number' => $faker->text(25), - 'id_number' => $faker->text(20), - 'custom_value1' => $faker->text(20), - 'custom_value2' => $faker->text(20), - 'custom_value3' => $faker->text(20), - 'custom_value4' => $faker->text(20), + 'id_number' => '', + 'custom_value1' => 'date|'.$faker->date('Y-m-d'), + 'custom_value2' => '', + 'custom_value3' => '', + 'custom_value4' => '', 'address1' => $faker->buildingNumber, 'address2' => $faker->streetAddress, 'city' => $faker->city,