Improvements to quality of test data

This commit is contained in:
David Bomba 2020-05-28 10:04:26 +10:00
parent 41b19c20c1
commit 2d2be07944
3 changed files with 62 additions and 39 deletions

View File

@ -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);
}

View File

@ -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());
}
/*

View File

@ -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,