mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 02:54:36 -04:00
Allow draft credits to be used in payments
This commit is contained in:
parent
912d0aebc5
commit
17b1119466
@ -46,10 +46,9 @@ class ValidCreditsPresentRule implements Rule
|
|||||||
|
|
||||||
if (request()->input('credits') && is_array(request()->input('credits'))) {
|
if (request()->input('credits') && is_array(request()->input('credits'))) {
|
||||||
$credit_collection = Credit::whereIn('id', $this->transformKeys(array_column(request()->input('credits'), 'credit_id')))
|
$credit_collection = Credit::whereIn('id', $this->transformKeys(array_column(request()->input('credits'), 'credit_id')))
|
||||||
->where('balance', '>', 0)
|
->count();
|
||||||
->get();
|
|
||||||
|
|
||||||
return $credit_collection->count() == count(request()->input('credits'));
|
return $credit_collection == count(request()->input('credits'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -156,6 +156,7 @@ class PaymentRepository extends BaseRepository {
|
|||||||
$credit = Credit::withTrashed()->find($this->decodePrimaryKey($paid_credit['credit_id']));
|
$credit = Credit::withTrashed()->find($this->decodePrimaryKey($paid_credit['credit_id']));
|
||||||
|
|
||||||
if ($credit) {
|
if ($credit) {
|
||||||
|
$credit = $credit->service()->markSent()->save();
|
||||||
ApplyCreditPayment::dispatchNow($credit, $payment, $paid_credit['amount'], $credit->company);
|
ApplyCreditPayment::dispatchNow($credit, $payment, $paid_credit['amount'], $credit->company);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user