diff --git a/erpnext/accounts/doctype/gl_closing/gl_closing.py b/erpnext/accounts/doctype/gl_closing/gl_closing.py index 1316c1c858b1..62ec10da9d08 100644 --- a/erpnext/accounts/doctype/gl_closing/gl_closing.py +++ b/erpnext/accounts/doctype/gl_closing/gl_closing.py @@ -104,10 +104,17 @@ def get_merge(): .run(as_dict=True) ) return data + + @frappe.whitelist(allow_guest=True) def get_account_settings(): - acs = frappe.get_all("Accounts Closing Table", fields=["company", "frozen_accounts_modifier"]) + if frappe.db.table_exists("Accounts Closing Table"): + acs = frappe.get_all("Accounts Closing Table", fields=["company", "frozen_accounts_modifier"]) + else: + acs = [] return acs + + @frappe.whitelist(allow_guest=True) def get_user_roles(): user = frappe.session.user diff --git a/erpnext/accounts/report/budget_variance_report/budget_variance_report.py b/erpnext/accounts/report/budget_variance_report/budget_variance_report.py index e540aa9993c8..dec189da4185 100644 --- a/erpnext/accounts/report/budget_variance_report/budget_variance_report.py +++ b/erpnext/accounts/report/budget_variance_report/budget_variance_report.py @@ -240,8 +240,8 @@ def get_actual_details(name, filters): if filters.get("budget_against") == "Cost Center": cc_lft, cc_rgt = frappe.db.get_value("Cost Center", name, ["lft", "rgt"]) cond = f""" - and lft >= "{cc_lft}" - and rgt <= "{cc_rgt}" + and lft >= {cc_lft} + and rgt <= {cc_rgt} """ ac_details = frappe.db.sql( @@ -251,8 +251,8 @@ def get_actual_details(name, filters): gl.debit, gl.credit, gl.fiscal_year, - MONTHNAME(gl.posting_date) as month_name, - b.{budget_against} as budget_against + TO_CHAR(gl.posting_date, 'Month') AS month_name, + (ARRAY_AGG(b.{budget_against}))[1] as budget_against from `tabGL Entry` gl, `tabBudget Account` ba, diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py index 0a55ae273a43..1a6bcb3bd633 100644 --- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py +++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py @@ -810,13 +810,25 @@ def get_group_by_and_display_fields(filters): def add_sub_total_row(item, total_row_map, group_by_value, tax_columns): - total_row = total_row_map.get(group_by_value) - total_row["stock_qty"] += item["stock_qty"] - total_row["amount"] += item["amount"] - total_row["total_tax"] += item["total_tax"] - total_row["total"] += item["total"] - total_row["percent_gt"] += item["percent_gt"] - - for tax in tax_columns: - total_row.setdefault(frappe.scrub(tax + " Amount"), 0.0) - total_row[frappe.scrub(tax + " Amount")] += flt(item[frappe.scrub(tax + " Amount")]) + if group_by_value not in total_row_map: + total_row_map[group_by_value] = { + "stock_qty": 0.0, + "amount": 0.0, + "total_tax": 0.0, + "total": 0.0, + "percent_gt": 0.0 + } + + total_row = total_row_map.get(group_by_value) + + total_row["stock_qty"] += item.get("stock_qty", 0) + total_row["amount"] += item.get("amount", 0) + total_row["total_tax"] += item.get("total_tax", 0) + total_row["total"] += item.get("total", 0) + total_row["percent_gt"] += item.get("percent_gt", 0) + + for tax in tax_columns: + tax_amount_field = frappe.scrub(tax + " Amount") + total_row.setdefault(tax_amount_field, 0.0) + total_row[tax_amount_field] += item.get(tax_amount_field, 0.0) +