Fixes for demo data

This commit is contained in:
David Bomba 2020-07-17 07:50:02 +10:00
parent 5eb9791c37
commit c0237474ef
5 changed files with 45 additions and 24 deletions

View File

@ -90,6 +90,8 @@ class DemoMode extends Command
private function createSmallAccount()
{
$faker = \Faker\Factory::create();
$this->count = 10;
$this->info('Creating Small Account and Company');
@ -101,6 +103,20 @@ class DemoMode extends Command
'enabled_modules' => 4095,
]);
$settings = $company->settings;
$settings->name = $faker->company;
$settings->address1 = $faker->buildingNumber;
$settings->address2 = $faker->streetAddress;
$settings->city = $faker->city;
$settings->state = $faker->state;
$settings->postal_code = $faker->postcode;
$settings->website = $faker->url;
$settings->vat_number = $faker->numberBetween(123456789, 987654321);
$settings->phone = $faker->phoneNumber;
$company->settings = $settings;
$company->save();
$account->default_company_id = $company->id;
$account->save();
@ -258,9 +274,7 @@ class DemoMode extends Command
$settings->currency_id = (string)rand(1,3);
$client->settings = $settings;
$country = Country::all()->random();
$client->country_id = $country->id;
$client->country_id = array_rand([36,392,840,124,276,826]);
$client->save();
}
@ -268,31 +282,31 @@ class DemoMode extends Command
private function createExpense($client)
{
factory(\App\Models\Expense::class, rand(1, 5))->create([
'user_id' => $client->user->id,
'user_id' => $client->user_id,
'client_id' => $client->id,
'company_id' => $client->company->id
'company_id' => $client->company_id
]);
}
private function createVendor($client)
{
$vendor = factory(\App\Models\Vendor::class)->create([
'user_id' => $client->user->id,
'company_id' => $client->company->id
'user_id' => $client->user_id,
'company_id' => $client->company_id
]);
factory(\App\Models\VendorContact::class, 1)->create([
'user_id' => $client->user->id,
'vendor_id' => $vendor->id,
'company_id' => $client->company->id,
'company_id' => $client->company_id,
'is_primary' => 1
]);
factory(\App\Models\VendorContact::class, rand(1, 5))->create([
'user_id' => $client->user->id,
'vendor_id' => $vendor->id,
'company_id' => $client->company->id,
'company_id' => $client->company_id,
'is_primary' => 0
]);
}
@ -301,7 +315,7 @@ class DemoMode extends Command
{
$vendor = factory(\App\Models\Task::class)->create([
'user_id' => $client->user->id,
'company_id' => $client->company->id
'company_id' => $client->company_id
]);
}
@ -309,7 +323,7 @@ class DemoMode extends Command
{
$vendor = factory(\App\Models\Project::class)->create([
'user_id' => $client->user->id,
'company_id' => $client->company->id
'company_id' => $client->company_id
]);
}
@ -427,19 +441,15 @@ class DemoMode extends Command
private function createQuote($client)
{
// for($x=0; $x<$this->count; $x++){
// dispatch(new CreateTestQuoteJob($client));
// }
$faker = \Faker\Factory::create();
//$quote = QuoteFactory::create($client->company->id, $client->user->id);//stub the company and user_id
$quote =factory(\App\Models\Quote::class)->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]);
$quote =factory(\App\Models\Quote::class)->create(['user_id' => $client->user->id, 'company_id' => $client->company_id, 'client_id' => $client->id]);
if((bool)rand(0,1))
$dateable = Carbon::now()->subDays(rand(0, 90));
$dateable = Carbon::now()->subDays(rand(1, 30));
else
$dateable = Carbon::now()->addDays(rand(0, 90));
$dateable = Carbon::now()->addDays(rand(1, 30));
$quote->date = $dateable;
$quote->client_id = $client->id;

View File

@ -40,10 +40,10 @@ class QuoteFactory
$quote->tax_rate1 = 0;
$quote->tax_name2 = '';
$quote->tax_rate2 = 0;
$quote->custom_value1 = 0;
$quote->custom_value2 = 0;
$quote->custom_value3 = 0;
$quote->custom_value4 = 0;
$quote->custom_value1 = '';
$quote->custom_value2 = '';
$quote->custom_value3 = '';
$quote->custom_value4 = '';
$quote->amount = 0;
$quote->balance = 0;
$quote->partial = 0;

View File

@ -76,4 +76,9 @@ class Expense extends BaseModel
{
return $this->belongsTo(User::class, 'assigned_user_id', 'id');
}
public function company()
{
return $this->belongsTo(Company::class);
}
}

View File

@ -83,4 +83,9 @@ class Vendor extends BaseModel
{
return $this->hasMany(Activity::class);
}
public function company()
{
return $this->belongsTo(Company::class);
}
}

View File

@ -5,15 +5,16 @@ use App\DataMapper\CompanySettings;
use Faker\Generator as Faker;
$factory->define(App\Models\Client::class, function (Faker $faker) {
return [
'name' => $faker->company(),
'website' => $faker->url,
'private_notes' => $faker->text(200),
'balance' => 0,
'paid_to_date' => 0,
'vat_number' => $faker->text(25),
'vat_number' => $faker->numberBetween(123456789, 987654321),
'id_number' => '',
'custom_value1' => $faker->date('Y-m-d'),
'custom_value1' => '',
'custom_value2' => '',
'custom_value3' => '',
'custom_value4' => '',