def setup_charts(delete_existing=True): frappe.local.flags.allow_unverified_charts = True # delete if delete_existing: for company in frappe.get_all("Company"): if company.name not in ("Wind Power LLC", "Test Company"): print "deleting {0}".format(company.name) frappe.delete_doc("Company", company.name) frappe.db.commit() print "-"*40 for country in frappe.get_all("Country", fields=["name", "code"]): charts = get_charts_for_country(country.name) for i, chart in enumerate(charts): if (chart != "Standard" or country.name == "United States"): if not frappe.db.exists("Company", chart): print chart.encode('utf-8') company = frappe.new_doc("Company") company.company_name = chart company.country = country.name company.chart_of_accounts = chart company.abbr = country.code + str(i+1) company.default_currency = "USD" company.insert() frappe.db.commit()
def setup_charts(delete_existing=True): frappe.local.flags.allow_unverified_charts = True # delete if delete_existing: for company in frappe.get_all("Company"): if company.name not in ("Wind Power LLC", "Test Company"): print("deleting {0}".format(company.name)) frappe.delete_doc("Company", company.name) frappe.db.commit() print("-" * 40) for country in frappe.get_all("Country", fields=["name", "code"], filters={"name": "India"}): charts = get_charts_for_country(country.name) for i, chart in enumerate(charts): if (chart != "Standard" or country.name == "United States"): if not frappe.db.exists("Company", chart): print(chart.encode('utf-8')) company = frappe.new_doc("Company") company.company_name = chart company.country = country.name company.chart_of_accounts = chart company.abbr = country.code + str(i + 1) company.default_currency = "USD" company.insert() frappe.db.commit()
def setup_charts(): frappe.local.flags.allow_unverified_charts = True # delete for company in frappe.get_all("Company"): if company.name != "Wind Power LLC": print "deleting {0}".format(company.name) frappe.delete_doc("Company", company.name) frappe.db.commit() for country in frappe.get_all("Country", fields=["name", "code"]): if country.name in countries: print "creating for {0}".format(country.name) charts = get_charts_for_country(country.name) for i, chart in enumerate(charts): company = frappe.new_doc("Company") company.company_name = "{0} - {1}".format(country.name, chart) company.country = country.name company.chart_of_accounts = chart company.abbr = country.code + str(i) company.default_currency = "USD" company.insert() frappe.db.commit()
def test_coa_based_on_country_template(self): countries = ["Canada", "Germany", "France"] for country in countries: templates = get_charts_for_country(country) if len(templates) != 1 and "Standard" in templates: templates.remove("Standard") self.assertTrue(templates) for template in templates: try: company = frappe.new_doc("Company") company.company_name = template company.abbr = random_string(3) company.default_currency = "USD" company.create_chart_of_accounts_based_on = "Standard Template" company.chart_of_accounts = template company.save() account_types = [ "Cost of Goods Sold", "Depreciation", "Expenses Included In Valuation", "Fixed Asset", "Payable", "Receivable", "Stock Adjustment", "Stock Received But Not Billed", "Bank", "Cash", "Stock", ] for account_type in account_types: filters = { "company": template, "account_type": account_type } if account_type in ["Bank", "Cash"]: filters["is_group"] = 1 has_matching_accounts = frappe.get_all( "Account", filters) error_message = _( "No Account matched these filters: {}").format( json.dumps(filters)) self.assertTrue(has_matching_accounts, msg=error_message) finally: self.delete_mode_of_payment(template) frappe.delete_doc("Company", template)
def test_coa_based_on_country_template(self): countries = [ "India", "Brazil", "United Arab Emirates", "Canada", "Germany", "France", "Guatemala", "Indonesia", "Mexico", "Nicaragua", "Netherlands", "Singapore", "Brazil", "Argentina", "Hungary", "Taiwan" ] for country in countries: templates = get_charts_for_country(country) if len(templates) != 1 and "Standard" in templates: templates.remove("Standard") self.assertTrue(templates) for template in templates: try: company = frappe.new_doc("Company") company.company_name = template company.abbr = random_string(3) company.default_currency = "USD" company.create_chart_of_accounts_based_on = "Standard Template" company.chart_of_accounts = template company.save() account_types = [ "Cost of Goods Sold", "Depreciation", "Expenses Included In Valuation", "Fixed Asset", "Payable", "Receivable", "Stock Adjustment", "Stock Received But Not Billed", "Bank", "Cash", "Stock" ] for account_type in account_types: filters = { "company": template, "account_type": account_type } if account_type in ["Bank", "Cash"]: filters["is_group"] = 1 self.assertTrue(frappe.get_all("Account", filters)) finally: self.delete_mode_of_payment(template) frappe.delete_doc("Company", template)
def test_coa_based_on_country_template(self): countries = ["India", "Brazil", "United Arab Emirates", "Canada", "Germany", "France", "Guatemala", "Indonesia", "Italy", "Mexico", "Nicaragua", "Netherlands", "Singapore", "Brazil", "Argentina", "Hungary", "Taiwan"] for country in countries: templates = get_charts_for_country(country) if len(templates) != 1 and "Standard" in templates: templates.remove("Standard") self.assertTrue(templates) for template in templates: try: company = frappe.new_doc("Company") company.company_name = template company.abbr = random_string(3) company.default_currency = "USD" company.create_chart_of_accounts_based_on = "Standard Template" company.chart_of_accounts = template company.save() account_types = ["Cost of Goods Sold", "Depreciation", "Expenses Included In Valuation", "Fixed Asset", "Payable", "Receivable", "Stock Adjustment", "Stock Received But Not Billed", "Bank", "Cash", "Stock"] for account_type in account_types: filters = { "company": template, "account_type": account_type } if account_type in ["Bank", "Cash"]: filters["is_group"] = 1 has_matching_accounts = frappe.get_all("Account", filters) error_message = _("No Account matched these filters: {}".format(json.dumps(filters))) self.assertTrue(has_matching_accounts, msg=error_message) finally: self.delete_mode_of_payment(template) frappe.delete_doc("Company", template)