fix: update currency based on transaction

(cherry picked from commit fc4f38eed1)
This commit is contained in:
DHINESH00
2025-06-05 20:04:20 +05:30
committed by Mergify
parent 78607b5812
commit eaeb18c651

View File

@@ -20,14 +20,14 @@ def get_columns(filters, trans):
columns = ( columns = (
based_on_details["based_on_cols"] based_on_details["based_on_cols"]
+ period_cols + period_cols
+ [_("Total(Qty)") + ":Float:120", _("Total(Amt)") + ":Currency:120"] + [_("Total(Qty)") + ":Float:120", _("Total(Amt)") + ":Currency/currency:120"]
) )
if group_by_cols: if group_by_cols:
columns = ( columns = (
based_on_details["based_on_cols"] based_on_details["based_on_cols"]
+ group_by_cols + group_by_cols
+ period_cols + period_cols
+ [_("Total(Qty)") + ":Float:120", _("Total(Amt)") + ":Currency:120"] + [_("Total(Qty)") + ":Float:120", _("Total(Amt)") + ":Currency/currency:120"]
) )
conditions = { conditions = {
@@ -157,7 +157,7 @@ def get_data(filters, conditions):
# get data for group_by filter # get data for group_by filter
row1 = frappe.db.sql( row1 = frappe.db.sql(
""" select {} , {} from `tab{}` t1, `tab{} Item` t2 {} """ select t1.currency , {} , {} from `tab{}` t1, `tab{} Item` t2 {}
where t2.parent = t1.name and t1.company = {} and {} between {} and {} where t2.parent = t1.name and t1.company = {} and {} between {} and {}
and t1.docstatus = 1 and {} = {} and {} = {} {} {} and t1.docstatus = 1 and {} = {} and {} = {} {} {}
""".format( """.format(
@@ -182,6 +182,7 @@ def get_data(filters, conditions):
) )
des[ind] = row[i][0] des[ind] = row[i][0]
des[ind - 1] = row1[0][0]
for j in range(1, len(conditions["columns"]) - inc): for j in range(1, len(conditions["columns"]) - inc):
des[j + inc] = row1[0][j] des[j + inc] = row1[0][j]
@@ -236,7 +237,7 @@ def period_wise_columns_query(filters, trans):
else: else:
pwc = [ pwc = [
_(filters.get("fiscal_year")) + " (" + _("Qty") + "):Float:120", _(filters.get("fiscal_year")) + " (" + _("Qty") + "):Float:120",
_(filters.get("fiscal_year")) + " (" + _("Amt") + "):Currency:120", _(filters.get("fiscal_year")) + " (" + _("Amt") + "):Currency/currency:120",
] ]
query_details = " SUM(t2.stock_qty), SUM(t2.base_net_amount)," query_details = " SUM(t2.stock_qty), SUM(t2.base_net_amount),"
@@ -248,12 +249,17 @@ def get_period_wise_columns(bet_dates, period, pwc):
if period == "Monthly": if period == "Monthly":
pwc += [ pwc += [
_(get_mon(bet_dates[0])) + " (" + _("Qty") + "):Float:120", _(get_mon(bet_dates[0])) + " (" + _("Qty") + "):Float:120",
_(get_mon(bet_dates[0])) + " (" + _("Amt") + "):Currency:120", _(get_mon(bet_dates[0])) + " (" + _("Amt") + "):Currency/currency:120",
] ]
else: else:
pwc += [ pwc += [
_(get_mon(bet_dates[0])) + "-" + _(get_mon(bet_dates[1])) + " (" + _("Qty") + "):Float:120", _(get_mon(bet_dates[0])) + "-" + _(get_mon(bet_dates[1])) + " (" + _("Qty") + "):Float:120",
_(get_mon(bet_dates[0])) + "-" + _(get_mon(bet_dates[1])) + " (" + _("Amt") + "):Currency:120", _(get_mon(bet_dates[0]))
+ "-"
+ _(get_mon(bet_dates[1]))
+ " ("
+ _("Amt")
+ "):Currency/currency:120",
] ]
@@ -375,6 +381,9 @@ def based_wise_columns_query(based_on, trans):
else: else:
frappe.throw(_("Project-wise data is not available for Quotation")) frappe.throw(_("Project-wise data is not available for Quotation"))
based_on_details["based_on_select"] += "t1.currency,"
based_on_details["based_on_cols"].append("Currency:Link/Currency:120")
return based_on_details return based_on_details