[Fix] Gross profit validation issue (#12516)
This commit is contained in:
parent
4d4ce3e5cf
commit
60febc5465
@ -6,7 +6,6 @@ import frappe
|
|||||||
from frappe import _, scrub
|
from frappe import _, scrub
|
||||||
from erpnext.stock.utils import get_incoming_rate
|
from erpnext.stock.utils import get_incoming_rate
|
||||||
from erpnext.controllers.queries import get_match_cond
|
from erpnext.controllers.queries import get_match_cond
|
||||||
from erpnext.stock.stock_ledger import get_valuation_rate
|
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
|
|
||||||
|
|
||||||
@ -248,6 +247,7 @@ class GrossProfitGenerator(object):
|
|||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
def get_average_buying_rate(self, row, item_code):
|
def get_average_buying_rate(self, row, item_code):
|
||||||
|
args = row
|
||||||
if not item_code in self.average_buying_rate:
|
if not item_code in self.average_buying_rate:
|
||||||
if item_code in self.non_stock_items:
|
if item_code in self.non_stock_items:
|
||||||
self.average_buying_rate[item_code] = flt(frappe.db.sql("""
|
self.average_buying_rate[item_code] = flt(frappe.db.sql("""
|
||||||
@ -255,14 +255,14 @@ class GrossProfitGenerator(object):
|
|||||||
from `tabPurchase Invoice Item`
|
from `tabPurchase Invoice Item`
|
||||||
where item_code = %s and docstatus=1""", item_code)[0][0])
|
where item_code = %s and docstatus=1""", item_code)[0][0])
|
||||||
else:
|
else:
|
||||||
row.voucher_type = row.parenttype
|
args.update({
|
||||||
row.voucher_no = row.parent
|
'voucher_type': row.parenttype,
|
||||||
average_buying_rate = get_incoming_rate(row)
|
'voucher_no': row.parent,
|
||||||
if not average_buying_rate:
|
'allow_zero_valuation': True,
|
||||||
average_buying_rate = get_valuation_rate(item_code, row.warehouse,
|
'company': self.filters.company
|
||||||
row.parenttype, row.parent, allow_zero_rate=row.allow_zero_valuation,
|
})
|
||||||
currency=self.filters.currency, company=self.filters.company)
|
|
||||||
|
|
||||||
|
average_buying_rate = get_incoming_rate(args)
|
||||||
self.average_buying_rate[item_code] = flt(average_buying_rate)
|
self.average_buying_rate[item_code] = flt(average_buying_rate)
|
||||||
|
|
||||||
return self.average_buying_rate[item_code]
|
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`.brand, `tabSales Invoice Item`.dn_detail,
|
||||||
`tabSales Invoice Item`.delivery_note, `tabSales Invoice Item`.stock_qty as qty,
|
`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`.base_net_rate, `tabSales Invoice Item`.base_net_amount,
|
||||||
`tabSales Invoice Item`.name as "item_row", `tabSales Invoice`.is_return,
|
`tabSales Invoice Item`.name as "item_row", `tabSales Invoice`.is_return
|
||||||
`tabSales Invoice Item`.allow_zero_valuation_rate as "allow_zero_valuation"
|
|
||||||
{sales_person_cols}
|
{sales_person_cols}
|
||||||
from
|
from
|
||||||
`tabSales Invoice` inner join `tabSales Invoice Item`
|
`tabSales Invoice` inner join `tabSales Invoice Item`
|
||||||
|
@ -144,10 +144,9 @@ def get_incoming_rate(args):
|
|||||||
|
|
||||||
if not in_rate:
|
if not in_rate:
|
||||||
voucher_no = args.get('voucher_no') or args.get('name')
|
voucher_no = args.get('voucher_no') or args.get('name')
|
||||||
|
|
||||||
in_rate = get_valuation_rate(args.get('item_code'), args.get('warehouse'),
|
in_rate = get_valuation_rate(args.get('item_code'), args.get('warehouse'),
|
||||||
args.get('voucher_type'), voucher_no, args.get('allow_zero_valuation'),
|
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
|
return in_rate
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user