From 61c3a3f57ee8c6d3eac9433388bc5dc795cfa3bc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 7 Jul 2020 17:56:30 +1000 Subject: [PATCH] Working on check data script --- app/Console/Commands/CheckData.php | 2 +- app/Models/Invoice.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 34744782fa82..3e8b3ff3aa70 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -357,7 +357,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'); diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 9500cbf62986..50cffcfd250b 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -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(); ; }