Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Budget variance report #1038

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion erpnext/accounts/doctype/gl_closing/gl_closing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Loading