diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-07-25 10:02:38 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-07-25 10:02:38 +0700 |
| commit | c0a913efe390bad9dde397dd1627b3baf682a8f9 (patch) | |
| tree | bb4bea0ffc0cd96d735126385af9d1cec364543c | |
| parent | 3a571c8004c9a1efc8e4a049b0d1e81b300ed4c9 (diff) | |
margin po
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 0321c1bd..c6512772 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -637,25 +637,29 @@ class PurchaseOrder(models.Model): ('order_id', '=', line.sale_id.id) ], limit=1, order='price_reduce_taxexcl') - sum_so_margin += line.qty_po / line.qty_so * sale_order_line.item_margin - # sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty - sales_price = sale_order_line.price_reduce_taxexcl * po_line.product_qty - if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': - sales_price -= sale_order_line.delivery_amt_line - if sale_order_line.order_id.fee_third_party > 0: - sales_price -= sale_order_line.fee_third_party_line - sum_sales_price += sales_price - purchase_price = po_line.price_subtotal - if line.purchase_order_id.delivery_amount > 0: - purchase_price += po_line.delivery_amt_line - real_item_margin = sales_price - purchase_price - sum_margin += real_item_margin + if sale_order_line and po_line: + so_margin = (line.qty_po / line.qty_so) * sale_order_line.item_margin + sum_so_margin += so_margin + + sales_price = sale_order_line.price_reduce_taxexcl * line.qty_po + if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': + sales_price -= (sale_order_line.delivery_amt_line / sale_order_line.product_uom_qty) * line.qty_po + if sale_order_line.order_id.fee_third_party > 0: + sales_price -= (sale_order_line.fee_third_party_line / sale_order_line.product_uom_qty) * line.qty_po + sum_sales_price += sales_price + + purchase_price = po_line.price_subtotal / po_line.product_qty * line.qty_po + if line.purchase_order_id.delivery_amount > 0: + purchase_price += (po_line.delivery_amt_line / po_line.product_qty) * line.qty_po + real_item_margin = sales_price - purchase_price + sum_margin += real_item_margin if sum_so_margin != 0 and sum_sales_price != 0 and sum_margin != 0: self.total_so_margin = sum_so_margin self.total_so_percent_margin = round((sum_so_margin / sum_sales_price), 2) * 100 self.total_margin = sum_margin self.total_percent_margin = round((sum_margin / sum_sales_price), 2) * 100 + else: self.total_margin = 0 self.total_percent_margin = 0 |
