[Fix] Gross profit validation issue (#12516)

This commit is contained in:
rohitwaghchaure 2018-01-17 14:40:59 +05:30 committed by Nabin Hait
parent 4d4ce3e5cf
commit 60febc5465
2 changed files with 10 additions and 12 deletions

View File

@ -6,7 +6,6 @@ import frappe
from frappe import _, scrub
from erpnext.stock.utils import get_incoming_rate
from erpnext.controllers.queries import get_match_cond
from erpnext.stock.stock_ledger import get_valuation_rate
from frappe.utils import flt
@ -248,6 +247,7 @@ class GrossProfitGenerator(object):
return 0.0
def get_average_buying_rate(self, row, item_code):
args = row
if not item_code in self.average_buying_rate:
if item_code in self.non_stock_items:
self.average_buying_rate[item_code] = flt(frappe.db.sql("""
@ -255,14 +255,14 @@ class GrossProfitGenerator(object):
from `tabPurchase Invoice Item`
where item_code = %s and docstatus=1""", item_code)[0][0])
else:
row.voucher_type = row.parenttype
row.voucher_no = row.parent
average_buying_rate = get_incoming_rate(row)
if not average_buying_rate:
average_buying_rate = get_valuation_rate(item_code, row.warehouse,
row.parenttype, row.parent, allow_zero_rate=row.allow_zero_valuation,
currency=self.filters.currency, company=self.filters.company)
args.update({
'voucher_type': row.parenttype,
'voucher_no': row.parent,
'allow_zero_valuation': True,
'company': self.filters.company
})
average_buying_rate = get_incoming_rate(args)
self.average_buying_rate[item_code] = flt(average_buying_rate)
return self.average_buying_rate[item_code]
@ -311,8 +311,7 @@ class GrossProfitGenerator(object):
`tabSales Invoice Item`.brand, `tabSales Invoice Item`.dn_detail,
`tabSales Invoice Item`.delivery_note, `tabSales Invoice Item`.stock_qty as qty,
`tabSales Invoice Item`.base_net_rate, `tabSales Invoice Item`.base_net_amount,
`tabSales Invoice Item`.name as "item_row", `tabSales Invoice`.is_return,
`tabSales Invoice Item`.allow_zero_valuation_rate as "allow_zero_valuation"
`tabSales Invoice Item`.name as "item_row", `tabSales Invoice`.is_return
{sales_person_cols}
from
`tabSales Invoice` inner join `tabSales Invoice Item`

View File

@ -144,10 +144,9 @@ def get_incoming_rate(args):
if not in_rate:
voucher_no = args.get('voucher_no') or args.get('name')
in_rate = get_valuation_rate(args.get('item_code'), args.get('warehouse'),
args.get('voucher_type'), voucher_no, args.get('allow_zero_valuation'),
currency=erpnext.get_company_currency(args.get('company')))
currency=erpnext.get_company_currency(args.get('company')), company=args.get('company'))
return in_rate