<?php
// Legacy supplier statement body now delegates to the unified party statement renderer.
// This keeps old routes working while preserving the same print settings/CSS behavior.
$role = 'supplier';
$party = is_array($party ?? null) ? $party : (is_array($supplier ?? null) ? $supplier : []);
$filters = is_array($filters ?? null) ? $filters : ['from' => $from ?? '', 'to' => $to ?? ''];

$running = (float)($opening ?? 0);
$totalDebit = 0.0;
$totalCredit = 0.0;
foreach (($rows ?? []) as $statementRow) {
    $totalDebit += (float)($statementRow['debit'] ?? 0);
    $totalCredit += (float)($statementRow['credit'] ?? 0);
    $running += (float)($statementRow['debit'] ?? 0) - (float)($statementRow['credit'] ?? 0);
}
$closing = $closing ?? $running;
$totals = is_array($totals ?? null) ? $totals : ['debit' => $totalDebit, 'credit' => $totalCredit, 'closing' => $closing];

require __DIR__ . '/party_statement.php';
