[gst] adde reports + docs

This commit is contained in:
Rushabh Mehta
2017-06-22 16:37:04 +05:30
parent b3c8f44b3e
commit 919a74ad88
40 changed files with 676 additions and 225 deletions

View File

@@ -0,0 +1,8 @@
{{ address_line1 }}<br>{% if address_line2 %}{{ address_line2 }}<br>{% endif -%}{{ city }}<br>
{% if state %}{{ state }}<br>{% endif -%}
{% if pincode %}{{ pincode }}<br>{% endif -%}
{{ country }}<br>
{% if gstin %}GSTIN: {{ gstin }}<br>{% endif -%}
{% if phone %}Phone: {{ phone }}<br>{% endif -%}
{% if fax %}Fax: {{ fax }}<br>{% endif -%}
{% if email_id %}Email: {{ email_id }}<br>{% endif -%}

View File

@@ -8,16 +8,39 @@ from frappe.custom.doctype.custom_field.custom_field import create_custom_field
from frappe.permissions import add_permission
from erpnext.regional.india import states
def install(company):
def setup(company=None):
make_custom_fields()
make_fixtures()
add_permissions()
add_custom_roles_for_reports()
add_hsn_codes()
update_address_template()
def update_address_template():
with open(os.path.join(os.path.dirname(__file__), 'address_template.html'), 'r') as f:
html = f.read()
address_template = frappe.db.get_value('Address Template', 'India')
if address_template:
frappe.db.set_value('Address Template', 'India', 'template', html)
else:
# make new html template for India
frappe.get_doc(
doctype='Address Template',
country='India',
template=html
).insert()
def add_hsn_codes():
frappe.reload_doc('regional', 'doctype', 'gst_hsn_code')
if frappe.db.count('GST HSN Code') > 100:
return
with open(os.path.join(os.path.dirname(__file__), 'hsn_code_data.json'), 'r') as f:
hsn_codes = json.loads(f.read())
frappe.db.commit()
frappe.db.sql('truncate `tabGST HSN Code`')
for d in hsn_codes:
@@ -26,6 +49,24 @@ def add_hsn_codes():
hsn_code.name = hsn_code.hsn_code
hsn_code.db_insert()
frappe.db.commit()
def add_custom_roles_for_reports():
for report_name in ('GST Sales Register', 'GST Purchase Register',
'GST Itemised Sales Register', 'GST Itemised Purchase Register'):
frappe.reload_doc('regional', 'report', frappe.scrub(report_name))
if not frappe.db.get_value('Custom Role', dict(report=report_name)):
frappe.get_doc(dict(
doctype='Custom Role',
report=report_name,
roles= [
dict(role='Accounts User'),
dict(role='Accounts Manager')
]
)).insert()
def add_permissions():
for doctype in ('GST HSN Code',):
add_permission(doctype, 'Accounts Manager', 0)
@@ -34,23 +75,26 @@ def add_permissions():
def make_custom_fields():
custom_fields = {
'Address': [
dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data', insert_after='fax'),
dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data',
insert_after='fax'),
dict(fieldname='gst_state', label='GST State', fieldtype='Select',
options='\n'.join(states), insert_after='gstin')
],
'Purchase Invoice': [
dict(fieldname='supplier_gstin', label='Supplier GSTIN',
fieldtype='Data', insert_after='supplier_address', options='supplier_address.gstin'),
fieldtype='Data', insert_after='supplier_address',
options='supplier_address.gstin'),
dict(fieldname='company_gstin', label='Company GSTIN',
fieldtype='Data', insert_after='fax', options='shipping_address.gstin'),
fieldtype='Data', insert_after='shipping_address',
options='shipping_address.gstin'),
],
'Sales Invoice': [
dict(fieldname='customer_gstin', label='Customer GSTIN',
fieldtype='Data', insert_after='shipping_address', options='shipping_address.gstin'),
dict(fieldname='company_address', label='Company Address',
fieldtype='Link', insert_after='shipping_address', options='Address'),
fieldtype='Data', insert_after='shipping_address',
options='shipping_address_name.gstin'),
dict(fieldname='company_gstin', label='Company GSTIN',
fieldtype='Data', insert_after='fax', options='company_address.gstin'),
fieldtype='Data', insert_after='company_address',
options='company_address.gstin'),
],
'Item': [
dict(fieldname='gst_hsn_code', label='GST HSN Code',
@@ -58,11 +102,13 @@ def make_custom_fields():
],
'Sales Invoice Item': [
dict(fieldname='gst_hsn_code', label='GST HSN Code',
fieldtype='Data', options='item_code.gst_hsn_code', insert_after='income_account'),
fieldtype='Data', options='item_code.gst_hsn_code',
insert_after='income_account'),
],
'Purchase Invoice Item': [
dict(fieldname='gst_hsn_code', label='GST HSN Code',
fieldtype='Data', options='item_code.gst_hsn_code', insert_after='expense_account'),
fieldtype='Data', options='item_code.gst_hsn_code',
insert_after='expense_account'),
]
}