<?php
/** Daily settlement cron — runs at 3am AFTER reconciliation */
require_once __DIR__ . '/../config.php';
require_once __DIR__ . '/../engine/SettlementEngine.php';
require_once __DIR__ . '/../engine/ReconciliationEngine.php';
require_once __DIR__ . '/../engine/BankAdapter.php';

$date   = date('Y-m-d', strtotime('yesterday'));
$result = SettlementEngine::processDate($date);
$status = ($result['success']??false) ? 'OK' : 'FAIL';
echo date('Y-m-d H:i:s') . " Settle $date: $status paid=" . ($result['paid']??0) .
     " failed=" . ($result['failed']??0) . "\n";
