mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-14 09:23:09 +00:00
fix: use company currency instead of global default in report
(cherry picked from commit e6f9149ad7)
This commit is contained in:
committed by
Mergify
parent
6bd903e45a
commit
4a0e7f23ec
@@ -80,6 +80,7 @@ def execute(filters=None):
|
|||||||
"parent_section": None,
|
"parent_section": None,
|
||||||
"indent": 0.0,
|
"indent": 0.0,
|
||||||
"section": cash_flow_section["section_header"],
|
"section": cash_flow_section["section_header"],
|
||||||
|
"currency": company_currency,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -227,6 +227,7 @@ def get_data_when_grouped_by_invoice(columns, gross_profit_data, filters, group_
|
|||||||
)
|
)
|
||||||
if total_base_amount
|
if total_base_amount
|
||||||
else 0,
|
else 0,
|
||||||
|
"currency": filters.currency,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -269,6 +270,7 @@ def get_data_when_not_grouped_by_invoice(gross_profit_data, filters, group_wise_
|
|||||||
"buying_amount": total_buying_amount,
|
"buying_amount": total_buying_amount,
|
||||||
"gross_profit": total_gross_profit,
|
"gross_profit": total_gross_profit,
|
||||||
"gross_profit_percent": flt(gross_profit_percent, currency_precision),
|
"gross_profit_percent": flt(gross_profit_percent, currency_precision),
|
||||||
|
"currency": filters.currency,
|
||||||
}
|
}
|
||||||
|
|
||||||
total_row = [total_row.get(col, None) for col in [*group_columns, "currency"]]
|
total_row = [total_row.get(col, None) for col in [*group_columns, "currency"]]
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
|
import erpnext
|
||||||
from erpnext.controllers.trends import get_columns, get_data
|
from erpnext.controllers.trends import get_columns, get_data
|
||||||
|
|
||||||
|
|
||||||
@@ -50,6 +51,7 @@ def get_chart_data(data, conditions, filters):
|
|||||||
for i in range(len(row)):
|
for i in range(len(row)):
|
||||||
datapoints[i] += row[i]
|
datapoints[i] += row[i]
|
||||||
|
|
||||||
|
company_currency = erpnext.get_company_currency(filters.get("company"))
|
||||||
return {
|
return {
|
||||||
"data": {
|
"data": {
|
||||||
"labels": labels,
|
"labels": labels,
|
||||||
@@ -60,4 +62,6 @@ def get_chart_data(data, conditions, filters):
|
|||||||
"type": "line",
|
"type": "line",
|
||||||
"lineOptions": {"regionFill": 1},
|
"lineOptions": {"regionFill": 1},
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"currency": company_currency,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import frappe
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import DateTimeLikeObject, getdate, today
|
from frappe.utils import DateTimeLikeObject, getdate, today
|
||||||
|
|
||||||
|
import erpnext
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
|
|
||||||
|
|
||||||
@@ -206,7 +207,7 @@ def get_data(filters, conditions):
|
|||||||
|
|
||||||
data.append(des)
|
data.append(des)
|
||||||
|
|
||||||
total_row = calculate_total_row(data1, conditions["columns"])
|
total_row = calculate_total_row(data1, conditions["columns"], filters.get("company"))
|
||||||
data.append(total_row)
|
data.append(total_row)
|
||||||
else:
|
else:
|
||||||
data = frappe.db.sql(
|
data = frappe.db.sql(
|
||||||
@@ -231,20 +232,23 @@ def get_data(filters, conditions):
|
|||||||
as_list=1,
|
as_list=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
total_row = calculate_total_row(data, conditions["columns"])
|
total_row = calculate_total_row(data, conditions["columns"], filters.get("company"))
|
||||||
data.append(total_row)
|
data.append(total_row)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def calculate_total_row(data, columns):
|
def calculate_total_row(data, columns, company=None):
|
||||||
def wrap_in_quotes(label):
|
def wrap_in_quotes(label):
|
||||||
return f"'{label}'"
|
return f"'{label}'"
|
||||||
|
|
||||||
total_values = {}
|
total_values = {}
|
||||||
|
currency_col_idx = None
|
||||||
for i, col in enumerate(columns):
|
for i, col in enumerate(columns):
|
||||||
if "Float" in col or "Currency/currency" in col:
|
if "Float" in col or "Currency/currency" in col:
|
||||||
total_values[i] = 0
|
total_values[i] = 0
|
||||||
|
if col.split(":")[0] == "Currency":
|
||||||
|
currency_col_idx = i
|
||||||
|
|
||||||
for row in data:
|
for row in data:
|
||||||
for i in total_values.keys():
|
for i in total_values.keys():
|
||||||
@@ -254,6 +258,9 @@ def calculate_total_row(data, columns):
|
|||||||
for i in range(1, len(columns)):
|
for i in range(1, len(columns)):
|
||||||
total_row.append(total_values.get(i, None))
|
total_row.append(total_values.get(i, None))
|
||||||
|
|
||||||
|
if currency_col_idx is not None:
|
||||||
|
total_row[currency_col_idx] = company and erpnext.get_company_currency(company)
|
||||||
|
|
||||||
return total_row
|
return total_row
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
|
import erpnext
|
||||||
from erpnext.controllers.trends import get_columns, get_data
|
from erpnext.controllers.trends import get_columns, get_data
|
||||||
|
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ def get_chart_data(data, conditions, filters):
|
|||||||
|
|
||||||
for i in range(len(row)):
|
for i in range(len(row)):
|
||||||
datapoints[i] += row[i]
|
datapoints[i] += row[i]
|
||||||
|
company_currency = erpnext.get_company_currency(filters.get("company"))
|
||||||
return {
|
return {
|
||||||
"data": {
|
"data": {
|
||||||
"labels": labels,
|
"labels": labels,
|
||||||
@@ -59,4 +59,6 @@ def get_chart_data(data, conditions, filters):
|
|||||||
"type": "line",
|
"type": "line",
|
||||||
"lineOptions": {"regionFill": 1},
|
"lineOptions": {"regionFill": 1},
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"currency": company_currency,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
|
import erpnext
|
||||||
from erpnext.controllers.trends import get_columns, get_data
|
from erpnext.controllers.trends import get_columns, get_data
|
||||||
|
|
||||||
|
|
||||||
@@ -50,6 +51,7 @@ def get_chart_data(data, conditions, filters):
|
|||||||
for i in range(len(row)):
|
for i in range(len(row)):
|
||||||
datapoints[i] += row[i]
|
datapoints[i] += row[i]
|
||||||
|
|
||||||
|
company_currency = erpnext.get_company_currency(filters.get("company"))
|
||||||
return {
|
return {
|
||||||
"data": {
|
"data": {
|
||||||
"labels": labels,
|
"labels": labels,
|
||||||
@@ -58,4 +60,6 @@ def get_chart_data(data, conditions, filters):
|
|||||||
"type": "line",
|
"type": "line",
|
||||||
"lineOptions": {"regionFill": 1},
|
"lineOptions": {"regionFill": 1},
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"currency": company_currency,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
|
import erpnext
|
||||||
from erpnext.controllers.trends import get_columns, get_data
|
from erpnext.controllers.trends import get_columns, get_data
|
||||||
|
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@ def get_chart_data(data, filters):
|
|||||||
labels.append(row[0])
|
labels.append(row[0])
|
||||||
datapoints.append(row[-1])
|
datapoints.append(row[-1])
|
||||||
|
|
||||||
|
company_currency = erpnext.get_company_currency(filters.get("company"))
|
||||||
return {
|
return {
|
||||||
"data": {
|
"data": {
|
||||||
"labels": labels,
|
"labels": labels,
|
||||||
@@ -52,4 +54,6 @@ def get_chart_data(data, filters):
|
|||||||
},
|
},
|
||||||
"type": "bar",
|
"type": "bar",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"currency": company_currency,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ def get_columns() -> list[dict]:
|
|||||||
"label": _("Total Landed Cost"),
|
"label": _("Total Landed Cost"),
|
||||||
"fieldname": "landed_cost",
|
"fieldname": "landed_cost",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": _("Purchase Voucher Type"),
|
"label": _("Purchase Voucher Type"),
|
||||||
@@ -49,6 +50,8 @@ def get_columns() -> list[dict]:
|
|||||||
|
|
||||||
|
|
||||||
def get_data(filters) -> list[list]:
|
def get_data(filters) -> list[list]:
|
||||||
|
company_currency = frappe.get_cached_value("Company", filters.company, "default_currency")
|
||||||
|
|
||||||
landed_cost_vouchers = get_landed_cost_vouchers(filters) or {}
|
landed_cost_vouchers = get_landed_cost_vouchers(filters) or {}
|
||||||
landed_vouchers = list(landed_cost_vouchers.keys())
|
landed_vouchers = list(landed_cost_vouchers.keys())
|
||||||
vendor_invoices = {}
|
vendor_invoices = {}
|
||||||
@@ -57,7 +60,6 @@ def get_data(filters) -> list[list]:
|
|||||||
|
|
||||||
data = []
|
data = []
|
||||||
|
|
||||||
print(vendor_invoices)
|
|
||||||
for name, vouchers in landed_cost_vouchers.items():
|
for name, vouchers in landed_cost_vouchers.items():
|
||||||
res = {
|
res = {
|
||||||
"name": name,
|
"name": name,
|
||||||
@@ -72,6 +74,7 @@ def get_data(filters) -> list[list]:
|
|||||||
"landed_cost": d.landed_cost,
|
"landed_cost": d.landed_cost,
|
||||||
"voucher_type": d.voucher_type,
|
"voucher_type": d.voucher_type,
|
||||||
"voucher_no": d.voucher_no,
|
"voucher_no": d.voucher_no,
|
||||||
|
"currency": company_currency,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -88,7 +91,6 @@ def get_data(filters) -> list[list]:
|
|||||||
|
|
||||||
if vendor_invoice_list and len(vendor_invoice_list) > len(vouchers):
|
if vendor_invoice_list and len(vendor_invoice_list) > len(vouchers):
|
||||||
for row in vendor_invoice_list[last_index + 1 :]:
|
for row in vendor_invoice_list[last_index + 1 :]:
|
||||||
print(row)
|
|
||||||
data.append({"vendor_invoice": row})
|
data.append({"vendor_invoice": row})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
|
import erpnext
|
||||||
from erpnext.controllers.trends import get_columns, get_data
|
from erpnext.controllers.trends import get_columns, get_data
|
||||||
|
|
||||||
|
|
||||||
@@ -44,6 +45,7 @@ def get_chart_data(data, filters):
|
|||||||
|
|
||||||
labels.append(row[0])
|
labels.append(row[0])
|
||||||
datapoints.append(row[-1])
|
datapoints.append(row[-1])
|
||||||
|
company_currency = erpnext.get_company_currency(filters.get("company"))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"data": {
|
"data": {
|
||||||
@@ -53,4 +55,6 @@ def get_chart_data(data, filters):
|
|||||||
"type": "bar",
|
"type": "bar",
|
||||||
"colors": ["#5e64ff"],
|
"colors": ["#5e64ff"],
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"currency": company_currency,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user