diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-04-17 15:24:47 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-04-17 15:24:47 +0700 |
| commit | a87e58a2d7bbfb9103c6bb9ca8b17fefeadb3275 (patch) | |
| tree | 9dc6ef94776662a2e81f6c7f77ee397a119e102b | |
| parent | 7856f737e40c39eefa0f27d2247a649c5381d3c3 (diff) | |
margin po
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 5c23b9b8..71ac0655 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -498,9 +498,9 @@ class PurchaseOrder(models.Model): ('order_id', '=', line.sale_id.id) ], limit=1, order='price_reduce_taxexcl') - sum_so_margin += 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 + sum_so_margin = sale_order_line.item_margin * po_line.product_qty + 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: @@ -512,16 +512,16 @@ class PurchaseOrder(models.Model): 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 - self.total_so_margin = 0 - self.total_so_percent_margin = 0 + 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 + self.total_so_margin = 0 + self.total_so_percent_margin = 0 # def compute_total_margin_from_apo(self): # purchase_price_dict = {} @@ -545,8 +545,8 @@ class PurchaseOrder(models.Model): # sum_so_margin += sale_order_line.item_margin - # sales_price = sale_order_line.price_reduce_taxexcl * line.qty_so - # # sales_price = sale_order_line.price_reduce_taxexcl * lines.product_qty + # # sales_price = sale_order_line.price_reduce_taxexcl * line.qty_so + # sales_price = sale_order_line.price_reduce_taxexcl * lines.product_qty # if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': # sales_price -= sale_order_line.delivery_amt_line @@ -569,16 +569,16 @@ class PurchaseOrder(models.Model): # 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 - # self.total_so_margin = 0 - # self.total_so_percent_margin = 0 + # 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 + # self.total_so_margin = 0 + # self.total_so_percent_margin = 0 def compute_amt_total_without_service(self): for order in self: |
