feat(tally): Create chart of accounts from tally master data
diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.json b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.json
index 7d51850..2087c7f 100644
--- a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.json
+++ b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.json
@@ -328,6 +328,38 @@
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
+ "read_only": 1,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "chart_of_accounts",
+ "fieldtype": "Attach",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Chart of Accounts",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
@@ -348,7 +380,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2019-03-01 15:02:47.992385",
+ "modified": "2019-03-01 20:58:04.320605",
"modified_by": "Administrator",
"module": "ERPNext Integrations",
"name": "Tally Migration",
diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py
index 4c27d74..aac371d 100644
--- a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py
+++ b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py
@@ -10,6 +10,7 @@
import frappe
from frappe.model.document import Document
from bs4 import BeautifulSoup as bs
+from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import create_charts
PRIMARY_ACCOUNT = "Primary"
@@ -19,6 +20,15 @@
self.tally_company = company
self.erpnext_company = company
self.status = "Preprocessed"
+
+ coa_file = frappe.get_doc({
+ "doctype": "File",
+ "file_name": "COA.json",
+ "attached_to_doctype": self.doctype,
+ "attached_to_name": self.name,
+ "content": json.dumps(chart_of_accounts_tree)
+ }).insert()
+ self.chart_of_accounts = coa_file.file_url
self.save()
def _process_master_data(self):
@@ -120,7 +130,19 @@
frappe.enqueue_doc(self.doctype, self.name, "_preprocess")
def start_import(self):
- pass
+ def create_company_and_coa(coa_file_url):
+ coa_file = frappe.get_doc("File", {"file_url": coa_file_url})
+ frappe.local.flags.ignore_chart_of_accounts = True
+ company = frappe.get_doc({
+ "doctype": "Company",
+ "company_name": self.erpnext_company,
+ "default_currency": "INR",
+ }).insert()
+ frappe.local.flags.ignore_chart_of_accounts = False
+ create_charts(company.name, json.loads(coa_file.get_content()))
+
+ create_company_and_coa(self.chart_of_accounts)
+
def sanitize(string):
return re.sub("", "", string)