diff --git a/app/Console/Commands/CalculatePayouts.php b/app/Console/Commands/CalculatePayouts.php index 869783dc8ad3..673b1d89f869 100644 --- a/app/Console/Commands/CalculatePayouts.php +++ b/app/Console/Commands/CalculatePayouts.php @@ -74,7 +74,8 @@ class CalculatePayouts extends Command $this->info("User: $user"); foreach ($client->payments as $payment) { - $this->info("Date: $payment->payment_date, Amount: $payment->amount, Reference: $payment->transaction_reference"); + $amount = $payment->getCompletedAmount(); + $this->info("Date: $payment->payment_date, Amount: $amount, Reference: $payment->transaction_reference"); } } } diff --git a/app/Models/Payment.php b/app/Models/Payment.php index e1556b7d6046..0fc6da08eda2 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -295,6 +295,10 @@ class Payment extends EntityModel */ public function getCompletedAmount() { + if ($this->isFailed() || $this->isVoided()) { + return 0; + } + return $this->amount - $this->refunded; }