fix: Commified function to get dimensions
This commit is contained in:
parent
d83cf65be1
commit
e64c357216
@ -5,7 +5,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
|
||||||
from frappe.custom.doctype.custom_field.custom_field import create_custom_field
|
from frappe.custom.doctype.custom_field.custom_field import create_custom_field
|
||||||
from frappe import scrub
|
from frappe import scrub
|
||||||
from frappe.utils import cstr
|
from frappe.utils import cstr
|
||||||
@ -41,6 +40,24 @@ class AccountingDimension(Document):
|
|||||||
}
|
}
|
||||||
|
|
||||||
for doctype in doclist:
|
for doctype in doclist:
|
||||||
|
|
||||||
|
if doctype == "Budget":
|
||||||
|
df.update({
|
||||||
|
"depends_on": "eval:doc.budget_against == '{0}'".format(self.document_type)
|
||||||
|
})
|
||||||
|
|
||||||
|
create_custom_field(doctype, df)
|
||||||
|
|
||||||
|
property_setter = frappe.db.exists("Property Setter", "Budget-budget_against-options")
|
||||||
|
|
||||||
|
if property_setter:
|
||||||
|
else:
|
||||||
|
frappe.get_doc({
|
||||||
|
"doctype": "Property Setter",
|
||||||
|
"doc_type": "Budget",
|
||||||
|
"fieldname": "budget_against"
|
||||||
|
})
|
||||||
|
else:
|
||||||
create_custom_field(doctype, df)
|
create_custom_field(doctype, df)
|
||||||
|
|
||||||
def delete_accounting_dimension(self):
|
def delete_accounting_dimension(self):
|
||||||
|
|||||||
@ -62,3 +62,11 @@ frappe.query_reports["Budget Variance Report"] = {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let dimension_filters = erpnext.get_dimension_filters();
|
||||||
|
|
||||||
|
dimension_filters.then((dimensions) => {
|
||||||
|
dimensions.forEach((dimension) => {
|
||||||
|
frappe.query_reports["Budget Variance Report"].filters[4].options.push(dimension["document_type"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@ -19,9 +19,12 @@ def execute(filters=None):
|
|||||||
else:
|
else:
|
||||||
cost_centers = get_cost_centers(filters)
|
cost_centers = get_cost_centers(filters)
|
||||||
|
|
||||||
|
print(cost_centers)
|
||||||
|
|
||||||
period_month_ranges = get_period_month_ranges(filters["period"], filters["from_fiscal_year"])
|
period_month_ranges = get_period_month_ranges(filters["period"], filters["from_fiscal_year"])
|
||||||
cam_map = get_cost_center_account_month_map(filters)
|
cam_map = get_cost_center_account_month_map(filters)
|
||||||
|
|
||||||
|
print(cam_map)
|
||||||
data = []
|
data = []
|
||||||
for cost_center in cost_centers:
|
for cost_center in cost_centers:
|
||||||
cost_center_items = cam_map.get(cost_center)
|
cost_center_items = cam_map.get(cost_center)
|
||||||
@ -56,7 +59,7 @@ def execute(filters=None):
|
|||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
def validate_filters(filters):
|
def validate_filters(filters):
|
||||||
if filters.get("budget_against")=="Project" and filters.get("cost_center"):
|
if filters.get("budget_against") != "Cost Center" and filters.get("cost_center"):
|
||||||
frappe.throw(_("Filter based on Cost Center is only applicable if Budget Against is selected as Cost Center"))
|
frappe.throw(_("Filter based on Cost Center is only applicable if Budget Against is selected as Cost Center"))
|
||||||
|
|
||||||
def get_columns(filters):
|
def get_columns(filters):
|
||||||
@ -92,8 +95,11 @@ def get_cost_centers(filters):
|
|||||||
if filters.get("budget_against") == "Cost Center":
|
if filters.get("budget_against") == "Cost Center":
|
||||||
cond = "order by lft"
|
cond = "order by lft"
|
||||||
|
|
||||||
|
if filters.get("budget_against") in ["Cost Center", "Project"]:
|
||||||
return frappe.db.sql_list("""select name from `tab{tab}` where company=%s
|
return frappe.db.sql_list("""select name from `tab{tab}` where company=%s
|
||||||
{cond}""".format(tab=filters.get("budget_against"), cond=cond), filters.get("company"))
|
{cond}""".format(tab=filters.get("budget_against"), cond=cond), filters.get("company"))
|
||||||
|
else:
|
||||||
|
return frappe.db.sql_list("""select name from `tab{tab}`""".format(tab=filters.get("budget_against")))
|
||||||
|
|
||||||
#Get cost center & target details
|
#Get cost center & target details
|
||||||
def get_cost_center_target_details(filters):
|
def get_cost_center_target_details(filters):
|
||||||
@ -153,6 +159,7 @@ def get_actual_details(name, filters):
|
|||||||
def get_cost_center_account_month_map(filters):
|
def get_cost_center_account_month_map(filters):
|
||||||
import datetime
|
import datetime
|
||||||
cost_center_target_details = get_cost_center_target_details(filters)
|
cost_center_target_details = get_cost_center_target_details(filters)
|
||||||
|
print(cost_center_target_details)
|
||||||
tdd = get_target_distribution_details(filters)
|
tdd = get_target_distribution_details(filters)
|
||||||
|
|
||||||
cam_map = {}
|
cam_map = {}
|
||||||
|
|||||||
@ -215,7 +215,7 @@ frappe.query_reports["General Ledger"] = {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
let dimension_filters = get_dimension_filters();
|
let dimension_filters = erpnext.get_dimension_filters();
|
||||||
|
|
||||||
dimension_filters.then((dimensions) => {
|
dimension_filters.then((dimensions) => {
|
||||||
dimensions.forEach((dimension) => {
|
dimensions.forEach((dimension) => {
|
||||||
@ -228,10 +228,3 @@ dimension_filters.then((dimensions) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
async function get_dimension_filters() {
|
|
||||||
let dimensions = await frappe.db.get_list('Accounting Dimension', {
|
|
||||||
fields: ['label', 'fieldname', 'document_type'],
|
|
||||||
});
|
|
||||||
|
|
||||||
return dimensions;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -150,7 +150,7 @@ function get_filters(){
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
let dimension_filters = get_dimension_filters()
|
let dimension_filters = erpnext.get_dimension_filters()
|
||||||
|
|
||||||
dimension_filters.then((dimensions) => {
|
dimension_filters.then((dimensions) => {
|
||||||
dimensions.forEach((dimension) => {
|
dimensions.forEach((dimension) => {
|
||||||
@ -166,10 +166,4 @@ function get_filters(){
|
|||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function get_dimension_filters() {
|
|
||||||
let dimensions = await frappe.db.get_list('Accounting Dimension', {
|
|
||||||
fields: ['label', 'fieldname', 'document_type'],
|
|
||||||
});
|
|
||||||
|
|
||||||
return dimensions;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -62,6 +62,14 @@ $.extend(erpnext, {
|
|||||||
$btn.on("click", function() {
|
$btn.on("click", function() {
|
||||||
me.show_serial_batch_selector(grid_row.frm, grid_row.doc);
|
me.show_serial_batch_selector(grid_row.frm, grid_row.doc);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
get_dimension_filters: async function() {
|
||||||
|
let dimensions = await frappe.db.get_list('Accounting Dimension', {
|
||||||
|
fields: ['label', 'fieldname', 'document_type'],
|
||||||
|
});
|
||||||
|
|
||||||
|
return dimensions;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user