update total invoice

This commit is contained in:
2026-08-05 13:35:26 +07:00
parent 7d349d4efd
commit 0b94af8a26
3 changed files with 14 additions and 4 deletions
+3
View File
@@ -0,0 +1,3 @@
{
"editor.language.colorizedBracketPairs": []
}
+6 -2
View File
@@ -88,12 +88,16 @@ class Generateinvoice extends CI_Controller {
// =========================
$total = (float)$invi['total'];
$this->db->select_sum('sisa_piutang');
// ================= AMBIL TUNGGAKAN =================
$this->db->select_sum('total');
$this->db->select_sum('total_bayar');
$this->db->where('customer_id', $invi['customer_id']);
$this->db->where('status !=', 'paid');
$this->db->where('id !=', $invoice_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);
// Ngambil Data Tunggakan bulan lalu jika ada.
$keteranganlain = 'Akumulasi Tunggakan Invoice Bulan Lalu';
+5 -2
View File
@@ -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;