From 7c39b2e65aa09607876ca6c4c24b76293d7b48d3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 2 Jun 2020 20:15:12 +1000 Subject: [PATCH 1/2] Fixes for check data --- app/Console/Commands/CheckData.php | 2 +- app/Console/Commands/CreateTestData.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index e347c735c9ef..839f7f562e36 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -299,7 +299,7 @@ class CheckData extends Command $ledger = CompanyLedger::where('client_id', $client->id)->orderBy('id', 'DESC')->first(); - if($ledger && $invoice_balance != $client->balance) + if($ledger && number_format($invoice_balance, 4) != number_format($client->balance, 4)) { $wrong_balances++; $this->logMessage($client->present()->name . " - " . $client->id . " - balances do not match {$invoice_balance} - {$client->balance} - {$ledger->balance}"); diff --git a/app/Console/Commands/CreateTestData.php b/app/Console/Commands/CreateTestData.php index 7b79178e2bab..45ac31773554 100644 --- a/app/Console/Commands/CreateTestData.php +++ b/app/Console/Commands/CreateTestData.php @@ -25,6 +25,7 @@ use App\Models\PaymentType; use App\Models\Product; use App\Models\User; use App\Repositories\InvoiceRepository; +use App\Utils\Traits\GeneratesCounter; use App\Utils\Traits\MakesHash; use Carbon\Carbon; use Faker\Factory; @@ -35,7 +36,7 @@ use Illuminate\Support\Str; class CreateTestData extends Command { - use MakesHash; + use MakesHash, GeneratesCounter; /** * @var string */ @@ -233,7 +234,7 @@ class CreateTestData extends Command $this->createClient($company, $user); } - for($x=0; $x<$this->count; $x++) + for($x=0; $x<$this->count*100; $x++) { $client = $company->clients->random(); @@ -324,7 +325,7 @@ class CreateTestData extends Command $this->info('Creating '.$this->count. ' clients'); - for ($x=0; $x<$this->count; $x++) { + for ($x=0; $x<$this->count*1000; $x++) { $z = $x+1; $this->info("Creating client # ".$z); @@ -393,6 +394,10 @@ class CreateTestData extends Command 'client_id' => $client->id, 'company_id' => $company->id ]); + + $client->id_number = $this->getNextClientNumber($client); + $client->save(); + } private function createExpense($client) From fa19c708553eaa050245ff217dd913a3080774de Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 2 Jun 2020 20:19:29 +1000 Subject: [PATCH 2/2] Create a status for Quote -> Completed --- app/Models/Quote.php | 1 + app/Services/Quote/ConvertQuote.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Models/Quote.php b/app/Models/Quote.php index 9c758b944587..c8146faa27e5 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -84,6 +84,7 @@ class Quote extends BaseModel const STATUS_DRAFT = 1; const STATUS_SENT = 2; const STATUS_APPROVED = 3; + const STATUS_CONVERTED = 4; const STATUS_EXPIRED = -1; public function getEntityType() diff --git a/app/Services/Quote/ConvertQuote.php b/app/Services/Quote/ConvertQuote.php index 597e57dae741..873439b023b9 100644 --- a/app/Services/Quote/ConvertQuote.php +++ b/app/Services/Quote/ConvertQuote.php @@ -2,7 +2,7 @@ namespace App\Services\Quote; use App\Factory\CloneQuoteToInvoiceFactory; -use App\Quote; +use App\Models\Quote; use App\Repositories\InvoiceRepository; class ConvertQuote @@ -33,6 +33,7 @@ class ConvertQuote ->save(); $quote->invoice_id = $invoice->id; + $quote->status_id = Quote::STATUS_CONVERTED; $quote->save(); // maybe should return invoice here