19 lines
347 B
PHP
19 lines
347 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Services;
|
||
|
|
||
|
use App\Models\Payment;
|
||
|
|
||
|
class PaymentService
|
||
|
{
|
||
|
public function distributePayments()
|
||
|
{
|
||
|
|
||
|
$payments = Payment::where('unapplied_amount', '>', 0)->get();
|
||
|
|
||
|
foreach ($payments as $payment) {
|
||
|
$payment->applyToInvoices(); // Apply remaining amounts to the new invoice
|
||
|
}
|
||
|
}
|
||
|
}
|