Check if referral payments have been refunded

This commit is contained in:
Hillel Coren 2017-09-14 11:38:54 +03:00
parent 2451baafa0
commit 10fd839c78
2 changed files with 6 additions and 1 deletions

View File

@ -74,7 +74,8 @@ class CalculatePayouts extends Command
$this->info("User: $user"); $this->info("User: $user");
foreach ($client->payments as $payment) { 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");
} }
} }
} }

View File

@ -295,6 +295,10 @@ class Payment extends EntityModel
*/ */
public function getCompletedAmount() public function getCompletedAmount()
{ {
if ($this->isFailed() || $this->isVoided()) {
return 0;
}
return $this->amount - $this->refunded; return $this->amount - $this->refunded;
} }