<?php
require_once __DIR__.'/../includes/functions.php';
require_once __DIR__.'/../includes/v292_admin_portal_helpers.php';
$admin=require_admin(); mj292_ensure_schema();
$adminTitle='Finance Reconciliation'; $adminSubtitle='Cross-check invoice paid amount, receipt amount, payment approval, wallet debit and open invoice total.';
$stats=mj292_admin_stats(); $checks=mj292_finance_checks(true);
include __DIR__.'/_header.php';
?>
<?php mj292_quick_cards([
 ['Invoice Paid Amount','Paid/approved invoices','report-invoices.php?status=paid', mj292_money0($stats['invoice_paid_amount'],'SGD'), 'success','fas fa-file-invoice'],
 ['Receipt Amount','Generated receipts','report-receipts.php', mj292_money0($stats['receipt_amount'],'SGD'), 'info','fas fa-receipt'],
 ['Wallet Debit','Wallet invoice payments','report-wallets.php', mj292_money0($stats['wallet_debit'],'SGD'), 'warning','fas fa-wallet'],
 ['Wallet Credit','Top-up/admin credit','report-wallets.php', mj292_money0($stats['wallet_credit'],'SGD'), 'primary','fas fa-plus-circle'],
]); ?>
<div class="card mj-v292-card"><div class="card-header"><h3 class="card-title">Mismatch Checks</h3></div><div class="card-body">
<?php if(!$checks): ?><div class="alert alert-success mb-0"><i class="fas fa-check-circle mr-1"></i>No finance mismatch found.</div><?php else: foreach($checks as $c): ?><a class="mj-v292-action" href="<?=e($c['url'])?>"><span><b><?=e($c['title'])?></b><br><small><?=e($c['message'])?></small></span><span class="badge badge-danger">Check</span></a><?php endforeach; endif; ?>
</div></div>
<?php include __DIR__.'/_footer.php'; ?>
