update total invoice
This commit is contained in:
@@ -510,12 +510,15 @@ class Invoices extends CI_Controller {
|
||||
}
|
||||
|
||||
// ================= AMBIL TUNGGAKAN =================
|
||||
$this->db->select_sum('sisa_piutang');
|
||||
$this->db->select_sum('total');
|
||||
$this->db->select_sum('total_bayar');
|
||||
$this->db->where('customer_id', $data->customer_id);
|
||||
$this->db->where('status !=', 'paid');
|
||||
$this->db->where('id !=', $id); // exclude invoice sekarang
|
||||
|
||||
$tunggakan = $this->db->get('invoices')->row()->sisa_piutang ?? 0;
|
||||
$row = $this->db->get('invoices')->row();
|
||||
|
||||
$tunggakan = ($row->total ?? 0) - ($row->total_bayar ?? 0);
|
||||
|
||||
// ================= MASUKKAN KE DATA =================
|
||||
$data->tunggakan = (int)$tunggakan;
|
||||
|
||||
Reference in New Issue
Block a user