topnotch_website/app/Services/PaymentService.php
2025-01-29 12:30:54 -08:00

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
}
}
}