Changeset View
Changeset View
Standalone View
Standalone View
src/app/Wallet.php
Show First 20 Lines • Show All 737 Lines • ▼ Show 20 Lines | protected function balanceUpdate(string $type, int|Payment $amount, $description = null, array $eTIDs = []) | ||||
]); | ]); | ||||
if (!empty($eTIDs)) { | if (!empty($eTIDs)) { | ||||
Transaction::whereIn('id', $eTIDs)->update(['transaction_id' => $transaction->id]); | Transaction::whereIn('id', $eTIDs)->update(['transaction_id' => $transaction->id]); | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | |||||
* Ensure that this wallet has a positive balance and a minimum number of payments, | |||||
* or a 100% discount (in which case there are no payments). | |||||
* | |||||
* @return bool | |||||
*/ | |||||
public function hasMinimumBalanceAndPayments($minimumPayments = 2): bool | |||||
machniak: The argument is not documented. And maybe it should be `$minPaymentsCount`. | |||||
{ | |||||
if ($this->discount && $this->discount->discount == 100) { | |||||
return true; | |||||
} | |||||
if ($this->balance > 0) { | |||||
$payments = $this->payments()->where('amount', '>', 0)->where('status', 'paid'); | |||||
if ($payments->count() >= $minimumPayments) { | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
} | } |
The argument is not documented. And maybe it should be $minPaymentsCount.