diff --git a/app/Console/Commands/CreateTestData.php b/app/Console/Commands/CreateTestData.php index 675a00f36019..46bf28984805 100644 --- a/app/Console/Commands/CreateTestData.php +++ b/app/Console/Commands/CreateTestData.php @@ -20,6 +20,7 @@ use App\Jobs\Quote\CreateQuoteInvitations; use App\Listeners\Credit\CreateCreditInvitation; use App\Listeners\Invoice\CreateInvoiceInvitation; use App\Models\CompanyToken; +use App\Models\Country; use App\Models\Payment; use App\Models\PaymentType; use App\Models\Product; @@ -396,6 +397,14 @@ class CreateTestData extends Command ]); $client->id_number = $this->getNextClientNumber($client); + + $settings = $client->settings; + $settings->currency_id = (string)rand(1,79); + $client->settings = $settings; + + $country = Country::all()->random(); + + $client->country_id = $country->id; $client->save(); } diff --git a/app/Console/Commands/DemoMode.php b/app/Console/Commands/DemoMode.php index 3f90cbbe5c86..b306ee7f43d0 100644 --- a/app/Console/Commands/DemoMode.php +++ b/app/Console/Commands/DemoMode.php @@ -38,9 +38,14 @@ class DemoMode extends Command { set_time_limit(0); - Artisan::call('migrate:fresh'); - Artisan::call('db:seed'); - Artisan::call('db:seed --class=RandomDataSeeder'); + $this->info("Migrating"); + Artisan::call('migrate:fresh --force'); + + $this->info("Seeding"); + Artisan::call('db:seed --force'); + + $this->info("Seeding Random Data"); + Artisan::call('db:seed --class=RandomDataSeeder --force'); } } diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index a3cc6e5ed1ce..2ac79b281ef7 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -302,16 +302,25 @@ class BaseRepository $model->client->service()->updateBalance(($state['finished_amount'] - $state['starting_amount']))->save(); } + if(!$model->design_id) + $model->design_id = $client->getSetting('invoice_design_id'); + event(new InvoiceWasUpdated($model, $model->company)); } if ($class->name == Credit::class) { $model = $model->calc()->getCredit(); + + if(!$model->design_id) + $model->design_id = $client->getSetting('credit_design_id'); } if ($class->name == Quote::class) { $model = $model->calc()->getQuote(); + + if(!$model->design_id) + $model->design_id = $client->getSetting('quote_design_id'); } $model->save();