Merge pull request #3892 from turbo124/v2

Fixes for checkdata
This commit is contained in:
David Bomba 2020-07-07 20:36:17 +10:00 committed by GitHub
commit 0b2d4e7554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 22 deletions

View File

@ -76,9 +76,6 @@ class CheckData extends Command
config(['database.default' => $database]);
}
if (! $this->option('client_id')) {
$this->checkPaidToDate();
}
$this->checkInvoiceBalances();
$this->checkInvoicePayments();
@ -286,11 +283,6 @@ class CheckData extends Command
}
}
private function checkPaidToDate()
{
//Check the client paid to date value matches the sum of payments by the client
}
private function checkInvoiceBalances()
{
@ -327,7 +319,7 @@ class CheckData extends Command
$total_invoice_payments = 0;
foreach($client->invoices->where('is_deleted', false) as $invoice)
foreach($client->invoices as $invoice)
{
$total_amount = $invoice->payments->sum('pivot.amount');
$total_refund = $invoice->payments->sum('pivot.refunded');
@ -357,7 +349,7 @@ class CheckData extends Command
Client::cursor()->each(function ($client) use($wrong_balances){
$client->invoices->where('is_deleted', false)->each(function ($invoice) use($wrong_balances){
$client->invoices->where('is_deleted', false)->each(function ($invoice) use($wrong_balances, $client){
$total_amount = $invoice->payments->sum('pivot.amount');
$total_refund = $invoice->payments->sum('pivot.refunded');
@ -387,8 +379,8 @@ class CheckData extends Command
foreach(Client::cursor() as $client)
{
$invoice_balance = $client->invoices->where('is_deleted', false)->sum('balance');
$invoice_amounts = $client->invoices->where('is_deleted', false)->sum('amount') - $invoice_balance;
$invoice_balance = $client->invoices->sum('balance');
$invoice_amounts = $client->invoices->sum('amount') - $invoice_balance;
$ledger = CompanyLedger::where('client_id', $client->id)->orderBy('id', 'DESC')->first();

View File

@ -192,7 +192,7 @@ class Client extends BaseModel implements HasLocalePreference
public function invoices()
{
return $this->hasMany(Invoice::class);
return $this->hasMany(Invoice::class)->withTrashed();
}
public function shipping_country()

View File

@ -196,7 +196,7 @@ class Invoice extends BaseModel
public function payments()
{
return $this->morphToMany(Payment::class, 'paymentable')->withPivot('amount', 'refunded')->withTimestamps();
return $this->morphToMany(Payment::class, 'paymentable')->withPivot('amount', 'refunded')->withTimestamps()->withTrashed();
;
}

View File

@ -84,12 +84,9 @@ class InvoiceRepository extends BaseRepository
return;
}
$invoice->is_deleted = true;
$invoice->save();
$invoice->delete();
event(new InvoiceWasDeleted($invoice, $invoice->company));
$invoice->service()->handleCancellation()->save();
$invoice = $this->invoice_repo->delete($invoice);
return $invoice;
}

View File

@ -12,8 +12,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => env('APP_URL', ''),
'app_domain' => env('APP_DOMAIN', ''),
'app_version' => '5.0.11',
'minimum_client_version' => '5.0.11',
'app_version' => '5.0.12',
'minimum_client_version' => '5.0.12',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),
'google_maps_api_key' => env('GOOGLE_MAPS_API_KEY'),