summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorHafidBuroiroh <hafidburoiroh09@gmail.com>2026-01-30 18:19:30 +0700
committerHafidBuroiroh <hafidburoiroh09@gmail.com>2026-01-30 18:19:30 +0700
commit48e48a61a6fc0addcc1e0c3590ca8582abe66a6a (patch)
treec943c26348d7478819032a156e2e2eb7849a4f54 /indoteknik_custom/models
parent4ac8b06616a0dce80029e1063078b31b6100084e (diff)
<hafid> refund kebutuhan BA dan cahsback
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/refund_sale_order.py6
-rw-r--r--indoteknik_custom/models/sale_order_line.py48
2 files changed, 28 insertions, 26 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):