mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 21:59:13 +00:00
fix: Remove qty from Sales Invoice rows
This commit is contained in:
@@ -193,11 +193,12 @@ class GrossProfitGenerator(object):
|
|||||||
buying_amount = 0
|
buying_amount = 0
|
||||||
|
|
||||||
# get buying rate
|
# get buying rate
|
||||||
if row.qty:
|
if flt(row.qty):
|
||||||
row.buying_rate = flt(row.buying_amount / row.qty, self.float_precision)
|
row.buying_rate = flt(row.buying_amount / flt(row.qty), self.float_precision)
|
||||||
row.base_rate = flt(row.base_amount / row.qty, self.float_precision)
|
row.base_rate = flt(row.base_amount / flt(row.qty), self.float_precision)
|
||||||
else:
|
else:
|
||||||
row.buying_rate, row.base_rate = 0.0, 0.0
|
if self.filters.get("group_by") != "Invoice":
|
||||||
|
row.buying_rate, row.base_rate = 0.0, 0.0
|
||||||
|
|
||||||
# calculate gross profit
|
# calculate gross profit
|
||||||
row.gross_profit = flt(row.base_amount - row.buying_amount, self.currency_precision)
|
row.gross_profit = flt(row.base_amount - row.buying_amount, self.currency_precision)
|
||||||
@@ -229,7 +230,7 @@ class GrossProfitGenerator(object):
|
|||||||
if i==0:
|
if i==0:
|
||||||
new_row = row
|
new_row = row
|
||||||
else:
|
else:
|
||||||
new_row.qty += row.qty
|
new_row.qty += flt(row.qty)
|
||||||
new_row.buying_amount += flt(row.buying_amount, self.currency_precision)
|
new_row.buying_amount += flt(row.buying_amount, self.currency_precision)
|
||||||
new_row.base_amount += flt(row.base_amount, self.currency_precision)
|
new_row.base_amount += flt(row.base_amount, self.currency_precision)
|
||||||
new_row = self.set_average_rate(new_row)
|
new_row = self.set_average_rate(new_row)
|
||||||
@@ -241,10 +242,10 @@ class GrossProfitGenerator(object):
|
|||||||
and row.item_code in self.returned_invoices[row.parent]:
|
and row.item_code in self.returned_invoices[row.parent]:
|
||||||
returned_item_rows = self.returned_invoices[row.parent][row.item_code]
|
returned_item_rows = self.returned_invoices[row.parent][row.item_code]
|
||||||
for returned_item_row in returned_item_rows:
|
for returned_item_row in returned_item_rows:
|
||||||
row.qty += returned_item_row.qty
|
row.qty += flt(returned_item_row.qty)
|
||||||
row.base_amount += flt(returned_item_row.base_amount, self.currency_precision)
|
row.base_amount += flt(returned_item_row.base_amount, self.currency_precision)
|
||||||
row.buying_amount = flt(row.qty * row.buying_rate, self.currency_precision)
|
row.buying_amount = flt(flt(row.qty) * row.buying_rate, self.currency_precision)
|
||||||
if row.qty or row.base_amount:
|
if flt(row.qty) or row.base_amount:
|
||||||
row = self.set_average_rate(row)
|
row = self.set_average_rate(row)
|
||||||
self.grouped_data.append(row)
|
self.grouped_data.append(row)
|
||||||
self.add_to_totals(row)
|
self.add_to_totals(row)
|
||||||
@@ -261,6 +262,8 @@ class GrossProfitGenerator(object):
|
|||||||
new_row.gross_profit = flt(new_row.base_amount - new_row.buying_amount, self.currency_precision)
|
new_row.gross_profit = flt(new_row.base_amount - new_row.buying_amount, self.currency_precision)
|
||||||
new_row.gross_profit_percent = flt(((new_row.gross_profit / new_row.base_amount) * 100.0), self.currency_precision) \
|
new_row.gross_profit_percent = flt(((new_row.gross_profit / new_row.base_amount) * 100.0), self.currency_precision) \
|
||||||
if new_row.base_amount else 0
|
if new_row.base_amount else 0
|
||||||
|
new_row.buying_rate = flt(new_row.buying_amount / flt(new_row.qty), self.float_precision) if flt(new_row.qty) else 0
|
||||||
|
new_row.base_rate = flt(new_row.base_amount / flt(new_row.qty), self.float_precision) if flt(new_row.qty) else 0
|
||||||
|
|
||||||
def add_to_totals(self, new_row):
|
def add_to_totals(self, new_row):
|
||||||
for key in self.totals:
|
for key in self.totals:
|
||||||
@@ -444,11 +447,12 @@ class GrossProfitGenerator(object):
|
|||||||
'brand': None,
|
'brand': None,
|
||||||
'dn_detail': None,
|
'dn_detail': None,
|
||||||
'delivery_note': None,
|
'delivery_note': None,
|
||||||
'qty': 0,
|
'qty': None,
|
||||||
'item_row': None,
|
'item_row': None,
|
||||||
'is_return': row.is_return,
|
'is_return': row.is_return,
|
||||||
'cost_center': row.cost_center,
|
'cost_center': row.cost_center,
|
||||||
'base_net_amount': 0
|
'base_net_amount': 0,
|
||||||
|
'base_rate': None
|
||||||
})
|
})
|
||||||
|
|
||||||
self.si_list.insert(index, invoice)
|
self.si_list.insert(index, invoice)
|
||||||
@@ -466,30 +470,8 @@ class GrossProfitGenerator(object):
|
|||||||
|
|
||||||
# self.si_list[parents_index-1].base_net_amount += row.base_net_amount
|
# self.si_list[parents_index-1].base_net_amount += row.base_net_amount
|
||||||
|
|
||||||
# print("\n\n\n\n\nRow Details: ", index, ". ", row.parent, ": ", row.base_net_amount)
|
if frappe.db.exists('Product Bundle', row.item_code):
|
||||||
# print("Ind details: ", parents_index-1, ": ", self.si_list[parents_index-1].base_net_amount, "\n\n\n")
|
self.add_bundle_items(row, index)
|
||||||
|
|
||||||
if frappe.db.exists('Product Bundle', row.item_code):
|
|
||||||
self.add_bundle_items(row, index)
|
|
||||||
|
|
||||||
base_net_amount = 0
|
|
||||||
for row in reversed(self.si_list):
|
|
||||||
if row.indent == 1.0:
|
|
||||||
base_net_amount += row.get('base_net_amount')
|
|
||||||
|
|
||||||
elif row.indent == 0.0:
|
|
||||||
row.base_net_amount = base_net_amount
|
|
||||||
base_net_amount = 0
|
|
||||||
|
|
||||||
# print("\n"*10)
|
|
||||||
# for index, row in enumerate(self.si_list):
|
|
||||||
# if row.indent == 0.0:
|
|
||||||
# print(index, ". ", row.parent, ": ", row.base_net_amount)
|
|
||||||
# elif row.indent == 1.0:
|
|
||||||
# print("\t", index, ". ", row.parent, ": ", row.base_net_amount)
|
|
||||||
# elif row.indent == 2.0:
|
|
||||||
# print("\t\t", index, ". ", row.parent, ": ", row.base_net_amount)
|
|
||||||
# print("")
|
|
||||||
|
|
||||||
def add_bundle_items(self, product_bundle, index):
|
def add_bundle_items(self, product_bundle, index):
|
||||||
bundle_items = frappe.get_all(
|
bundle_items = frappe.get_all(
|
||||||
@@ -518,7 +500,7 @@ class GrossProfitGenerator(object):
|
|||||||
'brand': frappe.db.get_value('Item', item.item_code, 'brand'),
|
'brand': frappe.db.get_value('Item', item.item_code, 'brand'),
|
||||||
'dn_detail': product_bundle.dn_detail,
|
'dn_detail': product_bundle.dn_detail,
|
||||||
'delivery_note': product_bundle.delivery_note,
|
'delivery_note': product_bundle.delivery_note,
|
||||||
'qty': (product_bundle.qty * item.qty),
|
'qty': (flt(product_bundle.qty) * flt(item.qty)),
|
||||||
'item_row': None,
|
'item_row': None,
|
||||||
'is_return': product_bundle.is_return,
|
'is_return': product_bundle.is_return,
|
||||||
'cost_center': product_bundle.cost_center
|
'cost_center': product_bundle.cost_center
|
||||||
|
|||||||
Reference in New Issue
Block a user