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(); ; }