mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-28 22:28:24 +00:00
Merge pull request #9435 from rmehta/gst
GST (India) Setup and Invoices #8711
This commit is contained in:
@@ -17,6 +17,8 @@ frappe.ui.form.on("Company", {
|
||||
if(!frm.doc.__islocal) {
|
||||
frappe.contacts.render_address_and_contact(frm);
|
||||
|
||||
frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Company'}
|
||||
|
||||
frm.toggle_enable("default_currency", (frm.doc.__onload &&
|
||||
!frm.doc.__onload.transactions_exist));
|
||||
|
||||
@@ -34,7 +36,7 @@ frappe.ui.form.on("Company", {
|
||||
},
|
||||
|
||||
onload_post_render: function(frm) {
|
||||
if(frm.get_field("delete_company_transactions").$input)
|
||||
if(frm.get_field("delete_company_transactions").$input)
|
||||
frm.get_field("delete_company_transactions").$input.addClass("btn-danger");
|
||||
},
|
||||
country: function(frm) {
|
||||
@@ -144,7 +146,7 @@ erpnext.company.setup_queries = function(frm) {
|
||||
["round_off_account", {"root_type": "Expense"}],
|
||||
["write_off_account", {"root_type": "Expense"}],
|
||||
["exchange_gain_loss_account", {"root_type": "Expense"}],
|
||||
["accumulated_depreciation_account",
|
||||
["accumulated_depreciation_account",
|
||||
{"root_type": "Asset", "account_type": "Accumulated Depreciation"}],
|
||||
["depreciation_expense_account", {"root_type": "Expense", "account_type": "Depreciation"}],
|
||||
["disposal_account", {"report_type": "Profit and Loss"}],
|
||||
@@ -158,11 +160,11 @@ erpnext.company.setup_queries = function(frm) {
|
||||
|
||||
if (frm.doc.enable_perpetual_inventory) {
|
||||
$.each([
|
||||
["stock_adjustment_account",
|
||||
["stock_adjustment_account",
|
||||
{"root_type": "Expense", "account_type": "Stock Adjustment"}],
|
||||
["expenses_included_in_valuation",
|
||||
["expenses_included_in_valuation",
|
||||
{"root_type": "Expense", "account_type": "Expenses Included in Valuation"}],
|
||||
["stock_received_but_not_billed",
|
||||
["stock_received_but_not_billed",
|
||||
{"root_type": "Liability", "account_type": "Stock Received But Not Billed"}]
|
||||
], function(i, v) {
|
||||
erpnext.company.set_custom_query(frm, v);
|
||||
|
||||
@@ -51,10 +51,10 @@ class Company(Document):
|
||||
frappe.throw(_("Abbreviation already used for another company"))
|
||||
|
||||
def validate_default_accounts(self):
|
||||
for field in ["default_bank_account", "default_cash_account",
|
||||
"default_receivable_account", "default_payable_account",
|
||||
"default_expense_account", "default_income_account",
|
||||
"stock_received_but_not_billed", "stock_adjustment_account",
|
||||
for field in ["default_bank_account", "default_cash_account",
|
||||
"default_receivable_account", "default_payable_account",
|
||||
"default_expense_account", "default_income_account",
|
||||
"stock_received_but_not_billed", "stock_adjustment_account",
|
||||
"expenses_included_in_valuation", "default_payroll_payable_account"]:
|
||||
if self.get(field):
|
||||
for_company = frappe.db.get_value("Account", self.get(field), "company")
|
||||
@@ -96,9 +96,9 @@ class Company(Document):
|
||||
frappe.clear_cache()
|
||||
|
||||
def install_country_fixtures(self):
|
||||
path = os.path.join(os.path.dirname(__file__), "fixtures", self.country.lower())
|
||||
path = frappe.get_app_path('erpnext', 'regional', frappe.scrub(self.country))
|
||||
if os.path.exists(path.encode("utf-8")):
|
||||
frappe.get_attr("erpnext.setup.doctype.company.fixtures.{0}.install"
|
||||
frappe.get_attr("erpnext.regional.{0}.setup.setup"
|
||||
.format(self.country.lower()))(self)
|
||||
|
||||
def create_default_warehouses(self):
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
# 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
|
||||
|
||||
def install(company):
|
||||
docs = [
|
||||
{'doctype': 'Salary Component', 'salary_component': 'Professional Tax', 'description': 'Professional Tax', 'type': 'Deduction'},
|
||||
{'doctype': 'Salary Component', 'salary_component': 'Provident Fund', 'description': 'Provident fund', 'type': 'Deduction'},
|
||||
{'doctype': 'Salary Component', 'salary_component': 'House Rent Allowance', 'description': 'House Rent Allowance', 'type': 'Earning'},
|
||||
{'doctype': 'Salary Component', 'salary_component': 'Basic', 'description': 'Basic', 'type': 'Earning'},
|
||||
{'doctype': 'Salary Component', 'salary_component': 'Arrear', 'description': 'Arrear', 'type': 'Earning'},
|
||||
{'doctype': 'Salary Component', 'salary_component': 'Leave Encashment', 'description': 'Leave Encashment', 'type': 'Earning'}
|
||||
]
|
||||
|
||||
for d in docs:
|
||||
try:
|
||||
doc = frappe.get_doc(d)
|
||||
doc.flags.ignore_permissions = True
|
||||
doc.insert()
|
||||
except frappe.NameError:
|
||||
pass
|
||||
@@ -584,16 +584,24 @@
|
||||
},
|
||||
|
||||
"India": {
|
||||
"India VAT 5%": {
|
||||
"account_name": "VAT 5%",
|
||||
"tax_rate": 5.00,
|
||||
"In State GST": {
|
||||
"account_name": ["SGST", "CGST"],
|
||||
"tax_rate": [9.00, 9.00],
|
||||
"default": 1
|
||||
},
|
||||
"India VAT 4%": {
|
||||
"Out of State GST": {
|
||||
"account_name": "IGST",
|
||||
"tax_rate": 18.00
|
||||
},
|
||||
"VAT 5%": {
|
||||
"account_name": "VAT 5%",
|
||||
"tax_rate": 5.00
|
||||
},
|
||||
"VAT 4%": {
|
||||
"account_name": "VAT 4%",
|
||||
"tax_rate": 4.00
|
||||
},
|
||||
"India VAT 14%": {
|
||||
"VAT 14%": {
|
||||
"account_name": "VAT 14%",
|
||||
"tax_rate": 14.00
|
||||
}
|
||||
|
||||
56
erpnext/setup/setup_wizard/data/test_mfg.json
Normal file
56
erpnext/setup/setup_wizard/data/test_mfg.json
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"add_sample_data": 1,
|
||||
"bank_account": "HDFC",
|
||||
"company_abbr": "GT",
|
||||
"company_name": "For Testing",
|
||||
"company_tagline": "Just for GST",
|
||||
"country": "India",
|
||||
"currency": "INR",
|
||||
"customer_1": "Test Customer 1",
|
||||
"customer_2": "Test Customer 2",
|
||||
"domain": "Manufacturing",
|
||||
"email": "great@example.com",
|
||||
"full_name": "Great Tester",
|
||||
"fy_end_date": "2018-03-31",
|
||||
"fy_start_date": "2017-04-01",
|
||||
"is_purchase_item_1": 1,
|
||||
"is_purchase_item_2": 1,
|
||||
"is_purchase_item_3": 0,
|
||||
"is_purchase_item_4": 0,
|
||||
"is_purchase_item_5": 0,
|
||||
"is_sales_item_1": 1,
|
||||
"is_sales_item_2": 1,
|
||||
"is_sales_item_3": 1,
|
||||
"is_sales_item_4": 1,
|
||||
"is_sales_item_5": 1,
|
||||
"item_1": "Test Item 1",
|
||||
"item_2": "Test Item 2",
|
||||
"item_group_1": "Products",
|
||||
"item_group_2": "Products",
|
||||
"item_group_3": "Products",
|
||||
"item_group_4": "Products",
|
||||
"item_group_5": "Products",
|
||||
"item_uom_1": "Unit",
|
||||
"item_uom_2": "Unit",
|
||||
"item_uom_3": "Unit",
|
||||
"item_uom_4": "Unit",
|
||||
"item_uom_5": "Unit",
|
||||
"language": "English (United States)",
|
||||
"password": "test",
|
||||
"setup_website": 1,
|
||||
"supplier_1": "Test Supplier 1",
|
||||
"supplier_2": "Test Supplier 2",
|
||||
"timezone": "Asia/Kolkata",
|
||||
"user_accountant_1": 1,
|
||||
"user_accountant_2": 1,
|
||||
"user_accountant_3": 1,
|
||||
"user_accountant_4": 1,
|
||||
"user_purchaser_1": 1,
|
||||
"user_purchaser_2": 1,
|
||||
"user_purchaser_3": 1,
|
||||
"user_purchaser_4": 1,
|
||||
"user_sales_1": 1,
|
||||
"user_sales_2": 1,
|
||||
"user_sales_3": 1,
|
||||
"user_sales_4": 1
|
||||
}
|
||||
@@ -84,7 +84,7 @@ def create_fiscal_year_and_company(args):
|
||||
if (args.get('company_name')):
|
||||
frappe.get_doc({
|
||||
"doctype":"Company",
|
||||
'company_name':args.get('company_name').strip(),
|
||||
'company_name':args.get('company_name'),
|
||||
'enable_perpetual_inventory': 1,
|
||||
'abbr':args.get('company_abbr'),
|
||||
'default_currency':args.get('currency'),
|
||||
@@ -104,7 +104,7 @@ def enable_shopping_cart(args):
|
||||
frappe.get_doc({
|
||||
"doctype": "Shopping Cart Settings",
|
||||
"enabled": 1,
|
||||
'company': args.get('company_name').strip(),
|
||||
'company': args.get('company_name') ,
|
||||
'price_list': frappe.db.get_value("Price List", {"selling": 1}),
|
||||
'default_customer_group': _("Individual"),
|
||||
'quotation_series': "QTN-",
|
||||
@@ -112,7 +112,7 @@ def enable_shopping_cart(args):
|
||||
|
||||
def create_bank_account(args):
|
||||
if args.get("bank_account"):
|
||||
company_name = args.get('company_name').strip()
|
||||
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})
|
||||
@@ -152,7 +152,7 @@ def set_defaults(args):
|
||||
global_defaults.update({
|
||||
'current_fiscal_year': args.curr_fiscal_year,
|
||||
'default_currency': args.get('currency'),
|
||||
'default_company':args.get('company_name').strip(),
|
||||
'default_company':args.get('company_name') ,
|
||||
"country": args.get("country"),
|
||||
})
|
||||
|
||||
@@ -253,8 +253,10 @@ def create_sales_tax(args):
|
||||
country_wise_tax = get_country_wise_tax(args.get("country"))
|
||||
if country_wise_tax and len(country_wise_tax) > 0:
|
||||
for sales_tax, tax_data in country_wise_tax.items():
|
||||
make_tax_account_and_template(args.get("company_name").strip(),
|
||||
tax_data.get('account_name'), tax_data.get('tax_rate'), sales_tax)
|
||||
make_tax_account_and_template(
|
||||
args.get("company_name"),
|
||||
tax_data.get('account_name'),
|
||||
tax_data.get('tax_rate'), sales_tax)
|
||||
|
||||
def get_country_wise_tax(country):
|
||||
data = {}
|
||||
@@ -270,13 +272,20 @@ def create_taxes(args):
|
||||
tax_rate = cstr(args.get("tax_rate_" + str(i)) or "").replace("%", "")
|
||||
account_name = args.get("tax_" + str(i))
|
||||
|
||||
make_tax_account_and_template(args.get("company_name").strip(), account_name, tax_rate)
|
||||
make_tax_account_and_template(args.get("company_name") , account_name, tax_rate)
|
||||
|
||||
def make_tax_account_and_template(company, account_name, tax_rate, template_name=None):
|
||||
try:
|
||||
account = make_tax_account(company, account_name, tax_rate)
|
||||
if account:
|
||||
make_sales_and_purchase_tax_templates(account, template_name)
|
||||
if not isinstance(account_name, (list, tuple)):
|
||||
account_name = [account_name]
|
||||
tax_rate = [tax_rate]
|
||||
|
||||
accounts = []
|
||||
for i, name in enumerate(account_name):
|
||||
accounts.append(make_tax_account(company, account_name[i], tax_rate[i]))
|
||||
|
||||
if accounts:
|
||||
make_sales_and_purchase_tax_templates(accounts, template_name)
|
||||
except frappe.NameError, e:
|
||||
if e.args[2][0]==1062:
|
||||
pass
|
||||
@@ -309,30 +318,34 @@ def make_tax_account(company, account_name, tax_rate):
|
||||
"tax_rate": flt(tax_rate) if tax_rate else None
|
||||
}).insert(ignore_permissions=True)
|
||||
|
||||
def make_sales_and_purchase_tax_templates(account, template_name=None):
|
||||
def make_sales_and_purchase_tax_templates(accounts, template_name=None):
|
||||
if not template_name:
|
||||
template_name = account.name
|
||||
template_name = accounts[0].name
|
||||
|
||||
sales_tax_template = {
|
||||
"doctype": "Sales Taxes and Charges Template",
|
||||
"title": template_name,
|
||||
"company": account.company,
|
||||
"taxes": [{
|
||||
"company": accounts[0].company,
|
||||
'taxes': []
|
||||
}
|
||||
|
||||
for account in accounts:
|
||||
sales_tax_template['taxes'].append({
|
||||
"category": "Valuation and Total",
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": account.name,
|
||||
"description": "{0} @ {1}".format(account.account_name, account.tax_rate),
|
||||
"rate": account.tax_rate
|
||||
}]
|
||||
}
|
||||
|
||||
})
|
||||
# Sales
|
||||
frappe.get_doc(copy.deepcopy(sales_tax_template)).insert(ignore_permissions=True)
|
||||
|
||||
# Purchase
|
||||
purchase_tax_template = copy.deepcopy(sales_tax_template)
|
||||
purchase_tax_template["doctype"] = "Purchase Taxes and Charges Template"
|
||||
frappe.get_doc(purchase_tax_template).insert(ignore_permissions=True)
|
||||
|
||||
doc = frappe.get_doc(purchase_tax_template)
|
||||
doc.insert(ignore_permissions=True)
|
||||
|
||||
def create_items(args):
|
||||
for i in xrange(1,6):
|
||||
@@ -346,7 +359,7 @@ def create_items(args):
|
||||
if is_stock_item:
|
||||
default_warehouse = frappe.db.get_value("Warehouse", filters={
|
||||
"warehouse_name": _("Finished Goods") if is_sales_item else _("Stores"),
|
||||
"company": args.get("company_name").strip()
|
||||
"company": args.get("company_name")
|
||||
})
|
||||
|
||||
try:
|
||||
@@ -405,7 +418,7 @@ def create_customers(args):
|
||||
"customer_type": "Company",
|
||||
"customer_group": _("Commercial"),
|
||||
"territory": args.get("country"),
|
||||
"company": args.get("company_name").strip()
|
||||
"company": args.get("company_name")
|
||||
}).insert()
|
||||
|
||||
if args.get("customer_contact_" + str(i)):
|
||||
@@ -423,7 +436,7 @@ def create_suppliers(args):
|
||||
"doctype":"Supplier",
|
||||
"supplier_name": supplier,
|
||||
"supplier_type": _("Local"),
|
||||
"company": args.get("company_name").strip()
|
||||
"company": args.get("company_name")
|
||||
}).insert()
|
||||
|
||||
if args.get("supplier_contact_" + str(i)):
|
||||
@@ -434,7 +447,7 @@ def create_suppliers(args):
|
||||
|
||||
def create_contact(contact, party_type, party):
|
||||
"""Create contact based on given contact name"""
|
||||
contact = contact.strip().split(" ")
|
||||
contact = contact .split(" ")
|
||||
|
||||
contact = frappe.get_doc({
|
||||
"doctype":"Contact",
|
||||
@@ -466,7 +479,7 @@ def create_logo(args):
|
||||
fileurl = save_file(filename, content, "Website Settings", "Website Settings",
|
||||
decode=True).file_url
|
||||
frappe.db.set_value("Website Settings", "Website Settings", "brand_html",
|
||||
"<img src='{0}' style='max-width: 40px; max-height: 25px;'> {1}".format(fileurl, args.get("company_name").strip()))
|
||||
"<img src='{0}' style='max-width: 40px; max-height: 25px;'> {1}".format(fileurl, args.get("company_name") ))
|
||||
|
||||
def create_territories():
|
||||
"""create two default territories, one for home country and one named Rest of the World"""
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,15 +0,0 @@
|
||||
# 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
|
||||
|
||||
from erpnext.setup.setup_wizard.test_setup_data import args
|
||||
from frappe.desk.page.setup_wizard.setup_wizard import setup_complete
|
||||
import frappe.utils.scheduler
|
||||
|
||||
if __name__=="__main__":
|
||||
frappe.connect()
|
||||
frappe.local.form_dict = frappe._dict(args)
|
||||
setup_complete()
|
||||
frappe.utils.scheduler.disable_scheduler()
|
||||
15
erpnext/setup/setup_wizard/utils.py
Normal file
15
erpnext/setup/setup_wizard/utils.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import json, os
|
||||
|
||||
from frappe.desk.page.setup_wizard.setup_wizard import setup_complete
|
||||
from erpnext.setup.setup_wizard import setup_wizard
|
||||
|
||||
def complete():
|
||||
with open(os.path.join(os.path.dirname(__file__),
|
||||
'data', 'test_mfg.json'), 'r') as f:
|
||||
data = json.loads(f.read())
|
||||
|
||||
#setup_wizard.create_sales_tax(data)
|
||||
setup_complete(data)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user