{{-- Báo cáo thu & duyệt chi (/chart-pay) - nạp lại bằng AJAX khi lọc (#gridForm). Bố cục đồng bộ màn /statistics (.crm-stats trong public/css/crm-2026/statistics.css): 3 thẻ KPI (Thực thu / Tổng chi / Còn lại) -> biểu đồ cơ cấu -> duyệt chi theo chi nhánh. --}} @php // Giữ nguyên công thức của giao diện cũ. Bản cũ dùng @number_format(...) nên khoá nào controller không trả // (vd 'used', 'wallet_payment') được coi là 0 -> chuẩn hoá tương tự để không lỗi "Undefined index". $data = array_merge(['payment' => 0, 'wallet_payment' => 0, 'used' => 0], (array) $data); $list_payment = array_merge(['money' => 0, 'CK' => 0, 'card' => 0], (array) $list_payment); $list_pay = array_merge(['money' => 0, 'CK' => 0, 'card' => 0], (array) $list_pay); $actualIncome = $data['payment'] + $data['wallet_payment'] - $data['used']; $totalPay = $list_pay['money'] + $list_pay['CK'] + $list_pay['card']; $remaining = $actualIncome - $totalPay; $payRate = $actualIncome > 0 ? round($totalPay / $actualIncome * 100, 1) : 0; @endphp