<commit_before># Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals
import frappe
import frappe.defaults
from frappe.utils import flt
from erpnext.accounts.utils import get_balance_on
from erpnext.accounts.report.financial_statements import sort_root_accounts

@frappe.whitelist()
def get_companies():
	"""get a list of companies based on permission"""
	return [d.name for d in frappe.get_list("Company", fields=["name"],
		order_by="name")]

@frappe.whitelist()
def get_children():
	args = frappe.local.form_dict
	ctype, company = args['ctype'], args['comp']

	# root
	if args['parent'] in ("Accounts", "Cost Centers"):
		acc = frappe.db.sql(""" select
			name as value, is_group as expandable, root_type, report_type
			from `tab%s`
			where ifnull(parent_%s,'') = ''
			and `company` = %s	and docstatus<2
			order by name""" % (ctype, ctype.lower().replace(' ','_'), '%s'),
				company, as_dict=1)

		if args["parent"]=="Accounts":
			sort_root_accounts(acc)
	else:
		# other
		acc = frappe.db.sql("""select
			name as value, is_group as expandable
	 		from `tab%s`
			where ifnull(parent_%s,'') = %s
			and docstatus<2<commit_msg>minor fix in chart of cost centers<commit_after># Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals
import frappe
import frappe.defaults
from frappe.utils import flt
from erpnext.accounts.utils import get_balance_on
from erpnext.accounts.report.financial_statements import sort_root_accounts

@frappe.whitelist()
def get_companies():
	"""get a list of companies based on permission"""
	return [d.name for d in frappe.get_list("Company", fields=["name"],
		order_by="name")]

@frappe.whitelist()
def get_children():
	args = frappe.local.form_dict
	ctype, company = args['ctype'], args['comp']

	# root
	if args['parent'] in ("Accounts", "Cost Centers"):
		select_cond = ", root_type, report_type" if args["parent"]=="Accounts" else ""
		
		acc = frappe.db.sql(""" select
			name as value, is_group as expandable %s
			from `tab%s`
			where ifnull(parent_%s,'') = ''
			and `company` = %s	and docstatus<2
			order by name""" % (select_cond, ctype, ctype.lower().replace(' ','_'), '%s'),
				company, as_dict=1)

		if args["parent"]=="Accounts":
			sort_root_accounts(acc)
	else:
		# other
		acc = frappe.db.sql("""select
			name as value, is_group as expandable
	 		from `tab%s`
			where ifnull(parent_%s,'') = %s
			and docstatus<2
{'fraction_non_alphanumeric': 0.1375722543352601, 'fraction_numerical': 0.006165703275529865, 'mean_word_length': 4.807606263982103, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4041321', 'n_tokens_mistral': 969, 'n_tokens_neox': 900, 'n_words': 253}