Merge pull request #3915 from turbo124/v2

Improvements to demo data
This commit is contained in:
David Bomba 2020-07-20 08:05:28 +10:00 committed by GitHub
commit 392f173789
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 52 additions and 40 deletions

View File

@ -92,7 +92,7 @@ class DemoMode extends Command
{
$faker = \Faker\Factory::create();
$this->count = 10;
$this->count = 50;
$this->info('Creating Small Account and Company');
@ -200,46 +200,46 @@ class DemoMode extends Command
{
$client = $company->clients->random();
$this->info('creating invoice for client #'.$client->id);
for($y=0; $y<($this->count); $y++){
$this->info("creating invoice #{$y} for client #".$client->id);
$this->info('creating entities for client #'.$client->id);
$this->createInvoice($client);
}
// for($y=0; $y<($this->count); $y++){
// $this->info("creating invoice #{$y} for client #".$client->id);
// }
$client = $company->clients->random();
for($y=0; $y<($this->count); $y++){
$this->info("creating credit #{$y} for client #".$client->id);
$this->createCredit($client);
}
// for($y=0; $y<($this->count); $y++){
// $this->info("creating credit #{$y} for client #".$client->id);
// }
$client = $company->clients->random();
for($y=0; $y<($this->count); $y++){
$this->info("creating quote #{$y} for client #".$client->id);
$this->createQuote($client);
}
// for($y=0; $y<($this->count); $y++){
// $this->info("creating quote #{$y} for client #".$client->id);
// }
$client = $company->clients->random();
$this->createExpense($client);
$this->info("creating expense for client #".$client->id);
$this->createExpense($client);
//$this->info("creating expense for client #".$client->id);
$client = $company->clients->random();
$this->info("creating vendor for client #".$client->id);
$this->createVendor($client);
$client = $company->clients->random();
// $this->info("creating vendor for client #".$client->id);
$this->info("creating task for client #".$client->id);
$client = $company->clients->random();
$this->createTask($client);
$client = $company->clients->random();
// $this->info("creating task for client #".$client->id);
$this->info("creating project for client #".$client->id);
$client = $company->clients->random();
$this->createProject($client);
// $this->info("creating project for client #".$client->id);
}
}
@ -446,12 +446,18 @@ class DemoMode extends Command
$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))
if((bool)rand(0,1)){
$dateable = Carbon::now()->subDays(rand(1, 30));
else
$dateable_due = $dateable->addDays(rand(1, 30));
}
else{
$dateable = Carbon::now()->addDays(rand(1, 30));
$dateable_due = $dateable->addDays(rand(-10, 30));
}
$quote->date = $dateable;
$quote->due_date = $dateable_due;
$quote->client_id = $client->id;
$quote->setRelation('client', $client);

View File

@ -536,6 +536,13 @@ class CreditController extends BaseController
case 'archive':
$this->credit_repository->archive($credit);
if (!$bulk) {
return $this->listResponse($credit);
}
break;
case 'restore':
$this->credit_repository->restore($credit);
if (!$bulk) {
return $this->listResponse($credit);
}

View File

@ -39,11 +39,6 @@ class StartupCheck
public function handle(Request $request, Closure $next)
{
// $start = microtime(true);
// Log::error('start up check');
if ($request->has('clear_cache')) {
Session::flash('message', 'Cache cleared');
}
/* Make sure our cache is built */
$cached_tables = config('ninja.cached_tables');

View File

@ -28,6 +28,8 @@ use App\Http\Requests\Company\UpdateCompanyRequest;
use App\Http\ValidationRules\ValidCompanyGatewayFeesAndLimitsRule;
use App\Http\ValidationRules\ValidUserForCompany;
use App\Jobs\Company\CreateCompanyToken;
use App\Jobs\Ninja\CompanySizeCheck;
use App\Jobs\Util\VersionCheck;
use App\Libraries\MultiDB;
use App\Mail\MigrationCompleted;
use App\Mail\MigrationFailed;
@ -175,6 +177,10 @@ class Import implements ShouldQueue
Mail::to($this->user)->send(new MigrationCompleted());
/*After a migration first some basic jobs to ensure the system is up to date*/
VersionCheck::dispatch();
CompanySizeCheck::dispatch();
info('Completed🚀🚀🚀🚀🚀 at '.now());
return true;

View File

@ -185,7 +185,7 @@ class EventServiceProvider extends ServiceProvider
// CreateInvoicePdf::class,
],
InvoiceWasPaid::class => [
CreateInvoiceHtmlBackup::class,
// CreateInvoiceHtmlBackup::class,
],
InvoiceWasViewed::class => [
InvoiceViewedActivity::class,

View File

@ -252,7 +252,7 @@ class BaseRepository
$invitations = collect($data['invitations']);
/* Get array of Keys which have been removed from the invitations array and soft delete each invitation */
$model->invitations->pluck('key')->diff($invitations->pluck('key'))->each(function ($invitation) {
$model->invitations->pluck('key')->diff($invitations->pluck('key'))->each(function ($invitation) use($resource){
$this->getInvitation($invitation, $resource)->delete();
});

View File

@ -44,15 +44,15 @@ class TriggeredActions extends AbstractService
public function run()
{
if($this->request->has('auto_bill')) {
if($this->request->has('auto_bill') && $this->request->input('auto_bill') == 'true') {
$this->invoice = $this->invoice->service()->autoBill()->save();
}
if($this->request->has('paid') && (bool)$this->request->input('paid') !== false) {
if($this->request->has('paid') && $this->request->input('paid') == 'true') {
$this->invoice = $this->invoice->service()->markPaid()->save();
}
if($this->request->has('send_email') && (bool)$this->request->input('send_email') !== false) {
if($this->request->has('send_email') && $this->request->input('send_email') == 'true') {
$this->sendEmail();
}

View File

@ -15,14 +15,12 @@ $factory->define(App\Models\Quote::class, function (Faker $faker) {
'tax_rate2' => 17.5,
'tax_name3' => 'THIRDTAX',
'tax_rate3' => 5,
'custom_value1' => $faker->numberBetween(1, 4),
'custom_value2' => $faker->numberBetween(1, 4),
'custom_value3' => $faker->numberBetween(1, 4),
'custom_value4' => $faker->numberBetween(1, 4),
// 'custom_value1' => $faker->numberBetween(1, 4),
// 'custom_value2' => $faker->numberBetween(1, 4),
// 'custom_value3' => $faker->numberBetween(1, 4),
// 'custom_value4' => $faker->numberBetween(1, 4),
'is_deleted' => false,
'po_number' => $faker->text(10),
'date' => $faker->date(),
'due_date' => $faker->date(),
'line_items' => false,
];
});