Merge pull request #38528 from frappe/mergify/bp/version-15-hotfix/pr-38525
fix: multiple minor fixes in report and Exchange Rate Revaluation (backport #38525)
This commit is contained in:
commit
5b1e7666c2
@ -214,7 +214,7 @@ class ExchangeRateRevaluation(Document):
|
|||||||
# round off balance based on currency precision
|
# round off balance based on currency precision
|
||||||
# and consider debit-credit difference allowance
|
# and consider debit-credit difference allowance
|
||||||
currency_precision = get_currency_precision()
|
currency_precision = get_currency_precision()
|
||||||
rounding_loss_allowance = float(rounding_loss_allowance) or 0.05
|
rounding_loss_allowance = float(rounding_loss_allowance)
|
||||||
for acc in account_details:
|
for acc in account_details:
|
||||||
acc.balance_in_account_currency = flt(acc.balance_in_account_currency, currency_precision)
|
acc.balance_in_account_currency = flt(acc.balance_in_account_currency, currency_precision)
|
||||||
if abs(acc.balance_in_account_currency) <= rounding_loss_allowance:
|
if abs(acc.balance_in_account_currency) <= rounding_loss_allowance:
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, msgprint
|
from frappe import _, msgprint, qb
|
||||||
|
from frappe.query_builder import Criterion
|
||||||
|
|
||||||
from erpnext import get_company_currency
|
from erpnext import get_company_currency
|
||||||
|
|
||||||
@ -214,24 +215,33 @@ def get_conditions(filters, date_field):
|
|||||||
if items:
|
if items:
|
||||||
conditions.append("dt_item.item_code in (%s)" % ", ".join(["%s"] * len(items)))
|
conditions.append("dt_item.item_code in (%s)" % ", ".join(["%s"] * len(items)))
|
||||||
values += items
|
values += items
|
||||||
|
else:
|
||||||
|
# return empty result, if no items are fetched after filtering on 'item group' and 'brand'
|
||||||
|
conditions.append("dt_item.item_code = Null")
|
||||||
|
|
||||||
return " and ".join(conditions), values
|
return " and ".join(conditions), values
|
||||||
|
|
||||||
|
|
||||||
def get_items(filters):
|
def get_items(filters):
|
||||||
|
item = qb.DocType("Item")
|
||||||
|
|
||||||
|
item_query_conditions = []
|
||||||
if filters.get("item_group"):
|
if filters.get("item_group"):
|
||||||
key = "item_group"
|
# Handle 'Parent' nodes as well.
|
||||||
elif filters.get("brand"):
|
item_group = qb.DocType("Item Group")
|
||||||
key = "brand"
|
lft, rgt = frappe.db.get_all(
|
||||||
else:
|
"Item Group", filters={"name": filters.get("item_group")}, fields=["lft", "rgt"], as_list=True
|
||||||
key = ""
|
)[0]
|
||||||
|
item_group_query = (
|
||||||
items = []
|
qb.from_(item_group)
|
||||||
if key:
|
.select(item_group.name)
|
||||||
items = frappe.db.sql_list(
|
.where((item_group.lft >= lft) & (item_group.rgt <= rgt))
|
||||||
"""select name from tabItem where %s = %s""" % (key, "%s"), (filters[key])
|
|
||||||
)
|
)
|
||||||
|
item_query_conditions.append(item.item_group.isin(item_group_query))
|
||||||
|
if filters.get("brand"):
|
||||||
|
item_query_conditions.append(item.brand == filters.get("brand"))
|
||||||
|
|
||||||
|
items = qb.from_(item).select(item.name).where(Criterion.all(item_query_conditions)).run()
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user