23 lines
595 B
PHP
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;
|
|
}
|
|
}
|