fix: Remove base_rate and buying_rate for Invoice rows

This commit is contained in:
GangaManoj
2021-08-25 00:33:55 +05:30
parent 8478a83148
commit 7ef5952176

View File

@@ -197,7 +197,7 @@ class GrossProfitGenerator(object):
row.buying_rate = flt(row.buying_amount / flt(row.qty), self.float_precision)
row.base_rate = flt(row.base_amount / flt(row.qty), self.float_precision)
else:
if self.filters.get("group_by") != "Invoice":
if self.is_not_invoice_row(row):
row.buying_rate, row.base_rate = 0.0, 0.0
# calculate gross profit
@@ -244,14 +244,17 @@ class GrossProfitGenerator(object):
for returned_item_row in returned_item_rows:
row.qty += flt(returned_item_row.qty)
row.base_amount += flt(returned_item_row.base_amount, self.currency_precision)
row.buying_amount = flt(flt(row.qty) * row.buying_rate, self.currency_precision)
if flt(row.qty) or row.base_amount:
row.buying_amount = flt(flt(row.qty) * flt(row.buying_rate), self.currency_precision)
if (flt(row.qty) or row.base_amount) and self.is_not_invoice_row(row):
row = self.set_average_rate(row)
self.grouped_data.append(row)
self.add_to_totals(row)
self.set_average_gross_profit(self.totals)
self.grouped_data.append(self.totals)
def is_not_invoice_row(self, row):
return (self.filters.get("group_by") == "Invoice" and row.indent != 0.0) or self.filters.get("group_by") != "Invoice"
def set_average_rate(self, new_row):
self.set_average_gross_profit(new_row)
new_row.buying_rate = flt(new_row.buying_amount / new_row.qty, self.float_precision) if new_row.qty else 0
@@ -451,8 +454,7 @@ class GrossProfitGenerator(object):
'item_row': None,
'is_return': row.is_return,
'cost_center': row.cost_center,
'base_net_amount': frappe.db.get_value('Sales Invoice', row.parent, 'base_net_total'),
'base_rate': None
'base_net_amount': frappe.db.get_value('Sales Invoice', row.parent, 'base_net_total')
})
self.si_list.insert(index, invoice)