mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-14 12:38:46 +00:00
fix: add monthly distributation and write query in qb
(cherry picked from commit 27195c7c96)
This commit is contained in:
@@ -490,13 +490,19 @@ def get_actual_expense(args):
|
|||||||
def get_accumulated_monthly_budget(monthly_distribution, posting_date, fiscal_year, annual_budget):
|
def get_accumulated_monthly_budget(monthly_distribution, posting_date, fiscal_year, annual_budget):
|
||||||
distribution = {}
|
distribution = {}
|
||||||
if monthly_distribution:
|
if monthly_distribution:
|
||||||
for d in frappe.db.sql(
|
mdp = frappe.qb.DocType("Monthly Distribution Percentage")
|
||||||
"""select mdp.month, mdp.percentage_allocation
|
md = frappe.qb.DocType("Monthly Distribution")
|
||||||
from `tabMonthly Distribution Percentage` mdp, `tabMonthly Distribution` md
|
|
||||||
where mdp.parent=md.name and md.fiscal_year=%s""",
|
query = (
|
||||||
fiscal_year,
|
frappe.qb.from_(mdp)
|
||||||
as_dict=1,
|
.join(md)
|
||||||
):
|
.on(mdp.parent == md.name)
|
||||||
|
.select(mdp.month, mdp.percentage_allocation)
|
||||||
|
.where(md.fiscal_year == fiscal_year)
|
||||||
|
.where(md.name == monthly_distribution)
|
||||||
|
)
|
||||||
|
|
||||||
|
for d in query.run(as_dict=True):
|
||||||
distribution.setdefault(d.month, d.percentage_allocation)
|
distribution.setdefault(d.month, d.percentage_allocation)
|
||||||
|
|
||||||
dt = frappe.get_cached_value("Fiscal Year", fiscal_year, "year_start_date")
|
dt = frappe.get_cached_value("Fiscal Year", fiscal_year, "year_start_date")
|
||||||
|
|||||||
Reference in New Issue
Block a user