Files
verifikator/app/Services/P1Dev/P1DawaiPaymentComparison.php
2026-10-20 10:24:22 +07:00

23 lines
595 B
PHP

<?php
namespace App\Services\P1Dev;
class P1DawaiPaymentComparison
{
public static function reference(?array $dawai, array $local): ?array
{
if ($dawai === null) {
return null;
}
// Use the newest payment ID regardless of whether older amounts match locally.
$latest = null;
foreach ($dawai['riwayat_pembayaran'] ?? [] as $payment) {
if ($latest === null || (int) ($payment['id'] ?? 0) > (int) ($latest['id'] ?? 0)) {
$latest = $payment;
}
}
return $latest ?? $dawai;
}
}