calculated the rate and total margin

This commit is contained in:
mbauskar 2016-01-18 16:31:10 +05:30 committed by rohitwaghchaure
parent c97becbd15
commit 36b5189163

View File

@ -59,6 +59,10 @@ class calculate_taxes_and_totals(object):
item.rate = flt(item.price_list_rate *
(1.0 - (item.discount_percentage / 100.0)), item.precision("rate"))
if item.doctype in ['Quotation Item', 'Sales Order Item']:
item.total_margin = self.calculate_margin(item)
item.rate = item.total_margin if item.total_margin > 0 else item.rate
item.net_rate = item.rate
item.amount = flt(item.rate * item.qty, item.precision("amount"))
item.net_amount = item.amount
@ -434,4 +438,18 @@ class calculate_taxes_and_totals(object):
self.doc.outstanding_amount = flt(total_amount_to_pay - flt(paid_amount),
self.doc.precision("outstanding_amount"))
elif self.doc.doctype == "Purchase Invoice":
self.doc.outstanding_amount = flt(total_amount_to_pay, self.doc.precision("outstanding_amount"))
self.doc.outstanding_amount = flt(total_amount_to_pay, self.doc.precision("outstanding_amount"))
def calculate_margin(self, item):
total_margin = 0.0
if item.price_list_rate:
if item.pricing_rule:
pricing_rule = frappe.get_doc('Pricing Rule', item.pricing_rule)
if not item.type: item.type = pricing_rule.type
if not item.rate_or_amount: item.rate_or_amount = pricing_rule.rate
if item.type and item.rate_or_amount:
margin_value = item.rate_or_amount if item.type == 'Amount' else flt(item.price_list_rate) * flt(item.rate_or_amount) / 100
total_margin = flt(item.price_list_rate) + flt(margin_value)
return total_margin