From d2bb21ae878db2a3b77dbb3341046c9d12ba1de5 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 20 Sep 2024 14:12:00 +0700 Subject: add grand total on dunning run and bill receipt --- indoteknik_custom/models/bill_receipt.py | 10 +++++++++- indoteknik_custom/models/dunning_run.py | 9 ++++++++- indoteknik_custom/views/bill_receipt.xml | 2 ++ indoteknik_custom/views/dunning_run.xml | 2 ++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/bill_receipt.py b/indoteknik_custom/models/bill_receipt.py index 76449c1f..7d38d5ad 100644 --- a/indoteknik_custom/models/bill_receipt.py +++ b/indoteknik_custom/models/bill_receipt.py @@ -22,8 +22,16 @@ class BillReceipt(models.Model): resi_tukar_faktur = fields.Char(string='Resi Faktur') date_terima_tukar_faktur = fields.Date(string='Terima Faktur') shipper_faktur_id = fields.Many2one('delivery.carrier', string='Shipper Faktur') - is_validated = fields.Boolean(string='Validated') + is_validated = fields.Boolean(string='Validated') notification = fields.Char(string='Notification') + grand_total = fields.Float(string='Grand Total', compute="_compute_grand_total") + + def _compute_grand_total(self): + for record in self: + grand_total = 0 + for line in record.bill_line: + grand_total += line.total_amt + record.grand_total = grand_total def copy_date_faktur(self): if not self.is_validated: diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index 90159cd0..c167aab7 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -30,7 +30,14 @@ class DunningRun(models.Model): is_paid = fields.Boolean(string='Paid') description = fields.Char(string='Description') comment = fields.Char(string='Comment') - + grand_total = fields.Float(string='Grand Total', compute="_compute_grand_total") + + def _compute_grand_total(self): + for record in self: + grand_total = 0 + for line in record.dunning_line: + grand_total += line.total_amt + record.grand_total = grand_total def copy_date_faktur(self): if not self.is_validated: diff --git a/indoteknik_custom/views/bill_receipt.xml b/indoteknik_custom/views/bill_receipt.xml index 15d82e7b..02b28ddf 100644 --- a/indoteknik_custom/views/bill_receipt.xml +++ b/indoteknik_custom/views/bill_receipt.xml @@ -13,6 +13,7 @@ + @@ -69,6 +70,7 @@ + diff --git a/indoteknik_custom/views/dunning_run.xml b/indoteknik_custom/views/dunning_run.xml index dd5bb120..522be8c9 100644 --- a/indoteknik_custom/views/dunning_run.xml +++ b/indoteknik_custom/views/dunning_run.xml @@ -13,6 +13,7 @@ + @@ -71,6 +72,7 @@ + -- cgit v1.2.3