summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiqdad <ahmadmiqdad27@gmail.com>2025-06-02 08:26:20 +0700
committerMiqdad <ahmadmiqdad27@gmail.com>2025-06-02 08:26:20 +0700
commit04e6162ba44784eb60b1f7122856f5f1a578d16f (patch)
tree7b5ab62e116f7c3a30a3db2ce70230662efa2d5e
parente289a641d11e50fd0f04c3ec4857a44a2d9c7f9d (diff)
<miqdad> fix margin calculation formula
-rwxr-xr-xindoteknik_custom/models/sale_order.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 3c69c3d1..096ffe3a 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -1724,12 +1724,11 @@ class SaleOrder(models.Model):
else:
delivery_amt = 0
- # Net margin = total margin - biaya tambahan
- net_margin = order.total_margin - order.biaya_lain_lain
- denominator = order.amount_untaxed - order.fee_third_party
+ net_margin = order.total_margin - order.fee_third_party - order.biaya_lain_lain
- if denominator > 0:
- order.total_percent_margin = round((net_margin / denominator) * 100, 2)
+
+ if order.amount_untaxed > 0:
+ order.total_percent_margin = round((net_margin / order.amount_untaxed) * 100, 2)
else:
order.total_percent_margin = 0