{{-- 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
Thực thu
{{ number_format($actualIncome) }}VNĐ
  • Tiền mặt{{ number_format($list_payment['money']) }}
  • Chuyển khoản{{ number_format($list_payment['CK']) }}
  • Thẻ{{ number_format($list_payment['card']) }}
Tổng chi
{{ number_format($totalPay) }}VNĐ
  • Tiền mặt{{ number_format($list_pay['money']) }}
  • Chuyển khoản{{ number_format($list_pay['CK']) }}
  • Tỷ lệ chi / thực thu{{ $payRate }}%
Còn lại
{{ number_format($remaining) }}VNĐ
  • Tiền mặt{{ number_format($list_payment['money'] - $list_pay['money']) }}
  • Chuyển khoản{{ number_format($list_payment['CK'] - $list_pay['CK']) }}
  • Thẻ{{ number_format($list_payment['card'] - $list_pay['card']) }}
{{-- Biểu đồ (vẽ bằng public/js/crm-charts.js vào đúng các id bên dưới) --}}
{{-- Biểu đồ Chart.js (thay Google Charts): duyệt chi theo danh mục / trạng thái / chi nhánh --}}