diff --git a/app/Http/Controllers/Admin/PlatformOrderController.php b/app/Http/Controllers/Admin/PlatformOrderController.php index ca40fa0..381313a 100644 --- a/app/Http/Controllers/Admin/PlatformOrderController.php +++ b/app/Http/Controllers/Admin/PlatformOrderController.php @@ -471,10 +471,16 @@ class PlatformOrderController extends Controller $tol = (float) config('saasshop.amounts.tolerance', 0.01); + $tolCents = (int) round($tol * 100); + $tolCents = max(1, $tolCents); + $deltaCents = (int) round($delta * 100); + $reconcileMismatch = $receiptTotal > 0 && abs($deltaCents) >= $tolCents; + fputcsv($out, ['receipt_total', number_format($receiptTotal, 2, '.', '')]); fputcsv($out, ['refund_total', number_format($refundTotal, 2, '.', '')]); fputcsv($out, ['reconcile_delta', number_format($delta, 2, '.', '')]); fputcsv($out, ['amount_tolerance', number_format($tol, 2, '.', '')]); + fputcsv($out, ['reconcile_mismatch', $reconcileMismatch ? '1' : '0']); fputcsv($out, ['placed_at', (string) (optional($order->placed_at)->format('Y-m-d H:i:s') ?? '')]); fputcsv($out, ['paid_at', (string) (optional($order->paid_at)->format('Y-m-d H:i:s') ?? '')]); diff --git a/tests/Feature/AdminPlatformOrderExportLedgerTest.php b/tests/Feature/AdminPlatformOrderExportLedgerTest.php index b0e3c72..0a674a2 100644 --- a/tests/Feature/AdminPlatformOrderExportLedgerTest.php +++ b/tests/Feature/AdminPlatformOrderExportLedgerTest.php @@ -114,6 +114,7 @@ class AdminPlatformOrderExportLedgerTest extends TestCase $this->assertStringContainsString('refund_total,1.00', $content2); $this->assertStringContainsString('reconcile_delta,10.00', $content2); $this->assertStringContainsString('amount_tolerance,0.01', $content2); + $this->assertStringContainsString('reconcile_mismatch,1', $content2); } public function test_show_page_should_render_export_ledger_link(): void