From e00500efd8a67ccd88dd7748ec5ec9bd0347eba0 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 19 Jul 2020 17:17:19 +1000 Subject: [PATCH 1/3] Minor enhancement for import process --- app/Jobs/Util/Import.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index a7ff06bea75a..4f7de793674a 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -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; From fec8e8b5209c3634a33b1fcb51b97e38c3de3ee2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 20 Jul 2020 07:54:10 +1000 Subject: [PATCH 2/3] Fix bug where restoring a credit wouldn't work --- app/Http/Controllers/CreditController.php | 7 +++++++ app/Http/Middleware/StartupCheck.php | 5 ----- app/Providers/EventServiceProvider.php | 2 +- app/Repositories/BaseRepository.php | 2 +- app/Services/Invoice/TriggeredActions.php | 6 +++--- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index 73588356f343..87bd4b1de5b4 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -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); } diff --git a/app/Http/Middleware/StartupCheck.php b/app/Http/Middleware/StartupCheck.php index 84a0e1f37cb1..c37fd2fa012e 100644 --- a/app/Http/Middleware/StartupCheck.php +++ b/app/Http/Middleware/StartupCheck.php @@ -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'); diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 16ced64cc8cc..8019d9409a7d 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -185,7 +185,7 @@ class EventServiceProvider extends ServiceProvider // CreateInvoicePdf::class, ], InvoiceWasPaid::class => [ - CreateInvoiceHtmlBackup::class, + // CreateInvoiceHtmlBackup::class, ], InvoiceWasViewed::class => [ InvoiceViewedActivity::class, diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index fe6a6d2586e8..c96cdf52577f 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -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(); }); diff --git a/app/Services/Invoice/TriggeredActions.php b/app/Services/Invoice/TriggeredActions.php index 8b807031e825..e5b1bfd204f1 100644 --- a/app/Services/Invoice/TriggeredActions.php +++ b/app/Services/Invoice/TriggeredActions.php @@ -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(); } From 867ae6435fee35f43ab7764e1b0edec069f04d4b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 20 Jul 2020 08:04:52 +1000 Subject: [PATCH 3/3] Improvements to demo data --- app/Console/Commands/DemoMode.php | 54 ++++++++++++++++------------- database/factories/QuoteFactory.php | 10 +++--- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/app/Console/Commands/DemoMode.php b/app/Console/Commands/DemoMode.php index 15093de71892..bc1875f5a787 100644 --- a/app/Console/Commands/DemoMode.php +++ b/app/Console/Commands/DemoMode.php @@ -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); diff --git a/database/factories/QuoteFactory.php b/database/factories/QuoteFactory.php index c4ec77a82093..54d87288fcc1 100644 --- a/database/factories/QuoteFactory.php +++ b/database/factories/QuoteFactory.php @@ -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, ]; });