From 48e48a61a6fc0addcc1e0c3590ca8582abe66a6a Mon Sep 17 00:00:00 2001 From: HafidBuroiroh Date: Fri, 30 Jan 2026 18:19:30 +0700 Subject: refund kebutuhan BA dan cahsback --- indoteknik_custom/models/refund_sale_order.py | 6 +--- indoteknik_custom/models/sale_order_line.py | 48 +++++++++++++++------------ indoteknik_custom/views/sale_order.xml | 2 +- indoteknik_custom/views/x_manufactures.xml | 2 +- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/indoteknik_custom/models/refund_sale_order.py b/indoteknik_custom/models/refund_sale_order.py index c3b7a356..7a219130 100644 --- a/indoteknik_custom/models/refund_sale_order.py +++ b/indoteknik_custom/models/refund_sale_order.py @@ -456,11 +456,7 @@ class RefundSaleOrder(models.Model): raise UserError("❌ Refund multi SO hanya bisa 1 kali.") vals['remaining_refundable'] = 0.0 elif so_ids and len(so_ids) == 1 and refund_type != 'salah_transfer': - remaining = 0.0 - if refund_type == 'berita_acara': - vals['remaining_refundable'] = vals['uang_masuk'] - amount_refund - else: - vals['remaining_refundable'] = remaining + remaining = vals['uang_masuk'] - amount_refund if remaining < 0: raise ValidationError("❌ Tidak ada sisa transaksi untuk di-refund di SO ini. Semua dana sudah dikembalikan.") vals['remaining_refundable'] = remaining diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 55bea22c..270fc842 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -167,8 +167,8 @@ class SaleOrderLine(models.Model): if line.purchase_tax_id.price_include: purchase_price = line.purchase_price / (1 + (line.purchase_tax_id.amount / 100)) - # if line.amount_cashback > 0: - # purchase_price = purchase_price - line.amount_cashback + if line.amount_cashback > 0: + purchase_price = purchase_price - line.amount_cashback purchase_price = purchase_price * line.product_uom_qty margin_per_item = sales_price - purchase_price @@ -192,6 +192,9 @@ class SaleOrderLine(models.Model): if line.purchase_tax_id and line.purchase_tax_id.price_include: purchase_price = line.purchase_price / (1 + (line.purchase_tax_id.amount / 100)) + if line.amount_cashback > 0: + purchase_price = purchase_price - line.amount_cashback + purchase_price = purchase_price * line.product_uom_qty margin_before = sales_price - purchase_price @@ -221,8 +224,8 @@ class SaleOrderLine(models.Model): if line.purchase_tax_id.price_include: purchase_price = line.purchase_price / (1 + (line.purchase_tax_id.amount / 100)) - # if line.amount_cashback > 0: - # purchase_price = purchase_price - line.amount_cashback + if line.amount_cashback > 0: + purchase_price = purchase_price - line.amount_cashback purchase_price = purchase_price * line.product_uom_qty margin_per_item = sales_price - purchase_price @@ -250,33 +253,36 @@ class SaleOrderLine(models.Model): if line.purchase_tax_id.price_include: purchase_price = line.purchase_price / (1 + (line.purchase_tax_id.amount / 100)) + if line.amount_cashback > 0: + purchase_price = purchase_price - line.amount_cashback + purchase_price = purchase_price * line.product_uom_qty margin_per_item = sales_price - purchase_price line.item_before_margin = margin_per_item - # def _compute_cashback_brand(self): - # for line in self: - # line.amount_cashback = 0 + def _compute_cashback_brand(self): + for line in self: + line.amount_cashback = 0 - # if not line.product_id: - # continue + if not line.product_id: + continue - # cashback_percent = line.product_id.x_manufacture.cashback_percent or 0 - # if cashback_percent <= 0: - # continue + cashback_percent = line.product_id.x_manufacture.cashback_percent or 0 + if cashback_percent <= 0: + continue - # price, taxes, vendor = self._get_purchase_price(line.product_id) + price, taxes, vendor = self._get_purchase_price(line.product_id) - # price_tax_excl = price + price_tax_excl = price - # if taxes: - # tax = self.env['account.tax'].browse(taxes) - # if tax.price_include: - # price_tax_excl = price / (1 + (tax.amount / 100)) - # else: - # price_tax_excl = price + if taxes: + tax = self.env['account.tax'].browse(taxes) + if tax.price_include: + price_tax_excl = price / (1 + (tax.amount / 100)) + else: + price_tax_excl = price - # line.amount_cashback = price_tax_excl * cashback_percent + line.amount_cashback = price_tax_excl * cashback_percent # @api.onchange('vendor_id') # def onchange_vendor_id(self): diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 7a517ca7..c3df92ec 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -302,7 +302,7 @@ ] } "/> - + - + -- cgit v1.2.3