mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-29 06:38:24 +00:00
Merge branch 'develop' into patch-5
This commit is contained in:
@@ -74,7 +74,7 @@
|
||||
"stock_received_but_not_billed",
|
||||
"service_received_but_not_billed",
|
||||
"expenses_included_in_valuation",
|
||||
"fixed_asset_depreciation_settings",
|
||||
"fixed_asset_defaults",
|
||||
"accumulated_depreciation_account",
|
||||
"depreciation_expense_account",
|
||||
"series_for_depreciation_entry",
|
||||
@@ -83,6 +83,7 @@
|
||||
"disposal_account",
|
||||
"depreciation_cost_center",
|
||||
"capital_work_in_progress_account",
|
||||
"repair_and_maintenance_account",
|
||||
"asset_received_but_not_billed",
|
||||
"budget_detail",
|
||||
"exception_budget_approver_role",
|
||||
@@ -519,12 +520,6 @@
|
||||
"no_copy": 1,
|
||||
"options": "Account"
|
||||
},
|
||||
{
|
||||
"collapsible": 1,
|
||||
"fieldname": "fixed_asset_depreciation_settings",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Fixed Asset Depreciation Settings"
|
||||
},
|
||||
{
|
||||
"fieldname": "accumulated_depreciation_account",
|
||||
"fieldtype": "Link",
|
||||
@@ -734,6 +729,18 @@
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Payment Discount Account",
|
||||
"options": "Account"
|
||||
},
|
||||
{
|
||||
"collapsible": 1,
|
||||
"fieldname": "fixed_asset_defaults",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Fixed Asset Defaults"
|
||||
},
|
||||
{
|
||||
"fieldname": "repair_and_maintenance_account",
|
||||
"fieldtype": "Link",
|
||||
"label": "Repair and Maintenance Account",
|
||||
"options": "Account"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-building",
|
||||
@@ -741,7 +748,7 @@
|
||||
"image_field": "company_logo",
|
||||
"is_tree": 1,
|
||||
"links": [],
|
||||
"modified": "2021-05-07 03:11:28.189740",
|
||||
"modified": "2021-05-12 16:51:08.187233",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Company",
|
||||
|
||||
@@ -110,7 +110,7 @@ class Company(NestedSet):
|
||||
self.create_default_warehouses()
|
||||
|
||||
if frappe.flags.country_change:
|
||||
install_country_fixtures(self.name)
|
||||
install_country_fixtures(self.name, self.country)
|
||||
self.create_default_tax_template()
|
||||
|
||||
if not frappe.db.get_value("Department", {"company": self.name}):
|
||||
@@ -291,7 +291,7 @@ class Company(NestedSet):
|
||||
cash = frappe.db.get_value('Mode of Payment', {'type': 'Cash'}, 'name')
|
||||
if cash and self.default_cash_account \
|
||||
and not frappe.db.get_value('Mode of Payment Account', {'company': self.name, 'parent': cash}):
|
||||
mode_of_payment = frappe.get_doc('Mode of Payment', cash)
|
||||
mode_of_payment = frappe.get_doc('Mode of Payment', cash, for_update=True)
|
||||
mode_of_payment.append('accounts', {
|
||||
'company': self.name,
|
||||
'default_account': self.default_cash_account
|
||||
@@ -395,7 +395,7 @@ class Company(NestedSet):
|
||||
|
||||
@frappe.whitelist()
|
||||
def enqueue_replace_abbr(company, old, new):
|
||||
kwargs = dict(company=company, old=old, new=new)
|
||||
kwargs = dict(queue="long", company=company, old=old, new=new)
|
||||
frappe.enqueue('erpnext.setup.doctype.company.company.replace_abbr', **kwargs)
|
||||
|
||||
|
||||
@@ -440,16 +440,15 @@ def get_name_with_abbr(name, company):
|
||||
|
||||
return " - ".join(parts)
|
||||
|
||||
def install_country_fixtures(company):
|
||||
company_doc = frappe.get_doc("Company", company)
|
||||
path = frappe.get_app_path('erpnext', 'regional', frappe.scrub(company_doc.country))
|
||||
def install_country_fixtures(company, country):
|
||||
path = frappe.get_app_path('erpnext', 'regional', frappe.scrub(country))
|
||||
if os.path.exists(path.encode("utf-8")):
|
||||
try:
|
||||
module_name = "erpnext.regional.{0}.setup.setup".format(frappe.scrub(company_doc.country))
|
||||
frappe.get_attr(module_name)(company_doc, False)
|
||||
module_name = "erpnext.regional.{0}.setup.setup".format(frappe.scrub(country))
|
||||
frappe.get_attr(module_name)(company, False)
|
||||
except Exception as e:
|
||||
frappe.log_error()
|
||||
frappe.throw(_("Failed to setup defaults for country {0}. Please contact support@erpnext.com").format(frappe.bold(company_doc.country)))
|
||||
frappe.throw(_("Failed to setup defaults for country {0}. Please contact support@erpnext.com").format(frappe.bold(country)))
|
||||
|
||||
|
||||
def update_company_current_month_sales(company):
|
||||
|
||||
@@ -87,8 +87,8 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
||||
if not field_filters:
|
||||
field_filters = {}
|
||||
|
||||
# Ensure the query remains within current item group
|
||||
field_filters['item_group'] = self.name
|
||||
# Ensure the query remains within current item group & sub group
|
||||
field_filters['item_group'] = [ig[0] for ig in get_child_groups(self.name)]
|
||||
|
||||
engine = ProductQuery()
|
||||
context.items = engine.query(attribute_filters, field_filters, search, start, item_group=self.name)
|
||||
|
||||
@@ -12,10 +12,14 @@ from frappe.desk.notifications import clear_notifications
|
||||
class TransactionDeletionRecord(Document):
|
||||
def validate(self):
|
||||
frappe.only_for('System Manager')
|
||||
self.validate_doctypes_to_be_ignored()
|
||||
|
||||
def validate_doctypes_to_be_ignored(self):
|
||||
doctypes_to_be_ignored_list = get_doctypes_to_be_ignored()
|
||||
for doctype in self.doctypes_to_be_ignored:
|
||||
if doctype.doctype_name not in doctypes_to_be_ignored_list:
|
||||
frappe.throw(_("DocTypes should not be added manually to the 'Excluded DocTypes' table. You are only allowed to remove entries from it. "), title=_("Not Allowed"))
|
||||
frappe.throw(_("DocTypes should not be added manually to the 'Excluded DocTypes' table. You are only allowed to remove entries from it. "),
|
||||
title=_("Not Allowed"))
|
||||
|
||||
def before_submit(self):
|
||||
if not self.doctypes_to_be_ignored:
|
||||
@@ -23,54 +27,9 @@ class TransactionDeletionRecord(Document):
|
||||
|
||||
self.delete_bins()
|
||||
self.delete_lead_addresses()
|
||||
|
||||
company_obj = frappe.get_doc('Company', self.company)
|
||||
# reset company values
|
||||
company_obj.total_monthly_sales = 0
|
||||
company_obj.sales_monthly_history = None
|
||||
company_obj.save()
|
||||
# Clear notification counts
|
||||
self.reset_company_values()
|
||||
clear_notifications()
|
||||
|
||||
singles = frappe.get_all('DocType', filters = {'issingle': 1}, pluck = 'name')
|
||||
tables = frappe.get_all('DocType', filters = {'istable': 1}, pluck = 'name')
|
||||
doctypes_to_be_ignored_list = singles
|
||||
for doctype in self.doctypes_to_be_ignored:
|
||||
doctypes_to_be_ignored_list.append(doctype.doctype_name)
|
||||
|
||||
docfields = frappe.get_all('DocField',
|
||||
filters = {
|
||||
'fieldtype': 'Link',
|
||||
'options': 'Company',
|
||||
'parent': ['not in', doctypes_to_be_ignored_list]},
|
||||
fields=['parent', 'fieldname'])
|
||||
|
||||
for docfield in docfields:
|
||||
if docfield['parent'] != self.doctype:
|
||||
no_of_docs = frappe.db.count(docfield['parent'], {
|
||||
docfield['fieldname'] : self.company
|
||||
})
|
||||
|
||||
if no_of_docs > 0:
|
||||
self.delete_version_log(docfield['parent'], docfield['fieldname'])
|
||||
self.delete_communications(docfield['parent'], docfield['fieldname'])
|
||||
|
||||
# populate DocTypes table
|
||||
if docfield['parent'] not in tables:
|
||||
self.append('doctypes', {
|
||||
'doctype_name' : docfield['parent'],
|
||||
'no_of_docs' : no_of_docs
|
||||
})
|
||||
|
||||
# delete the docs linked with the specified company
|
||||
frappe.db.delete(docfield['parent'], {
|
||||
docfield['fieldname'] : self.company
|
||||
})
|
||||
|
||||
naming_series = frappe.db.get_value('DocType', docfield['parent'], 'autoname')
|
||||
if naming_series:
|
||||
if '#' in naming_series:
|
||||
self.update_naming_series(naming_series, docfield['parent'])
|
||||
self.delete_company_transactions()
|
||||
|
||||
def populate_doctypes_to_be_ignored_table(self):
|
||||
doctypes_to_be_ignored_list = get_doctypes_to_be_ignored()
|
||||
@@ -79,6 +38,111 @@ class TransactionDeletionRecord(Document):
|
||||
'doctype_name' : doctype
|
||||
})
|
||||
|
||||
def delete_bins(self):
|
||||
frappe.db.sql("""delete from tabBin where warehouse in
|
||||
(select name from tabWarehouse where company=%s)""", self.company)
|
||||
|
||||
def delete_lead_addresses(self):
|
||||
"""Delete addresses to which leads are linked"""
|
||||
leads = frappe.get_all('Lead', filters={'company': self.company})
|
||||
leads = ["'%s'" % row.get("name") for row in leads]
|
||||
addresses = []
|
||||
if leads:
|
||||
addresses = frappe.db.sql_list("""select parent from `tabDynamic Link` where link_name
|
||||
in ({leads})""".format(leads=",".join(leads)))
|
||||
|
||||
if addresses:
|
||||
addresses = ["%s" % frappe.db.escape(addr) for addr in addresses]
|
||||
|
||||
frappe.db.sql("""delete from tabAddress where name in ({addresses}) and
|
||||
name not in (select distinct dl1.parent from `tabDynamic Link` dl1
|
||||
inner join `tabDynamic Link` dl2 on dl1.parent=dl2.parent
|
||||
and dl1.link_doctype<>dl2.link_doctype)""".format(addresses=",".join(addresses)))
|
||||
|
||||
frappe.db.sql("""delete from `tabDynamic Link` where link_doctype='Lead'
|
||||
and parenttype='Address' and link_name in ({leads})""".format(leads=",".join(leads)))
|
||||
|
||||
frappe.db.sql("""update tabCustomer set lead_name=NULL where lead_name in ({leads})""".format(leads=",".join(leads)))
|
||||
|
||||
def reset_company_values(self):
|
||||
company_obj = frappe.get_doc('Company', self.company)
|
||||
company_obj.total_monthly_sales = 0
|
||||
company_obj.sales_monthly_history = None
|
||||
company_obj.save()
|
||||
|
||||
def delete_company_transactions(self):
|
||||
doctypes_to_be_ignored_list = self.get_doctypes_to_be_ignored_list()
|
||||
docfields = self.get_doctypes_with_company_field(doctypes_to_be_ignored_list)
|
||||
|
||||
tables = self.get_all_child_doctypes()
|
||||
for docfield in docfields:
|
||||
if docfield['parent'] != self.doctype:
|
||||
no_of_docs = self.get_number_of_docs_linked_with_specified_company(docfield['parent'], docfield['fieldname'])
|
||||
|
||||
if no_of_docs > 0:
|
||||
self.delete_version_log(docfield['parent'], docfield['fieldname'])
|
||||
self.delete_communications(docfield['parent'], docfield['fieldname'])
|
||||
self.populate_doctypes_table(tables, docfield['parent'], no_of_docs)
|
||||
|
||||
self.delete_child_tables(docfield['parent'], docfield['fieldname'])
|
||||
self.delete_docs_linked_with_specified_company(docfield['parent'], docfield['fieldname'])
|
||||
|
||||
naming_series = frappe.db.get_value('DocType', docfield['parent'], 'autoname')
|
||||
if naming_series:
|
||||
if '#' in naming_series:
|
||||
self.update_naming_series(naming_series, docfield['parent'])
|
||||
|
||||
def get_doctypes_to_be_ignored_list(self):
|
||||
singles = frappe.get_all('DocType', filters = {'issingle': 1}, pluck = 'name')
|
||||
doctypes_to_be_ignored_list = singles
|
||||
for doctype in self.doctypes_to_be_ignored:
|
||||
doctypes_to_be_ignored_list.append(doctype.doctype_name)
|
||||
|
||||
return doctypes_to_be_ignored_list
|
||||
|
||||
def get_doctypes_with_company_field(self, doctypes_to_be_ignored_list):
|
||||
docfields = frappe.get_all('DocField',
|
||||
filters = {
|
||||
'fieldtype': 'Link',
|
||||
'options': 'Company',
|
||||
'parent': ['not in', doctypes_to_be_ignored_list]},
|
||||
fields=['parent', 'fieldname'])
|
||||
|
||||
return docfields
|
||||
|
||||
def get_all_child_doctypes(self):
|
||||
return frappe.get_all('DocType', filters = {'istable': 1}, pluck = 'name')
|
||||
|
||||
def get_number_of_docs_linked_with_specified_company(self, doctype, company_fieldname):
|
||||
return frappe.db.count(doctype, {company_fieldname : self.company})
|
||||
|
||||
def populate_doctypes_table(self, tables, doctype, no_of_docs):
|
||||
if doctype not in tables:
|
||||
self.append('doctypes', {
|
||||
'doctype_name' : doctype,
|
||||
'no_of_docs' : no_of_docs
|
||||
})
|
||||
|
||||
def delete_child_tables(self, doctype, company_fieldname):
|
||||
parent_docs_to_be_deleted = frappe.get_all(doctype, {
|
||||
company_fieldname : self.company
|
||||
}, pluck = 'name')
|
||||
|
||||
child_tables = frappe.get_all('DocField', filters = {
|
||||
'fieldtype': 'Table',
|
||||
'parent': doctype
|
||||
}, pluck = 'options')
|
||||
|
||||
for table in child_tables:
|
||||
frappe.db.delete(table, {
|
||||
'parent': ['in', parent_docs_to_be_deleted]
|
||||
})
|
||||
|
||||
def delete_docs_linked_with_specified_company(self, doctype, company_fieldname):
|
||||
frappe.db.delete(doctype, {
|
||||
company_fieldname : self.company
|
||||
})
|
||||
|
||||
def update_naming_series(self, naming_series, doctype_name):
|
||||
if '.' in naming_series:
|
||||
prefix, hashes = naming_series.rsplit('.', 1)
|
||||
@@ -107,32 +171,6 @@ class TransactionDeletionRecord(Document):
|
||||
|
||||
frappe.delete_doc('Communication', communication_names, ignore_permissions=True)
|
||||
|
||||
def delete_bins(self):
|
||||
frappe.db.sql("""delete from tabBin where warehouse in
|
||||
(select name from tabWarehouse where company=%s)""", self.company)
|
||||
|
||||
def delete_lead_addresses(self):
|
||||
"""Delete addresses to which leads are linked"""
|
||||
leads = frappe.get_all('Lead', filters={'company': self.company})
|
||||
leads = ["'%s'" % row.get("name") for row in leads]
|
||||
addresses = []
|
||||
if leads:
|
||||
addresses = frappe.db.sql_list("""select parent from `tabDynamic Link` where link_name
|
||||
in ({leads})""".format(leads=",".join(leads)))
|
||||
|
||||
if addresses:
|
||||
addresses = ["%s" % frappe.db.escape(addr) for addr in addresses]
|
||||
|
||||
frappe.db.sql("""delete from tabAddress where name in ({addresses}) and
|
||||
name not in (select distinct dl1.parent from `tabDynamic Link` dl1
|
||||
inner join `tabDynamic Link` dl2 on dl1.parent=dl2.parent
|
||||
and dl1.link_doctype<>dl2.link_doctype)""".format(addresses=",".join(addresses)))
|
||||
|
||||
frappe.db.sql("""delete from `tabDynamic Link` where link_doctype='Lead'
|
||||
and parenttype='Address' and link_name in ({leads})""".format(leads=",".join(leads)))
|
||||
|
||||
frappe.db.sql("""update tabCustomer set lead_name=NULL where lead_name in ({leads})""".format(leads=",".join(leads)))
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_doctypes_to_be_ignored():
|
||||
doctypes_to_be_ignored_list = ['Account', 'Cost Center', 'Warehouse', 'Budget',
|
||||
|
||||
@@ -1164,33 +1164,292 @@
|
||||
},
|
||||
|
||||
"India": {
|
||||
"tax_categories": [
|
||||
{
|
||||
"title": "In-State",
|
||||
"is_inter_state": 0,
|
||||
"gst_state": ""
|
||||
},
|
||||
{
|
||||
"title": "Out-State",
|
||||
"is_inter_state": 1,
|
||||
"gst_state": ""
|
||||
},
|
||||
{
|
||||
"title": "Reverse Charge In-State",
|
||||
"is_inter_state": 0,
|
||||
"gst_state": ""
|
||||
},
|
||||
{
|
||||
"title": "Reverse Charge Out-State",
|
||||
"is_inter_state": 1,
|
||||
"gst_state": ""
|
||||
},
|
||||
{
|
||||
"title": "Registered Composition",
|
||||
"is_inter_state": 0,
|
||||
"gst_state": ""
|
||||
}
|
||||
],
|
||||
"chart_of_accounts": {
|
||||
"*": {
|
||||
"item_tax_templates": [
|
||||
{
|
||||
"title": "In State GST",
|
||||
"title": "GST 9%",
|
||||
"taxes": [
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "SGST",
|
||||
"account_name": "Output Tax SGST",
|
||||
"tax_rate": 9.00
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "CGST",
|
||||
"account_name": "Output Tax CGST",
|
||||
"tax_rate": 9.00
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Output Tax IGST",
|
||||
"tax_rate": 18.00
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax SGST",
|
||||
"tax_rate": 9.00,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax CGST",
|
||||
"tax_rate": 9.00,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax IGST",
|
||||
"tax_rate": 18.00,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax SGST RCM",
|
||||
"tax_rate": 9.00,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax CGST RCM",
|
||||
"tax_rate": 9.00,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax IGST RCM",
|
||||
"tax_rate": 18.00,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Out of State GST",
|
||||
"title": "GST 5%",
|
||||
"taxes": [
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "IGST",
|
||||
"tax_rate": 18.00
|
||||
"account_name": "Output Tax SGST",
|
||||
"tax_rate": 2.5
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Output Tax CGST",
|
||||
"tax_rate": 2.5
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Output Tax IGST",
|
||||
"tax_rate": 5.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax SGST",
|
||||
"tax_rate": 2.5,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax CGST",
|
||||
"tax_rate": 2.5,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax IGST",
|
||||
"tax_rate": 5.0,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax SGST RCM",
|
||||
"tax_rate": 2.50,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax CGST RCM",
|
||||
"tax_rate": 2.50,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax IGST RCM",
|
||||
"tax_rate": 5.00,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "GST 12%",
|
||||
"taxes": [
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Output Tax SGST",
|
||||
"tax_rate": 6.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Output Tax CGST",
|
||||
"tax_rate": 6.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Output Tax IGST",
|
||||
"tax_rate": 12.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax SGST",
|
||||
"tax_rate": 6.0,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax CGST",
|
||||
"tax_rate": 6.0,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax IGST",
|
||||
"tax_rate": 12.0,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax SGST RCM",
|
||||
"tax_rate": 6.00,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax CGST RCM",
|
||||
"tax_rate": 6.00,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax IGST RCM",
|
||||
"tax_rate": 12.00,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "GST 28%",
|
||||
"taxes": [
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Output Tax SGST",
|
||||
"tax_rate": 14.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Output Tax CGST",
|
||||
"tax_rate": 14.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Output Tax IGST",
|
||||
"tax_rate": 28.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax SGST",
|
||||
"tax_rate": 14.0,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax CGST",
|
||||
"tax_rate": 14.0,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax IGST",
|
||||
"tax_rate": 28.0,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax SGST RCM",
|
||||
"tax_rate": 14.00,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax CGST RCM",
|
||||
"tax_rate": 14.00,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tax_type": {
|
||||
"account_name": "Input Tax IGST RCM",
|
||||
"tax_rate": 28.00,
|
||||
"root_type": "Asset"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -1229,35 +1488,116 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"*": [
|
||||
"sales_tax_templates": [
|
||||
{
|
||||
"title": "In State GST",
|
||||
"title": "Output GST In-state",
|
||||
"taxes": [
|
||||
{
|
||||
"account_head": {
|
||||
"account_name": "SGST",
|
||||
"tax_rate": 9.00
|
||||
"account_name": "Output Tax SGST",
|
||||
"tax_rate": 9.00,
|
||||
"account_type": "Tax"
|
||||
}
|
||||
},
|
||||
{
|
||||
"account_head": {
|
||||
"account_name": "CGST",
|
||||
"tax_rate": 9.00
|
||||
"account_name": "Output Tax CGST",
|
||||
"tax_rate": 9.00,
|
||||
"account_type": "Tax"
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"tax_category": "In-State"
|
||||
},
|
||||
{
|
||||
"title": "Out of State GST",
|
||||
"title": "Output GST Out-state",
|
||||
"taxes": [
|
||||
{
|
||||
"account_head": {
|
||||
"account_name": "IGST",
|
||||
"tax_rate": 18.00
|
||||
"account_name": "Output Tax IGST",
|
||||
"tax_rate": 18.00,
|
||||
"account_type": "Tax"
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"tax_category": "Out-State"
|
||||
}
|
||||
],
|
||||
"purchase_tax_templates": [
|
||||
{
|
||||
"title": "Input GST In-state",
|
||||
"taxes": [
|
||||
{
|
||||
"account_head": {
|
||||
"account_name": "Input Tax SGST",
|
||||
"tax_rate": 9.00,
|
||||
"root_type": "Asset",
|
||||
"account_type": "Tax"
|
||||
}
|
||||
},
|
||||
{
|
||||
"account_head": {
|
||||
"account_name": "Input Tax CGST",
|
||||
"tax_rate": 9.00,
|
||||
"root_type": "Asset",
|
||||
"account_type": "Tax"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tax_category": "In-State"
|
||||
},
|
||||
{
|
||||
"title": "Input GST Out-state",
|
||||
"taxes": [
|
||||
{
|
||||
"account_head": {
|
||||
"account_name": "Input Tax IGST",
|
||||
"tax_rate": 18.00,
|
||||
"root_type": "Asset",
|
||||
"account_type": "Tax"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tax_category": "Out-State"
|
||||
},
|
||||
{
|
||||
"title": "Input GST RCM In-state",
|
||||
"taxes": [
|
||||
{
|
||||
"account_head": {
|
||||
"account_name": "Input Tax SGST RCM",
|
||||
"tax_rate": 9.00,
|
||||
"root_type": "Asset",
|
||||
"account_type": "Tax"
|
||||
}
|
||||
},
|
||||
{
|
||||
"account_head": {
|
||||
"account_name": "Input Tax CGST RCM",
|
||||
"tax_rate": 9.00,
|
||||
"root_type": "Asset",
|
||||
"account_type": "Tax"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tax_category": "Reverse Charge In-State"
|
||||
},
|
||||
{
|
||||
"title": "Input GST RCM Out-state",
|
||||
"taxes": [
|
||||
{
|
||||
"account_head": {
|
||||
"account_name": "Input Tax IGST RCM",
|
||||
"tax_rate": 18.00,
|
||||
"root_type": "Asset",
|
||||
"account_type": "Tax"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tax_category": "Reverse Charge Out-State"
|
||||
}
|
||||
],
|
||||
"*": [
|
||||
{
|
||||
"title": "VAT 5%",
|
||||
"taxes": [
|
||||
@@ -1349,7 +1689,7 @@
|
||||
"Italy VAT 4%":{
|
||||
"account_name": "IVA 4%",
|
||||
"tax_rate": 4.00
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"Ivory Coast": {
|
||||
|
||||
@@ -42,29 +42,6 @@ def enable_shopping_cart(args):
|
||||
'quotation_series': "QTN-",
|
||||
}).insert()
|
||||
|
||||
def create_bank_account(args):
|
||||
if args.get("bank_account"):
|
||||
company_name = args.get('company_name')
|
||||
bank_account_group = frappe.db.get_value("Account",
|
||||
{"account_type": "Bank", "is_group": 1, "root_type": "Asset",
|
||||
"company": company_name})
|
||||
if bank_account_group:
|
||||
bank_account = frappe.get_doc({
|
||||
"doctype": "Account",
|
||||
'account_name': args.get("bank_account"),
|
||||
'parent_account': bank_account_group,
|
||||
'is_group':0,
|
||||
'company': company_name,
|
||||
"account_type": "Bank",
|
||||
})
|
||||
try:
|
||||
return bank_account.insert()
|
||||
except RootNotEditable:
|
||||
frappe.throw(_("Bank account cannot be named as {0}").format(args.get("bank_account")))
|
||||
except frappe.DuplicateEntryError:
|
||||
# bank account same as a CoA entry
|
||||
pass
|
||||
|
||||
def create_email_digest():
|
||||
from frappe.utils.user import get_system_managers
|
||||
system_managers = get_system_managers(only_name=True)
|
||||
|
||||
@@ -448,6 +448,8 @@ def install_defaults(args=None):
|
||||
set_active_domains(args)
|
||||
update_stock_settings()
|
||||
update_shopping_cart_settings(args)
|
||||
|
||||
args.update({"set_default": 1})
|
||||
create_bank_account(args)
|
||||
|
||||
def set_global_defaults(args):
|
||||
@@ -479,17 +481,17 @@ def update_stock_settings():
|
||||
stock_settings.save()
|
||||
|
||||
def create_bank_account(args):
|
||||
if not args.bank_account:
|
||||
if not args.get('bank_account'):
|
||||
return
|
||||
|
||||
company_name = args.company_name
|
||||
company_name = args.get('company_name')
|
||||
bank_account_group = frappe.db.get_value("Account",
|
||||
{"account_type": "Bank", "is_group": 1, "root_type": "Asset",
|
||||
"company": company_name})
|
||||
if bank_account_group:
|
||||
bank_account = frappe.get_doc({
|
||||
"doctype": "Account",
|
||||
'account_name': args.bank_account,
|
||||
'account_name': args.get('bank_account'),
|
||||
'parent_account': bank_account_group,
|
||||
'is_group':0,
|
||||
'company': company_name,
|
||||
@@ -498,10 +500,13 @@ def create_bank_account(args):
|
||||
try:
|
||||
doc = bank_account.insert()
|
||||
|
||||
frappe.db.set_value("Company", args.company_name, "default_bank_account", bank_account.name, update_modified=False)
|
||||
if args.get('set_default'):
|
||||
frappe.db.set_value("Company", args.get('company_name'), "default_bank_account", bank_account.name, update_modified=False)
|
||||
|
||||
return doc
|
||||
|
||||
except RootNotEditable:
|
||||
frappe.throw(_("Bank account cannot be named as {0}").format(args.bank_account))
|
||||
frappe.throw(_("Bank account cannot be named as {0}").format(args.get('bank_account')))
|
||||
except frappe.DuplicateEntryError:
|
||||
# bank account same as a CoA entry
|
||||
pass
|
||||
|
||||
@@ -27,6 +27,7 @@ def setup_taxes_and_charges(company_name: str, country: str):
|
||||
country_wise_tax = simple_to_detailed(country_wise_tax)
|
||||
|
||||
from_detailed_data(company_name, country_wise_tax)
|
||||
update_regional_tax_settings(country, company_name)
|
||||
|
||||
|
||||
def simple_to_detailed(templates):
|
||||
@@ -86,7 +87,7 @@ def from_detailed_data(company_name, data):
|
||||
|
||||
if tax_categories:
|
||||
for tax_category in tax_categories:
|
||||
make_tax_catgory(tax_category)
|
||||
make_tax_category(tax_category)
|
||||
|
||||
if sales_tax_templates:
|
||||
for template in sales_tax_templates:
|
||||
@@ -101,6 +102,17 @@ def from_detailed_data(company_name, data):
|
||||
make_item_tax_template(company_name, template)
|
||||
|
||||
|
||||
def update_regional_tax_settings(country, company):
|
||||
path = frappe.get_app_path('erpnext', 'regional', frappe.scrub(country))
|
||||
if os.path.exists(path.encode("utf-8")):
|
||||
try:
|
||||
module_name = "erpnext.regional.{0}.setup.update_regional_tax_settings".format(frappe.scrub(country))
|
||||
frappe.get_attr(module_name)(country, company)
|
||||
except Exception as e:
|
||||
# Log error and ignore if failed to setup regional tax settings
|
||||
frappe.log_error()
|
||||
pass
|
||||
|
||||
def make_taxes_and_charges_template(company_name, doctype, template):
|
||||
template['company'] = company_name
|
||||
template['doctype'] = doctype
|
||||
@@ -130,8 +142,14 @@ def make_taxes_and_charges_template(company_name, doctype, template):
|
||||
if fieldname not in tax_row:
|
||||
tax_row[fieldname] = default_value
|
||||
|
||||
return frappe.get_doc(template).insert(ignore_permissions=True)
|
||||
doc = frappe.get_doc(template)
|
||||
|
||||
# Data in country wise json is already pre validated, hence validations can be ignored
|
||||
# Ingone validations to make doctypes faster
|
||||
doc.flags.ignore_links = True
|
||||
doc.flags.ignore_validate = True
|
||||
doc.insert(ignore_permissions=True)
|
||||
return doc
|
||||
|
||||
def make_item_tax_template(company_name, template):
|
||||
"""Create an Item Tax Template.
|
||||
@@ -156,8 +174,14 @@ def make_item_tax_template(company_name, template):
|
||||
if 'tax_rate' not in tax_row:
|
||||
tax_row['tax_rate'] = account_data.get('tax_rate')
|
||||
|
||||
return frappe.get_doc(template).insert(ignore_permissions=True)
|
||||
doc = frappe.get_doc(template)
|
||||
|
||||
# Data in country wise json is already pre validated, hence validations can be ignored
|
||||
# Ingone validations to make doctypes faster
|
||||
doc.flags.ignore_links = True
|
||||
doc.flags.ignore_validate = True
|
||||
doc.insert(ignore_permissions=True)
|
||||
return doc
|
||||
|
||||
def get_or_create_account(company_name, account):
|
||||
"""
|
||||
@@ -175,8 +199,7 @@ def get_or_create_account(company_name, account):
|
||||
or_filters={
|
||||
'account_name': account.get('account_name'),
|
||||
'account_number': account.get('account_number')
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
if existing_accounts:
|
||||
return frappe.get_doc('Account', existing_accounts[0].name)
|
||||
@@ -191,8 +214,11 @@ def get_or_create_account(company_name, account):
|
||||
account['root_type'] = root_type
|
||||
account['is_group'] = 0
|
||||
|
||||
return frappe.get_doc(account).insert(ignore_permissions=True, ignore_mandatory=True)
|
||||
|
||||
doc = frappe.get_doc(account)
|
||||
doc.flags.ignore_links = True
|
||||
doc.flags.ignore_validate = True
|
||||
doc.insert(ignore_permissions=True, ignore_mandatory=True)
|
||||
return doc
|
||||
|
||||
def get_or_create_tax_group(company_name, root_type):
|
||||
# Look for a group account of type 'Tax'
|
||||
@@ -237,14 +263,18 @@ def get_or_create_tax_group(company_name, root_type):
|
||||
'account_type': 'Tax',
|
||||
'account_name': account_name,
|
||||
'parent_account': root_account.name
|
||||
}).insert(ignore_permissions=True)
|
||||
})
|
||||
|
||||
tax_group_account.flags.ignore_links = True
|
||||
tax_group_account.flags.ignore_validate = True
|
||||
tax_group_account.insert(ignore_permissions=True)
|
||||
|
||||
tax_group_name = tax_group_account.name
|
||||
|
||||
return tax_group_name
|
||||
|
||||
|
||||
def make_tax_catgory(tax_category):
|
||||
def make_tax_category(tax_category):
|
||||
doctype = 'Tax Category'
|
||||
if isinstance(tax_category, str):
|
||||
tax_category = {'title': tax_category}
|
||||
|
||||
@@ -28,21 +28,21 @@ def before_tests():
|
||||
from frappe.desk.page.setup_wizard.setup_wizard import setup_complete
|
||||
if not frappe.get_list("Company"):
|
||||
setup_complete({
|
||||
"currency" :"USD",
|
||||
"full_name" :"Test User",
|
||||
"company_name" :"Wind Power LLC",
|
||||
"timezone" :"America/New_York",
|
||||
"company_abbr" :"WP",
|
||||
"industry" :"Manufacturing",
|
||||
"country" :"United States",
|
||||
"fy_start_date" :"2011-01-01",
|
||||
"fy_end_date" :"2011-12-31",
|
||||
"language" :"english",
|
||||
"company_tagline" :"Testing",
|
||||
"email" :"test@erpnext.com",
|
||||
"password" :"test",
|
||||
"currency" :"USD",
|
||||
"full_name" :"Test User",
|
||||
"company_name" :"Wind Power LLC",
|
||||
"timezone" :"America/New_York",
|
||||
"company_abbr" :"WP",
|
||||
"industry" :"Manufacturing",
|
||||
"country" :"United States",
|
||||
"fy_start_date" :"2021-01-01",
|
||||
"fy_end_date" :"2021-12-31",
|
||||
"language" :"english",
|
||||
"company_tagline" :"Testing",
|
||||
"email" :"test@erpnext.com",
|
||||
"password" :"test",
|
||||
"chart_of_accounts" : "Standard",
|
||||
"domains" : ["Manufacturing"],
|
||||
"domains" : ["Manufacturing"],
|
||||
})
|
||||
|
||||
frappe.db.sql("delete from `tabLeave Allocation`")
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
"hide_custom": 0,
|
||||
"icon": "settings",
|
||||
"idx": 0,
|
||||
"is_default": 0,
|
||||
"is_standard": 1,
|
||||
"label": "ERPNext Settings",
|
||||
"links": [],
|
||||
"modified": "2020-12-01 13:38:37.759596",
|
||||
"modified": "2021-06-12 01:58:11.399566",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "ERPNext Settings",
|
||||
@@ -109,6 +110,13 @@
|
||||
"label": "Domain Settings",
|
||||
"link_to": "Domain Settings",
|
||||
"type": "DocType"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"icon": "retail",
|
||||
"label": "Products Settings",
|
||||
"link_to": "Products Settings",
|
||||
"type": "DocType"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user