Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 1 | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors |
| 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | |
| 6 | import frappe, os, json |
Rushabh Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 7 | from frappe.custom.doctype.custom_field.custom_field import create_custom_fields |
Nabin Hait | 49b41e4 | 2019-01-24 17:55:44 +0530 | [diff] [blame] | 8 | from frappe.permissions import add_permission, update_permission_property |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 9 | from erpnext.regional.india import states |
Anuja Pawar | 4569e52 | 2021-01-14 19:24:30 +0530 | [diff] [blame] | 10 | from erpnext.accounts.utils import get_fiscal_year, FiscalYearError |
Zarrar | 7f8024c | 2018-08-01 17:45:05 +0530 | [diff] [blame] | 11 | from frappe.utils import today |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 12 | |
Rushabh Mehta | 0165927 | 2017-06-27 18:05:17 +0530 | [diff] [blame] | 13 | def setup(company=None, patch=True): |
Prateeksha Singh | dabf349 | 2018-11-13 15:56:15 +0530 | [diff] [blame] | 14 | setup_company_independent_fixtures() |
Prateeksha Singh | 39b8765 | 2018-11-12 17:19:56 +0530 | [diff] [blame] | 15 | if not patch: |
Prateeksha Singh | dabf349 | 2018-11-13 15:56:15 +0530 | [diff] [blame] | 16 | make_fixtures(company) |
Prateeksha Singh | 39b8765 | 2018-11-12 17:19:56 +0530 | [diff] [blame] | 17 | |
| 18 | # TODO: for all countries |
| 19 | def setup_company_independent_fixtures(): |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 20 | make_custom_fields() |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 21 | add_permissions() |
Rushabh Mehta | 919a74a | 2017-06-22 16:37:04 +0530 | [diff] [blame] | 22 | add_custom_roles_for_reports() |
Nabin Hait | c314485 | 2017-09-28 18:55:40 +0530 | [diff] [blame] | 23 | frappe.enqueue('erpnext.regional.india.setup.add_hsn_sac_codes', now=frappe.flags.in_test) |
Nabin Hait | 852cb64 | 2017-07-05 12:58:19 +0530 | [diff] [blame] | 24 | add_print_formats() |
Rushabh Mehta | 919a74a | 2017-06-22 16:37:04 +0530 | [diff] [blame] | 25 | |
Nabin Hait | 1a60931 | 2017-07-13 12:16:04 +0530 | [diff] [blame] | 26 | def add_hsn_sac_codes(): |
| 27 | # HSN codes |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 28 | with open(os.path.join(os.path.dirname(__file__), 'hsn_code_data.json'), 'r') as f: |
| 29 | hsn_codes = json.loads(f.read()) |
| 30 | |
Nabin Hait | 1a60931 | 2017-07-13 12:16:04 +0530 | [diff] [blame] | 31 | create_hsn_codes(hsn_codes, code_field="hsn_code") |
Prateeksha Singh | 95d8fd3 | 2017-09-04 11:14:04 +0530 | [diff] [blame] | 32 | |
Nabin Hait | 1a60931 | 2017-07-13 12:16:04 +0530 | [diff] [blame] | 33 | # SAC Codes |
| 34 | with open(os.path.join(os.path.dirname(__file__), 'sac_code_data.json'), 'r') as f: |
| 35 | sac_codes = json.loads(f.read()) |
| 36 | create_hsn_codes(sac_codes, code_field="sac_code") |
Prateeksha Singh | 95d8fd3 | 2017-09-04 11:14:04 +0530 | [diff] [blame] | 37 | |
Nabin Hait | 1a60931 | 2017-07-13 12:16:04 +0530 | [diff] [blame] | 38 | def create_hsn_codes(data, code_field): |
| 39 | for d in data: |
Rushabh Mehta | f702d72 | 2017-09-27 15:31:30 +0530 | [diff] [blame] | 40 | hsn_code = frappe.new_doc('GST HSN Code') |
| 41 | hsn_code.description = d["description"] |
| 42 | hsn_code.hsn_code = d[code_field] |
| 43 | hsn_code.name = d[code_field] |
| 44 | try: |
Nabin Hait | 1a60931 | 2017-07-13 12:16:04 +0530 | [diff] [blame] | 45 | hsn_code.db_insert() |
Rushabh Mehta | f702d72 | 2017-09-27 15:31:30 +0530 | [diff] [blame] | 46 | except frappe.DuplicateEntryError: |
| 47 | pass |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 48 | |
Rushabh Mehta | 919a74a | 2017-06-22 16:37:04 +0530 | [diff] [blame] | 49 | def add_custom_roles_for_reports(): |
| 50 | for report_name in ('GST Sales Register', 'GST Purchase Register', |
rohitwaghchaure | 8cca61f | 2018-08-20 17:53:56 +0530 | [diff] [blame] | 51 | 'GST Itemised Sales Register', 'GST Itemised Purchase Register', 'Eway Bill'): |
Rushabh Mehta | 919a74a | 2017-06-22 16:37:04 +0530 | [diff] [blame] | 52 | |
Rushabh Mehta | 919a74a | 2017-06-22 16:37:04 +0530 | [diff] [blame] | 53 | if not frappe.db.get_value('Custom Role', dict(report=report_name)): |
| 54 | frappe.get_doc(dict( |
| 55 | doctype='Custom Role', |
| 56 | report=report_name, |
| 57 | roles= [ |
| 58 | dict(role='Accounts User'), |
| 59 | dict(role='Accounts Manager') |
| 60 | ] |
| 61 | )).insert() |
| 62 | |
Anurag Mishra | 289c822 | 2020-06-19 19:17:57 +0530 | [diff] [blame] | 63 | for report_name in ('Professional Tax Deductions', 'Provident Fund Deductions'): |
| 64 | |
| 65 | if not frappe.db.get_value('Custom Role', dict(report=report_name)): |
| 66 | frappe.get_doc(dict( |
| 67 | doctype='Custom Role', |
| 68 | report=report_name, |
| 69 | roles= [ |
| 70 | dict(role='HR User'), |
| 71 | dict(role='HR Manager'), |
| 72 | dict(role='Employee') |
| 73 | ] |
| 74 | )).insert() |
| 75 | |
Anurag Mishra | 54cd194 | 2020-09-03 13:51:26 +0530 | [diff] [blame] | 76 | for report_name in ('HSN-wise-summary of outward supplies', 'GSTR-1', 'GSTR-2'): |
| 77 | |
| 78 | if not frappe.db.get_value('Custom Role', dict(report=report_name)): |
| 79 | frappe.get_doc(dict( |
| 80 | doctype='Custom Role', |
| 81 | report=report_name, |
| 82 | roles= [ |
| 83 | dict(role='Accounts User'), |
| 84 | dict(role='Accounts Manager'), |
| 85 | dict(role='Auditor') |
| 86 | ] |
| 87 | )).insert() |
| 88 | |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 89 | def add_permissions(): |
Saqib | 6d74f5b | 2020-12-25 10:26:43 +0530 | [diff] [blame] | 90 | for doctype in ('GST HSN Code', 'GST Settings', 'GSTR 3B Report', 'Lower Deduction Certificate', 'E Invoice Settings'): |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 91 | add_permission(doctype, 'All', 0) |
Deepesh Garg | 6c8efde | 2020-04-04 20:05:17 +0530 | [diff] [blame] | 92 | for role in ('Accounts Manager', 'Accounts User', 'System Manager'): |
Saqib | 5e6ce88 | 2020-02-03 15:40:35 +0530 | [diff] [blame] | 93 | add_permission(doctype, role, 0) |
| 94 | update_permission_property(doctype, role, 0, 'write', 1) |
| 95 | update_permission_property(doctype, role, 0, 'create', 1) |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 96 | |
Deepesh Garg | 6c8efde | 2020-04-04 20:05:17 +0530 | [diff] [blame] | 97 | if doctype == 'GST HSN Code': |
| 98 | for role in ('Item Manager', 'Stock Manager'): |
| 99 | add_permission(doctype, role, 0) |
| 100 | update_permission_property(doctype, role, 0, 'write', 1) |
| 101 | update_permission_property(doctype, role, 0, 'create', 1) |
| 102 | |
Nabin Hait | 852cb64 | 2017-07-05 12:58:19 +0530 | [diff] [blame] | 103 | def add_print_formats(): |
| 104 | frappe.reload_doc("regional", "print_format", "gst_tax_invoice") |
rohitwaghchaure | e3b5c0f | 2017-12-16 10:53:53 +0530 | [diff] [blame] | 105 | frappe.reload_doc("accounts", "print_format", "gst_pos_invoice") |
Saqib | 6d74f5b | 2020-12-25 10:26:43 +0530 | [diff] [blame] | 106 | frappe.reload_doc("accounts", "print_format", "GST E-Invoice") |
rohitwaghchaure | e3b5c0f | 2017-12-16 10:53:53 +0530 | [diff] [blame] | 107 | |
| 108 | frappe.db.sql(""" update `tabPrint Format` set disabled = 0 where |
Saqib | 6d74f5b | 2020-12-25 10:26:43 +0530 | [diff] [blame] | 109 | name in('GST POS Invoice', 'GST Tax Invoice', 'GST E-Invoice') """) |
Nabin Hait | 852cb64 | 2017-07-05 12:58:19 +0530 | [diff] [blame] | 110 | |
Rushabh Mehta | 69fa808 | 2018-07-17 18:22:51 +0530 | [diff] [blame] | 111 | def make_custom_fields(update=True): |
Nabin Hait | f3f0dfe | 2017-07-06 14:49:34 +0530 | [diff] [blame] | 112 | hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC', |
Nabin Hait | d34bfa8 | 2018-11-13 18:19:58 +0530 | [diff] [blame] | 113 | fieldtype='Data', fetch_from='item_code.gst_hsn_code', insert_after='description', |
Nabin Hait | f4af608 | 2019-04-01 11:51:54 +0530 | [diff] [blame] | 114 | allow_on_submit=1, print_hide=1, fetch_if_empty=1) |
Marica | 9942acd | 2020-04-21 13:13:39 +0530 | [diff] [blame] | 115 | nil_rated_exempt = dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted', |
Deepesh Garg | 22b6160 | 2019-03-21 20:47:47 +0530 | [diff] [blame] | 116 | fieldtype='Check', fetch_from='item_code.is_nil_exempt', insert_after='gst_hsn_code', |
| 117 | print_hide=1) |
| 118 | is_non_gst = dict(fieldname='is_non_gst', label='Is Non GST', |
| 119 | fieldtype='Check', fetch_from='item_code.is_non_gst', insert_after='is_nil_exempt', |
| 120 | print_hide=1) |
| 121 | |
| 122 | purchase_invoice_gst_category = [ |
Nabin Hait | 879e162 | 2017-08-21 08:28:55 +0530 | [diff] [blame] | 123 | dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break', |
vishdha | 109b408 | 2018-01-30 12:11:13 +0530 | [diff] [blame] | 124 | insert_after='language', print_hide=1, collapsible=1), |
Deepesh Garg | 22b6160 | 2019-03-21 20:47:47 +0530 | [diff] [blame] | 125 | dict(fieldname='gst_category', label='GST Category', |
Nabin Hait | 10dae5d | 2019-04-01 20:56:51 +0530 | [diff] [blame] | 126 | fieldtype='Select', insert_after='gst_section', print_hide=1, |
Nabin Hait | 89b0613 | 2019-05-01 14:18:21 +0530 | [diff] [blame] | 127 | options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders', |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 128 | fetch_from='supplier.gst_category', fetch_if_empty=1), |
| 129 | dict(fieldname='export_type', label='Export Type', |
| 130 | fieldtype='Select', insert_after='gst_category', print_hide=1, |
| 131 | depends_on='eval:in_list(["SEZ", "Overseas"], doc.gst_category)', |
| 132 | options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='supplier.export_type', |
| 133 | fetch_if_empty=1), |
Deepesh Garg | 22b6160 | 2019-03-21 20:47:47 +0530 | [diff] [blame] | 134 | ] |
| 135 | |
| 136 | sales_invoice_gst_category = [ |
| 137 | dict(fieldname='gst_section', label='GST Details', fieldtype='Section Break', |
| 138 | insert_after='language', print_hide=1, collapsible=1), |
| 139 | dict(fieldname='gst_category', label='GST Category', |
Nabin Hait | 10dae5d | 2019-04-01 20:56:51 +0530 | [diff] [blame] | 140 | fieldtype='Select', insert_after='gst_section', print_hide=1, |
Nabin Hait | 89b0613 | 2019-05-01 14:18:21 +0530 | [diff] [blame] | 141 | options='\nRegistered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders', |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 142 | fetch_from='customer.gst_category', fetch_if_empty=1), |
| 143 | dict(fieldname='export_type', label='Export Type', |
| 144 | fieldtype='Select', insert_after='gst_category', print_hide=1, |
| 145 | depends_on='eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)', |
| 146 | options='\nWith Payment of Tax\nWithout Payment of Tax', fetch_from='customer.export_type', |
| 147 | fetch_if_empty=1), |
Deepesh Garg | 22b6160 | 2019-03-21 20:47:47 +0530 | [diff] [blame] | 148 | ] |
| 149 | |
| 150 | invoice_gst_fields = [ |
Nabin Hait | 879e162 | 2017-08-21 08:28:55 +0530 | [diff] [blame] | 151 | dict(fieldname='invoice_copy', label='Invoice Copy', |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 152 | fieldtype='Select', insert_after='export_type', print_hide=1, allow_on_submit=1, |
Nabin Hait | 879e162 | 2017-08-21 08:28:55 +0530 | [diff] [blame] | 153 | options='Original for Recipient\nDuplicate for Transporter\nDuplicate for Supplier\nTriplicate for Supplier'), |
| 154 | dict(fieldname='reverse_charge', label='Reverse Charge', |
| 155 | fieldtype='Select', insert_after='invoice_copy', print_hide=1, |
| 156 | options='Y\nN', default='N'), |
Nabin Hait | 879e162 | 2017-08-21 08:28:55 +0530 | [diff] [blame] | 157 | dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN', |
Vishal Dhayagude | c463c06 | 2018-01-26 11:27:22 +0530 | [diff] [blame] | 158 | fieldtype='Data', insert_after='export_type', print_hide=1), |
Nabin Hait | e6d65bc | 2018-02-14 17:44:06 +0530 | [diff] [blame] | 159 | dict(fieldname='gst_col_break', fieldtype='Column Break', insert_after='ecommerce_gstin'), |
Vishal Dhayagude | c463c06 | 2018-01-26 11:27:22 +0530 | [diff] [blame] | 160 | dict(fieldname='reason_for_issuing_document', label='Reason For Issuing document', |
Nabin Hait | b02c109 | 2018-02-05 16:09:51 +0530 | [diff] [blame] | 161 | fieldtype='Select', insert_after='gst_col_break', print_hide=1, |
Nabin Hait | e6d65bc | 2018-02-14 17:44:06 +0530 | [diff] [blame] | 162 | depends_on='eval:doc.is_return==1', |
Nabin Hait | a8d10b7 | 2018-02-12 16:54:13 +0530 | [diff] [blame] | 163 | options='\n01-Sales Return\n02-Post Sale Discount\n03-Deficiency in services\n04-Correction in Invoice\n05-Change in POS\n06-Finalization of Provisional assessment\n07-Others') |
Nabin Hait | 879e162 | 2017-08-21 08:28:55 +0530 | [diff] [blame] | 164 | ] |
Prateeksha Singh | 95d8fd3 | 2017-09-04 11:14:04 +0530 | [diff] [blame] | 165 | |
Nabin Hait | 879e162 | 2017-08-21 08:28:55 +0530 | [diff] [blame] | 166 | purchase_invoice_gst_fields = [ |
| 167 | dict(fieldname='supplier_gstin', label='Supplier GSTIN', |
| 168 | fieldtype='Data', insert_after='supplier_address', |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 169 | fetch_from='supplier_address.gstin', print_hide=1, read_only=1), |
Nabin Hait | 879e162 | 2017-08-21 08:28:55 +0530 | [diff] [blame] | 170 | dict(fieldname='company_gstin', label='Company GSTIN', |
Shreya Shah | 4fa600a | 2018-06-05 11:27:53 +0530 | [diff] [blame] | 171 | fieldtype='Data', insert_after='shipping_address_display', |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 172 | fetch_from='shipping_address.gstin', print_hide=1, read_only=1), |
Nabin Hait | b02c109 | 2018-02-05 16:09:51 +0530 | [diff] [blame] | 173 | dict(fieldname='place_of_supply', label='Place of Supply', |
| 174 | fieldtype='Data', insert_after='shipping_address', |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 175 | print_hide=1, read_only=1), |
deepeshgarg007 | d29ee97 | 2019-01-09 17:09:11 +0530 | [diff] [blame] | 176 | ] |
| 177 | |
| 178 | purchase_invoice_itc_fields = [ |
vishdha | 98e33c3 | 2018-01-29 13:57:34 +0530 | [diff] [blame] | 179 | dict(fieldname='eligibility_for_itc', label='Eligibility For ITC', |
| 180 | fieldtype='Select', insert_after='reason_for_issuing_document', print_hide=1, |
Deepesh Garg | 22b6160 | 2019-03-21 20:47:47 +0530 | [diff] [blame] | 181 | options='Input Service Distributor\nImport Of Service\nImport Of Capital Goods\nIneligible\nAll Other ITC', default="All Other ITC"), |
vishdha | 98e33c3 | 2018-01-29 13:57:34 +0530 | [diff] [blame] | 182 | dict(fieldname='itc_integrated_tax', label='Availed ITC Integrated Tax', |
| 183 | fieldtype='Data', insert_after='eligibility_for_itc', print_hide=1), |
| 184 | dict(fieldname='itc_central_tax', label='Availed ITC Central Tax', |
| 185 | fieldtype='Data', insert_after='itc_integrated_tax', print_hide=1), |
| 186 | dict(fieldname='itc_state_tax', label='Availed ITC State/UT Tax', |
| 187 | fieldtype='Data', insert_after='itc_central_tax', print_hide=1), |
| 188 | dict(fieldname='itc_cess_amount', label='Availed ITC Cess', |
| 189 | fieldtype='Data', insert_after='itc_state_tax', print_hide=1), |
Nabin Hait | 879e162 | 2017-08-21 08:28:55 +0530 | [diff] [blame] | 190 | ] |
Prateeksha Singh | 95d8fd3 | 2017-09-04 11:14:04 +0530 | [diff] [blame] | 191 | |
Nabin Hait | 879e162 | 2017-08-21 08:28:55 +0530 | [diff] [blame] | 192 | sales_invoice_gst_fields = [ |
rohitwaghchaure | 1664580 | 2017-09-28 11:05:03 +0530 | [diff] [blame] | 193 | dict(fieldname='billing_address_gstin', label='Billing Address GSTIN', |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 194 | fieldtype='Data', insert_after='customer_address', read_only=1, |
Shreya Shah | 4fa600a | 2018-06-05 11:27:53 +0530 | [diff] [blame] | 195 | fetch_from='customer_address.gstin', print_hide=1), |
Nabin Hait | 879e162 | 2017-08-21 08:28:55 +0530 | [diff] [blame] | 196 | dict(fieldname='customer_gstin', label='Customer GSTIN', |
Shreya Shah | 4fa600a | 2018-06-05 11:27:53 +0530 | [diff] [blame] | 197 | fieldtype='Data', insert_after='shipping_address_name', |
| 198 | fetch_from='shipping_address_name.gstin', print_hide=1), |
Nabin Hait | 879e162 | 2017-08-21 08:28:55 +0530 | [diff] [blame] | 199 | dict(fieldname='place_of_supply', label='Place of Supply', |
Nabin Hait | 619c42b | 2018-01-10 17:48:03 +0530 | [diff] [blame] | 200 | fieldtype='Data', insert_after='customer_gstin', |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 201 | print_hide=1, read_only=1), |
Nabin Hait | 879e162 | 2017-08-21 08:28:55 +0530 | [diff] [blame] | 202 | dict(fieldname='company_gstin', label='Company GSTIN', |
| 203 | fieldtype='Data', insert_after='company_address', |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 204 | fetch_from='company_address.gstin', print_hide=1, read_only=1), |
deepeshgarg007 | d29ee97 | 2019-01-09 17:09:11 +0530 | [diff] [blame] | 205 | ] |
| 206 | |
| 207 | sales_invoice_shipping_fields = [ |
vishdha | 98e33c3 | 2018-01-29 13:57:34 +0530 | [diff] [blame] | 208 | dict(fieldname='port_code', label='Port Code', |
| 209 | fieldtype='Data', insert_after='reason_for_issuing_document', print_hide=1, |
Deepesh Garg | 22b6160 | 2019-03-21 20:47:47 +0530 | [diff] [blame] | 210 | depends_on="eval:doc.gst_category=='Overseas' "), |
vishdha | 98e33c3 | 2018-01-29 13:57:34 +0530 | [diff] [blame] | 211 | dict(fieldname='shipping_bill_number', label=' Shipping Bill Number', |
| 212 | fieldtype='Data', insert_after='port_code', print_hide=1, |
Deepesh Garg | 22b6160 | 2019-03-21 20:47:47 +0530 | [diff] [blame] | 213 | depends_on="eval:doc.gst_category=='Overseas' "), |
vishdha | 98e33c3 | 2018-01-29 13:57:34 +0530 | [diff] [blame] | 214 | dict(fieldname='shipping_bill_date', label='Shipping Bill Date', |
| 215 | fieldtype='Date', insert_after='shipping_bill_number', print_hide=1, |
Deepesh Garg | 22b6160 | 2019-03-21 20:47:47 +0530 | [diff] [blame] | 216 | depends_on="eval:doc.gst_category=='Overseas' "), |
Nabin Hait | 879e162 | 2017-08-21 08:28:55 +0530 | [diff] [blame] | 217 | ] |
Prateeksha Singh | 95d8fd3 | 2017-09-04 11:14:04 +0530 | [diff] [blame] | 218 | |
Shreya Shah | 4fa600a | 2018-06-05 11:27:53 +0530 | [diff] [blame] | 219 | inter_state_gst_field = [ |
| 220 | dict(fieldname='is_inter_state', label='Is Inter State', |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 221 | fieldtype='Check', insert_after='disabled', print_hide=1), |
| 222 | dict(fieldname='tax_category_column_break', fieldtype='Column Break', |
| 223 | insert_after='is_inter_state'), |
| 224 | dict(fieldname='gst_state', label='Source State', fieldtype='Select', |
| 225 | options='\n'.join(states), insert_after='company') |
Shreya Shah | 4fa600a | 2018-06-05 11:27:53 +0530 | [diff] [blame] | 226 | ] |
| 227 | |
Sagar Vora | d92f3ac | 2018-10-10 14:51:26 +0530 | [diff] [blame] | 228 | ewaybill_fields = [ |
| 229 | { |
| 230 | 'fieldname': 'distance', |
| 231 | 'label': 'Distance (in km)', |
| 232 | 'fieldtype': 'Float', |
| 233 | 'insert_after': 'vehicle_no', |
| 234 | 'print_hide': 1 |
| 235 | }, |
| 236 | { |
| 237 | 'fieldname': 'gst_transporter_id', |
| 238 | 'label': 'GST Transporter ID', |
| 239 | 'fieldtype': 'Data', |
Nabin Hait | 34c551d | 2019-07-03 10:34:31 +0530 | [diff] [blame] | 240 | 'insert_after': 'transporter', |
Sagar Vora | d92f3ac | 2018-10-10 14:51:26 +0530 | [diff] [blame] | 241 | 'fetch_from': 'transporter.gst_transporter_id', |
Nabin Hait | 34c551d | 2019-07-03 10:34:31 +0530 | [diff] [blame] | 242 | 'print_hide': 1, |
| 243 | 'translatable': 0 |
Sagar Vora | d92f3ac | 2018-10-10 14:51:26 +0530 | [diff] [blame] | 244 | }, |
| 245 | { |
| 246 | 'fieldname': 'mode_of_transport', |
| 247 | 'label': 'Mode of Transport', |
| 248 | 'fieldtype': 'Select', |
| 249 | 'options': '\nRoad\nAir\nRail\nShip', |
| 250 | 'default': 'Road', |
Nabin Hait | 34c551d | 2019-07-03 10:34:31 +0530 | [diff] [blame] | 251 | 'insert_after': 'transporter_name', |
| 252 | 'print_hide': 1, |
| 253 | 'translatable': 0 |
| 254 | }, |
| 255 | { |
| 256 | 'fieldname': 'gst_vehicle_type', |
| 257 | 'label': 'GST Vehicle Type', |
| 258 | 'fieldtype': 'Select', |
| 259 | 'options': 'Regular\nOver Dimensional Cargo (ODC)', |
| 260 | 'depends_on': 'eval:(doc.mode_of_transport === "Road")', |
| 261 | 'default': 'Regular', |
Sagar Vora | d92f3ac | 2018-10-10 14:51:26 +0530 | [diff] [blame] | 262 | 'insert_after': 'lr_date', |
Nabin Hait | 34c551d | 2019-07-03 10:34:31 +0530 | [diff] [blame] | 263 | 'print_hide': 1, |
| 264 | 'translatable': 0 |
Deepesh Garg | 15ff6a5 | 2020-02-18 12:28:41 +0530 | [diff] [blame] | 265 | }, |
| 266 | { |
| 267 | 'fieldname': 'ewaybill', |
| 268 | 'label': 'E-Way Bill No.', |
| 269 | 'fieldtype': 'Data', |
| 270 | 'depends_on': 'eval:(doc.docstatus === 1)', |
| 271 | 'allow_on_submit': 1, |
| 272 | 'insert_after': 'customer_name_in_arabic', |
| 273 | 'translatable': 0, |
| 274 | } |
Nabin Hait | 34c551d | 2019-07-03 10:34:31 +0530 | [diff] [blame] | 275 | ] |
| 276 | |
| 277 | si_ewaybill_fields = [ |
| 278 | { |
| 279 | 'fieldname': 'transporter_info', |
| 280 | 'label': 'Transporter Info', |
| 281 | 'fieldtype': 'Section Break', |
| 282 | 'insert_after': 'terms', |
| 283 | 'collapsible': 1, |
| 284 | 'collapsible_depends_on': 'transporter', |
| 285 | 'print_hide': 1 |
| 286 | }, |
| 287 | { |
| 288 | 'fieldname': 'transporter', |
| 289 | 'label': 'Transporter', |
| 290 | 'fieldtype': 'Link', |
| 291 | 'insert_after': 'transporter_info', |
| 292 | 'options': 'Supplier', |
| 293 | 'print_hide': 1 |
| 294 | }, |
| 295 | { |
| 296 | 'fieldname': 'gst_transporter_id', |
| 297 | 'label': 'GST Transporter ID', |
| 298 | 'fieldtype': 'Data', |
| 299 | 'insert_after': 'transporter', |
| 300 | 'fetch_from': 'transporter.gst_transporter_id', |
| 301 | 'print_hide': 1, |
| 302 | 'translatable': 0 |
| 303 | }, |
| 304 | { |
| 305 | 'fieldname': 'driver', |
| 306 | 'label': 'Driver', |
| 307 | 'fieldtype': 'Link', |
| 308 | 'insert_after': 'gst_transporter_id', |
| 309 | 'options': 'Driver', |
| 310 | 'print_hide': 1 |
| 311 | }, |
| 312 | { |
| 313 | 'fieldname': 'lr_no', |
| 314 | 'label': 'Transport Receipt No', |
| 315 | 'fieldtype': 'Data', |
| 316 | 'insert_after': 'driver', |
| 317 | 'print_hide': 1, |
| 318 | 'translatable': 0 |
| 319 | }, |
| 320 | { |
| 321 | 'fieldname': 'vehicle_no', |
| 322 | 'label': 'Vehicle No', |
| 323 | 'fieldtype': 'Data', |
| 324 | 'insert_after': 'lr_no', |
| 325 | 'print_hide': 1, |
| 326 | 'translatable': 0 |
| 327 | }, |
| 328 | { |
| 329 | 'fieldname': 'distance', |
| 330 | 'label': 'Distance (in km)', |
| 331 | 'fieldtype': 'Float', |
| 332 | 'insert_after': 'vehicle_no', |
| 333 | 'print_hide': 1 |
| 334 | }, |
| 335 | { |
| 336 | 'fieldname': 'transporter_col_break', |
| 337 | 'fieldtype': 'Column Break', |
| 338 | 'insert_after': 'distance' |
| 339 | }, |
| 340 | { |
| 341 | 'fieldname': 'transporter_name', |
| 342 | 'label': 'Transporter Name', |
| 343 | 'fieldtype': 'Data', |
| 344 | 'insert_after': 'transporter_col_break', |
| 345 | 'fetch_from': 'transporter.name', |
| 346 | 'read_only': 1, |
| 347 | 'print_hide': 1, |
| 348 | 'translatable': 0 |
| 349 | }, |
| 350 | { |
| 351 | 'fieldname': 'mode_of_transport', |
| 352 | 'label': 'Mode of Transport', |
| 353 | 'fieldtype': 'Select', |
| 354 | 'options': '\nRoad\nAir\nRail\nShip', |
Nabin Hait | 34c551d | 2019-07-03 10:34:31 +0530 | [diff] [blame] | 355 | 'insert_after': 'transporter_name', |
| 356 | 'print_hide': 1, |
| 357 | 'translatable': 0 |
| 358 | }, |
| 359 | { |
| 360 | 'fieldname': 'driver_name', |
| 361 | 'label': 'Driver Name', |
| 362 | 'fieldtype': 'Data', |
| 363 | 'insert_after': 'mode_of_transport', |
| 364 | 'fetch_from': 'driver.full_name', |
| 365 | 'print_hide': 1, |
| 366 | 'translatable': 0 |
| 367 | }, |
| 368 | { |
| 369 | 'fieldname': 'lr_date', |
| 370 | 'label': 'Transport Receipt Date', |
| 371 | 'fieldtype': 'Date', |
| 372 | 'insert_after': 'driver_name', |
| 373 | 'default': 'Today', |
Sagar Vora | d92f3ac | 2018-10-10 14:51:26 +0530 | [diff] [blame] | 374 | 'print_hide': 1 |
| 375 | }, |
| 376 | { |
| 377 | 'fieldname': 'gst_vehicle_type', |
| 378 | 'label': 'GST Vehicle Type', |
| 379 | 'fieldtype': 'Select', |
Nabin Hait | 34c551d | 2019-07-03 10:34:31 +0530 | [diff] [blame] | 380 | 'options': 'Regular\nOver Dimensional Cargo (ODC)', |
Sagar Vora | d92f3ac | 2018-10-10 14:51:26 +0530 | [diff] [blame] | 381 | 'depends_on': 'eval:(doc.mode_of_transport === "Road")', |
Nabin Hait | 34c551d | 2019-07-03 10:34:31 +0530 | [diff] [blame] | 382 | 'default': 'Regular', |
| 383 | 'insert_after': 'lr_date', |
| 384 | 'print_hide': 1, |
| 385 | 'translatable': 0 |
| 386 | }, |
| 387 | { |
| 388 | 'fieldname': 'ewaybill', |
Deepesh Garg | 15ff6a5 | 2020-02-18 12:28:41 +0530 | [diff] [blame] | 389 | 'label': 'E-Way Bill No.', |
Nabin Hait | 34c551d | 2019-07-03 10:34:31 +0530 | [diff] [blame] | 390 | 'fieldtype': 'Data', |
Saqib | 6d74f5b | 2020-12-25 10:26:43 +0530 | [diff] [blame] | 391 | 'depends_on': 'eval:((doc.docstatus === 1 || doc.ewaybill) && doc.eway_bill_cancelled === 0)', |
Nabin Hait | 34c551d | 2019-07-03 10:34:31 +0530 | [diff] [blame] | 392 | 'allow_on_submit': 1, |
deepeshgarg007 | a85db66 | 2019-07-14 18:15:19 +0530 | [diff] [blame] | 393 | 'insert_after': 'tax_id', |
Nabin Hait | 34c551d | 2019-07-03 10:34:31 +0530 | [diff] [blame] | 394 | 'translatable': 0 |
Sagar Vora | d92f3ac | 2018-10-10 14:51:26 +0530 | [diff] [blame] | 395 | } |
| 396 | ] |
| 397 | |
Saqib | 6d74f5b | 2020-12-25 10:26:43 +0530 | [diff] [blame] | 398 | si_einvoice_fields = [ |
| 399 | dict(fieldname='irn', label='IRN', fieldtype='Data', read_only=1, insert_after='customer', no_copy=1, print_hide=1, |
| 400 | depends_on='eval:in_list(["Registered Regular", "SEZ", "Overseas", "Deemed Export"], doc.gst_category) && doc.irn_cancelled === 0'), |
| 401 | |
| 402 | dict(fieldname='ack_no', label='Ack. No.', fieldtype='Data', read_only=1, hidden=1, insert_after='irn', no_copy=1, print_hide=1), |
| 403 | |
| 404 | dict(fieldname='ack_date', label='Ack. Date', fieldtype='Data', read_only=1, hidden=1, insert_after='ack_no', no_copy=1, print_hide=1), |
| 405 | |
| 406 | dict(fieldname='irn_cancelled', label='IRN Cancelled', fieldtype='Check', no_copy=1, print_hide=1, |
| 407 | depends_on='eval:(doc.irn_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'), |
| 408 | |
| 409 | dict(fieldname='eway_bill_cancelled', label='E-Way Bill Cancelled', fieldtype='Check', no_copy=1, print_hide=1, |
| 410 | depends_on='eval:(doc.eway_bill_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'), |
| 411 | |
| 412 | dict(fieldname='signed_einvoice', fieldtype='Code', options='JSON', hidden=1, no_copy=1, print_hide=1, read_only=1), |
| 413 | |
| 414 | dict(fieldname='signed_qr_code', fieldtype='Code', options='JSON', hidden=1, no_copy=1, print_hide=1, read_only=1), |
| 415 | |
| 416 | dict(fieldname='qrcode_image', label='QRCode', fieldtype='Attach Image', hidden=1, no_copy=1, print_hide=1, read_only=1) |
| 417 | ] |
| 418 | |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 419 | custom_fields = { |
| 420 | 'Address': [ |
Rushabh Mehta | 919a74a | 2017-06-22 16:37:04 +0530 | [diff] [blame] | 421 | dict(fieldname='gstin', label='Party GSTIN', fieldtype='Data', |
| 422 | insert_after='fax'), |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 423 | dict(fieldname='gst_state', label='GST State', fieldtype='Select', |
Nabin Hait | f3f0dfe | 2017-07-06 14:49:34 +0530 | [diff] [blame] | 424 | options='\n'.join(states), insert_after='gstin'), |
| 425 | dict(fieldname='gst_state_number', label='GST State Number', |
Nabin Hait | 562d942 | 2018-09-07 16:14:44 +0530 | [diff] [blame] | 426 | fieldtype='Data', insert_after='gst_state', read_only=1), |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 427 | ], |
Deepesh Garg | 22b6160 | 2019-03-21 20:47:47 +0530 | [diff] [blame] | 428 | 'Purchase Invoice': purchase_invoice_gst_category + invoice_gst_fields + purchase_invoice_itc_fields + purchase_invoice_gst_fields, |
deepeshgarg007 | d29ee97 | 2019-01-09 17:09:11 +0530 | [diff] [blame] | 429 | 'Purchase Order': purchase_invoice_gst_fields, |
| 430 | 'Purchase Receipt': purchase_invoice_gst_fields, |
Saqib | 6d74f5b | 2020-12-25 10:26:43 +0530 | [diff] [blame] | 431 | 'Sales Invoice': sales_invoice_gst_category + invoice_gst_fields + sales_invoice_shipping_fields + sales_invoice_gst_fields + si_ewaybill_fields + si_einvoice_fields, |
Nabin Hait | 34c551d | 2019-07-03 10:34:31 +0530 | [diff] [blame] | 432 | 'Delivery Note': sales_invoice_gst_fields + ewaybill_fields + sales_invoice_shipping_fields, |
deepeshgarg007 | d29ee97 | 2019-01-09 17:09:11 +0530 | [diff] [blame] | 433 | 'Sales Order': sales_invoice_gst_fields, |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 434 | 'Tax Category': inter_state_gst_field, |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 435 | 'Item': [ |
Nabin Hait | f3f0dfe | 2017-07-06 14:49:34 +0530 | [diff] [blame] | 436 | dict(fieldname='gst_hsn_code', label='HSN/SAC', |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 437 | fieldtype='Link', options='GST HSN Code', insert_after='item_group'), |
Marica | 9942acd | 2020-04-21 13:13:39 +0530 | [diff] [blame] | 438 | dict(fieldname='is_nil_exempt', label='Is Nil Rated or Exempted', |
Deepesh Garg | 22b6160 | 2019-03-21 20:47:47 +0530 | [diff] [blame] | 439 | fieldtype='Check', insert_after='gst_hsn_code'), |
| 440 | dict(fieldname='is_non_gst', label='Is Non GST ', |
| 441 | fieldtype='Check', insert_after='is_nil_exempt') |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 442 | ], |
Deepesh Garg | 22b6160 | 2019-03-21 20:47:47 +0530 | [diff] [blame] | 443 | 'Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst], |
| 444 | 'Supplier Quotation Item': [hsn_sac_field, nil_rated_exempt, is_non_gst], |
| 445 | 'Sales Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst], |
| 446 | 'Delivery Note Item': [hsn_sac_field, nil_rated_exempt, is_non_gst], |
| 447 | 'Sales Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst], |
| 448 | 'Purchase Order Item': [hsn_sac_field, nil_rated_exempt, is_non_gst], |
| 449 | 'Purchase Receipt Item': [hsn_sac_field, nil_rated_exempt, is_non_gst], |
| 450 | 'Purchase Invoice Item': [hsn_sac_field, nil_rated_exempt, is_non_gst], |
Himanshu Warekar | 656d8e4 | 2019-04-01 19:38:43 +0530 | [diff] [blame] | 451 | 'Material Request Item': [hsn_sac_field, nil_rated_exempt, is_non_gst], |
Anurag Mishra | 289c822 | 2020-06-19 19:17:57 +0530 | [diff] [blame] | 452 | 'Salary Component': [ |
| 453 | dict(fieldname= 'component_type', |
| 454 | label= 'Component Type', |
| 455 | fieldtype= 'Select', |
| 456 | insert_after= 'description', |
| 457 | options= "\nProvident Fund\nAdditional Provident Fund\nProvident Fund Loan\nProfessional Tax", |
| 458 | depends_on = 'eval:doc.type == "Deduction"' |
| 459 | ) |
| 460 | ], |
Pawan Mehta | f419635 | 2018-04-05 14:54:51 +0530 | [diff] [blame] | 461 | 'Employee': [ |
Anurag Mishra | 289c822 | 2020-06-19 19:17:57 +0530 | [diff] [blame] | 462 | dict(fieldname='ifsc_code', |
| 463 | label='IFSC Code', |
| 464 | fieldtype='Data', |
| 465 | insert_after='bank_ac_no', |
| 466 | print_hide=1, |
| 467 | depends_on='eval:doc.salary_mode == "Bank"' |
| 468 | ), |
| 469 | dict( |
| 470 | fieldname = 'pan_number', |
| 471 | label = 'PAN Number', |
| 472 | fieldtype = 'Data', |
| 473 | insert_after = 'payroll_cost_center', |
| 474 | print_hide = 1 |
| 475 | ), |
| 476 | dict( |
| 477 | fieldname = 'micr_code', |
| 478 | label = 'MICR Code', |
| 479 | fieldtype = 'Data', |
| 480 | insert_after = 'ifsc_code', |
| 481 | print_hide = 1, |
| 482 | depends_on='eval:doc.salary_mode == "Bank"' |
| 483 | ), |
| 484 | dict( |
| 485 | fieldname = 'provident_fund_account', |
| 486 | label = 'Provident Fund Account', |
| 487 | fieldtype = 'Data', |
| 488 | insert_after = 'pan_number' |
| 489 | ) |
| 490 | |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 491 | ], |
| 492 | 'Company': [ |
| 493 | dict(fieldname='hra_section', label='HRA Settings', |
Anurag Mishra | a552722 | 2019-06-14 15:25:57 +0530 | [diff] [blame] | 494 | fieldtype='Section Break', insert_after='asset_received_but_not_billed', collapsible=1), |
Ranjith Kurungadam | b1a756c | 2018-07-01 16:42:38 +0530 | [diff] [blame] | 495 | dict(fieldname='basic_component', label='Basic Component', |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 496 | fieldtype='Link', options='Salary Component', insert_after='hra_section'), |
Ranjith Kurungadam | b1a756c | 2018-07-01 16:42:38 +0530 | [diff] [blame] | 497 | dict(fieldname='hra_component', label='HRA Component', |
| 498 | fieldtype='Link', options='Salary Component', insert_after='basic_component'), |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 499 | dict(fieldname='arrear_component', label='Arrear Component', |
Mangesh-Khairnar | 9215de0 | 2019-05-06 16:24:10 +0530 | [diff] [blame] | 500 | fieldtype='Link', options='Salary Component', insert_after='hra_component'), |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 501 | ], |
| 502 | 'Employee Tax Exemption Declaration':[ |
| 503 | dict(fieldname='hra_section', label='HRA Exemption', |
| 504 | fieldtype='Section Break', insert_after='declarations'), |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 505 | dict(fieldname='monthly_house_rent', label='Monthly House Rent', |
Nabin Hait | 04e7bf4 | 2019-04-25 18:44:10 +0530 | [diff] [blame] | 506 | fieldtype='Currency', insert_after='hra_section'), |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 507 | dict(fieldname='rented_in_metro_city', label='Rented in Metro City', |
Nabin Hait | 04e7bf4 | 2019-04-25 18:44:10 +0530 | [diff] [blame] | 508 | fieldtype='Check', insert_after='monthly_house_rent', depends_on='monthly_house_rent'), |
| 509 | dict(fieldname='salary_structure_hra', label='HRA as per Salary Structure', |
| 510 | fieldtype='Currency', insert_after='rented_in_metro_city', read_only=1, depends_on='monthly_house_rent'), |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 511 | dict(fieldname='hra_column_break', fieldtype='Column Break', |
Nabin Hait | 04e7bf4 | 2019-04-25 18:44:10 +0530 | [diff] [blame] | 512 | insert_after='salary_structure_hra', depends_on='monthly_house_rent'), |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 513 | dict(fieldname='annual_hra_exemption', label='Annual HRA Exemption', |
Nabin Hait | 04e7bf4 | 2019-04-25 18:44:10 +0530 | [diff] [blame] | 514 | fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='monthly_house_rent'), |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 515 | dict(fieldname='monthly_hra_exemption', label='Monthly HRA Exemption', |
Nabin Hait | 04e7bf4 | 2019-04-25 18:44:10 +0530 | [diff] [blame] | 516 | fieldtype='Currency', insert_after='annual_hra_exemption', read_only=1, depends_on='monthly_house_rent') |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 517 | ], |
| 518 | 'Employee Tax Exemption Proof Submission': [ |
| 519 | dict(fieldname='hra_section', label='HRA Exemption', |
| 520 | fieldtype='Section Break', insert_after='tax_exemption_proofs'), |
| 521 | dict(fieldname='house_rent_payment_amount', label='House Rent Payment Amount', |
| 522 | fieldtype='Currency', insert_after='hra_section'), |
| 523 | dict(fieldname='rented_in_metro_city', label='Rented in Metro City', |
Nabin Hait | 04e7bf4 | 2019-04-25 18:44:10 +0530 | [diff] [blame] | 524 | fieldtype='Check', insert_after='house_rent_payment_amount', depends_on='house_rent_payment_amount'), |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 525 | dict(fieldname='rented_from_date', label='Rented From Date', |
Nabin Hait | 04e7bf4 | 2019-04-25 18:44:10 +0530 | [diff] [blame] | 526 | fieldtype='Date', insert_after='rented_in_metro_city', depends_on='house_rent_payment_amount'), |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 527 | dict(fieldname='rented_to_date', label='Rented To Date', |
Nabin Hait | 04e7bf4 | 2019-04-25 18:44:10 +0530 | [diff] [blame] | 528 | fieldtype='Date', insert_after='rented_from_date', depends_on='house_rent_payment_amount'), |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 529 | dict(fieldname='hra_column_break', fieldtype='Column Break', |
Nabin Hait | 04e7bf4 | 2019-04-25 18:44:10 +0530 | [diff] [blame] | 530 | insert_after='rented_to_date', depends_on='house_rent_payment_amount'), |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 531 | dict(fieldname='monthly_house_rent', label='Monthly House Rent', |
Nabin Hait | 04e7bf4 | 2019-04-25 18:44:10 +0530 | [diff] [blame] | 532 | fieldtype='Currency', insert_after='hra_column_break', read_only=1, depends_on='house_rent_payment_amount'), |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 533 | dict(fieldname='monthly_hra_exemption', label='Monthly Eligible Amount', |
Nabin Hait | 04e7bf4 | 2019-04-25 18:44:10 +0530 | [diff] [blame] | 534 | fieldtype='Currency', insert_after='monthly_house_rent', read_only=1, depends_on='house_rent_payment_amount'), |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 535 | dict(fieldname='total_eligible_hra_exemption', label='Total Eligible HRA Exemption', |
Nabin Hait | 04e7bf4 | 2019-04-25 18:44:10 +0530 | [diff] [blame] | 536 | fieldtype='Currency', insert_after='monthly_hra_exemption', read_only=1, depends_on='house_rent_payment_amount') |
Sagar Vora | d92f3ac | 2018-10-10 14:51:26 +0530 | [diff] [blame] | 537 | ], |
| 538 | 'Supplier': [ |
| 539 | { |
| 540 | 'fieldname': 'gst_transporter_id', |
| 541 | 'label': 'GST Transporter ID', |
| 542 | 'fieldtype': 'Data', |
| 543 | 'insert_after': 'supplier_type', |
| 544 | 'depends_on': 'eval:doc.is_transporter' |
Deepesh Garg | 22b6160 | 2019-03-21 20:47:47 +0530 | [diff] [blame] | 545 | }, |
| 546 | { |
| 547 | 'fieldname': 'gst_category', |
| 548 | 'label': 'GST Category', |
| 549 | 'fieldtype': 'Select', |
| 550 | 'insert_after': 'gst_transporter_id', |
| 551 | 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nUIN Holders', |
| 552 | 'default': 'Unregistered' |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 553 | }, |
| 554 | { |
| 555 | 'fieldname': 'export_type', |
| 556 | 'label': 'Export Type', |
| 557 | 'fieldtype': 'Select', |
| 558 | 'insert_after': 'gst_category', |
| 559 | 'default': 'Without Payment of Tax', |
| 560 | 'depends_on':'eval:in_list(["SEZ", "Overseas"], doc.gst_category)', |
| 561 | 'options': '\nWith Payment of Tax\nWithout Payment of Tax' |
Deepesh Garg | 22b6160 | 2019-03-21 20:47:47 +0530 | [diff] [blame] | 562 | } |
| 563 | ], |
| 564 | 'Customer': [ |
| 565 | { |
| 566 | 'fieldname': 'gst_category', |
| 567 | 'label': 'GST Category', |
| 568 | 'fieldtype': 'Select', |
| 569 | 'insert_after': 'customer_type', |
| 570 | 'options': 'Registered Regular\nRegistered Composition\nUnregistered\nSEZ\nOverseas\nConsumer\nDeemed Export\nUIN Holders', |
| 571 | 'default': 'Unregistered' |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 572 | }, |
| 573 | { |
| 574 | 'fieldname': 'export_type', |
| 575 | 'label': 'Export Type', |
| 576 | 'fieldtype': 'Select', |
| 577 | 'insert_after': 'gst_category', |
| 578 | 'default': 'Without Payment of Tax', |
| 579 | 'depends_on':'eval:in_list(["SEZ", "Overseas", "Deemed Export"], doc.gst_category)', |
| 580 | 'options': '\nWith Payment of Tax\nWithout Payment of Tax' |
Sagar Vora | d92f3ac | 2018-10-10 14:51:26 +0530 | [diff] [blame] | 581 | } |
Shivam Mishra | 1d6395c | 2020-03-30 18:14:44 +0530 | [diff] [blame] | 582 | ], |
| 583 | "Member": [ |
| 584 | { |
| 585 | 'fieldname': 'pan_number', |
| 586 | 'label': 'PAN Details', |
| 587 | 'fieldtype': 'Data', |
| 588 | 'insert_after': 'email' |
| 589 | } |
Ranjith Kurungadam | a8e047a | 2018-06-14 17:56:16 +0530 | [diff] [blame] | 590 | ] |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 591 | } |
Deepesh Garg | 22b6160 | 2019-03-21 20:47:47 +0530 | [diff] [blame] | 592 | create_custom_fields(custom_fields, update=update) |
Nabin Hait | 9c42161 | 2017-07-20 13:32:01 +0530 | [diff] [blame] | 593 | |
Saurabh | 2d8a7ee | 2018-05-11 13:16:16 +0530 | [diff] [blame] | 594 | def make_fixtures(company=None): |
| 595 | docs = [] |
| 596 | company = company.name if company else frappe.db.get_value("Global Defaults", None, "default_company") |
| 597 | |
| 598 | set_salary_components(docs) |
Ranjith Kurungadam | e51c175 | 2018-07-24 11:07:28 +0530 | [diff] [blame] | 599 | set_tds_account(docs, company) |
Rushabh Mehta | b3c8f44 | 2017-06-21 17:22:38 +0530 | [diff] [blame] | 600 | |
| 601 | for d in docs: |
| 602 | try: |
| 603 | doc = frappe.get_doc(d) |
| 604 | doc.flags.ignore_permissions = True |
| 605 | doc.insert() |
| 606 | except frappe.NameError: |
Faris Ansari | ec7b064 | 2019-05-14 16:21:09 +0530 | [diff] [blame] | 607 | frappe.clear_messages() |
Zarrar | 7f8024c | 2018-08-01 17:45:05 +0530 | [diff] [blame] | 608 | except frappe.DuplicateEntryError: |
Faris Ansari | ec7b064 | 2019-05-14 16:21:09 +0530 | [diff] [blame] | 609 | frappe.clear_messages() |
Saurabh | 2d8a7ee | 2018-05-11 13:16:16 +0530 | [diff] [blame] | 610 | |
Zarrar | 7f8024c | 2018-08-01 17:45:05 +0530 | [diff] [blame] | 611 | # create records for Tax Withholding Category |
Ranjith Kurungadam | e51c175 | 2018-07-24 11:07:28 +0530 | [diff] [blame] | 612 | set_tax_withholding_category(company) |
| 613 | |
Saurabh | 2d8a7ee | 2018-05-11 13:16:16 +0530 | [diff] [blame] | 614 | def set_salary_components(docs): |
| 615 | docs.extend([ |
Nabin Hait | 58ee6c1 | 2020-04-26 17:45:57 +0530 | [diff] [blame] | 616 | {'doctype': 'Salary Component', 'salary_component': 'Professional Tax', |
| 617 | 'description': 'Professional Tax', 'type': 'Deduction', 'exempted_from_income_tax': 1}, |
| 618 | {'doctype': 'Salary Component', 'salary_component': 'Provident Fund', |
| 619 | 'description': 'Provident fund', 'type': 'Deduction', 'is_tax_applicable': 1}, |
| 620 | {'doctype': 'Salary Component', 'salary_component': 'House Rent Allowance', |
| 621 | 'description': 'House Rent Allowance', 'type': 'Earning', 'is_tax_applicable': 1}, |
| 622 | {'doctype': 'Salary Component', 'salary_component': 'Basic', |
| 623 | 'description': 'Basic', 'type': 'Earning', 'is_tax_applicable': 1}, |
| 624 | {'doctype': 'Salary Component', 'salary_component': 'Arrear', |
| 625 | 'description': 'Arrear', 'type': 'Earning', 'is_tax_applicable': 1}, |
| 626 | {'doctype': 'Salary Component', 'salary_component': 'Leave Encashment', |
| 627 | 'description': 'Leave Encashment', 'type': 'Earning', 'is_tax_applicable': 1} |
Saurabh | 2d8a7ee | 2018-05-11 13:16:16 +0530 | [diff] [blame] | 628 | ]) |
| 629 | |
Ranjith Kurungadam | e51c175 | 2018-07-24 11:07:28 +0530 | [diff] [blame] | 630 | def set_tax_withholding_category(company): |
Saurabh | 2d8a7ee | 2018-05-11 13:16:16 +0530 | [diff] [blame] | 631 | accounts = [] |
Anuja Pawar | 4569e52 | 2021-01-14 19:24:30 +0530 | [diff] [blame] | 632 | fiscal_year = None |
Ranjith Kurungadam | e51c175 | 2018-07-24 11:07:28 +0530 | [diff] [blame] | 633 | abbr = frappe.get_value("Company", company, "abbr") |
| 634 | tds_account = frappe.get_value("Account", 'TDS Payable - {0}'.format(abbr), 'name') |
Saurabh | 2d8a7ee | 2018-05-11 13:16:16 +0530 | [diff] [blame] | 635 | |
| 636 | if company and tds_account: |
Ranjith Kurungadam | e51c175 | 2018-07-24 11:07:28 +0530 | [diff] [blame] | 637 | accounts = [dict(company=company, account=tds_account)] |
Saurabh | 2d8a7ee | 2018-05-11 13:16:16 +0530 | [diff] [blame] | 638 | |
Anuja Pawar | 4569e52 | 2021-01-14 19:24:30 +0530 | [diff] [blame] | 639 | try: |
| 640 | fiscal_year = get_fiscal_year(today(), verbose=0, company=company)[0] |
| 641 | except FiscalYearError: |
| 642 | pass |
Ranjith Kurungadam | e51c175 | 2018-07-24 11:07:28 +0530 | [diff] [blame] | 643 | |
Anuja Pawar | 4569e52 | 2021-01-14 19:24:30 +0530 | [diff] [blame] | 644 | docs = get_tds_details(accounts, fiscal_year) |
| 645 | |
Zarrar | 7f8024c | 2018-08-01 17:45:05 +0530 | [diff] [blame] | 646 | for d in docs: |
| 647 | try: |
| 648 | doc = frappe.get_doc(d) |
| 649 | doc.flags.ignore_permissions = True |
Nabin Hait | afef9c1 | 2019-02-12 11:28:20 +0530 | [diff] [blame] | 650 | doc.flags.ignore_mandatory = True |
Zarrar | 7f8024c | 2018-08-01 17:45:05 +0530 | [diff] [blame] | 651 | doc.insert() |
| 652 | except frappe.DuplicateEntryError: |
| 653 | doc = frappe.get_doc("Tax Withholding Category", d.get("name")) |
Zarrar | 963d62b | 2019-03-23 10:30:12 +0530 | [diff] [blame] | 654 | |
| 655 | if accounts: |
| 656 | doc.append("accounts", accounts[0]) |
Zarrar | 7f8024c | 2018-08-01 17:45:05 +0530 | [diff] [blame] | 657 | |
Anuja Pawar | 4569e52 | 2021-01-14 19:24:30 +0530 | [diff] [blame] | 658 | if fiscal_year: |
| 659 | # if fiscal year don't match with any of the already entered data, append rate row |
| 660 | fy_exist = [k for k in doc.get('rates') if k.get('fiscal_year')==fiscal_year] |
| 661 | if not fy_exist: |
| 662 | doc.append("rates", d.get('rates')[0]) |
| 663 | |
| 664 | doc.flags.ignore_permissions = True |
| 665 | doc.flags.ignore_mandatory = True |
Zarrar | 7f8024c | 2018-08-01 17:45:05 +0530 | [diff] [blame] | 666 | doc.save() |
Saurabh | 2d8a7ee | 2018-05-11 13:16:16 +0530 | [diff] [blame] | 667 | |
| 668 | def set_tds_account(docs, company): |
Ranjith Kurungadam | e51c175 | 2018-07-24 11:07:28 +0530 | [diff] [blame] | 669 | abbr = frappe.get_value("Company", company, "abbr") |
Nabin Hait | f77cd54 | 2018-11-20 16:46:25 +0530 | [diff] [blame] | 670 | parent_account = frappe.db.get_value("Account", filters = {"account_name": "Duties and Taxes", "company": company}) |
| 671 | if parent_account: |
| 672 | docs.extend([ |
| 673 | { |
| 674 | "doctype": "Account", |
| 675 | "account_name": "TDS Payable", |
| 676 | "account_type": "Tax", |
| 677 | "parent_account": parent_account, |
| 678 | "company": company |
| 679 | } |
| 680 | ]) |
Zarrar | 7f8024c | 2018-08-01 17:45:05 +0530 | [diff] [blame] | 681 | |
| 682 | def get_tds_details(accounts, fiscal_year): |
| 683 | # bootstrap default tax withholding sections |
| 684 | return [ |
| 685 | dict(name="TDS - 194C - Company", |
| 686 | category_name="Payment to Contractors (Single / Aggregate)", |
| 687 | doctype="Tax Withholding Category", accounts=accounts, |
| 688 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2, |
| 689 | "single_threshold": 30000, "cumulative_threshold": 100000}]), |
| 690 | dict(name="TDS - 194C - Individual", |
| 691 | category_name="Payment to Contractors (Single / Aggregate)", |
| 692 | doctype="Tax Withholding Category", accounts=accounts, |
| 693 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1, |
| 694 | "single_threshold": 30000, "cumulative_threshold": 100000}]), |
| 695 | dict(name="TDS - 194C - No PAN / Invalid PAN", |
| 696 | category_name="Payment to Contractors (Single / Aggregate)", |
| 697 | doctype="Tax Withholding Category", accounts=accounts, |
| 698 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20, |
| 699 | "single_threshold": 30000, "cumulative_threshold": 100000}]), |
| 700 | dict(name="TDS - 194D - Company", |
| 701 | category_name="Insurance Commission", |
| 702 | doctype="Tax Withholding Category", accounts=accounts, |
| 703 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5, |
| 704 | "single_threshold": 15000, "cumulative_threshold": 0}]), |
| 705 | dict(name="TDS - 194D - Company Assessee", |
| 706 | category_name="Insurance Commission", |
| 707 | doctype="Tax Withholding Category", accounts=accounts, |
| 708 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10, |
| 709 | "single_threshold": 15000, "cumulative_threshold": 0}]), |
| 710 | dict(name="TDS - 194D - Individual", |
| 711 | category_name="Insurance Commission", |
| 712 | doctype="Tax Withholding Category", accounts=accounts, |
| 713 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5, |
| 714 | "single_threshold": 15000, "cumulative_threshold": 0}]), |
| 715 | dict(name="TDS - 194D - No PAN / Invalid PAN", |
| 716 | category_name="Insurance Commission", |
| 717 | doctype="Tax Withholding Category", accounts=accounts, |
| 718 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20, |
| 719 | "single_threshold": 15000, "cumulative_threshold": 0}]), |
| 720 | dict(name="TDS - 194DA - Company", |
| 721 | category_name="Non-exempt payments made under a life insurance policy", |
| 722 | doctype="Tax Withholding Category", accounts=accounts, |
| 723 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1, |
| 724 | "single_threshold": 100000, "cumulative_threshold": 0}]), |
| 725 | dict(name="TDS - 194DA - Individual", |
| 726 | category_name="Non-exempt payments made under a life insurance policy", |
| 727 | doctype="Tax Withholding Category", accounts=accounts, |
| 728 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 1, |
| 729 | "single_threshold": 100000, "cumulative_threshold": 0}]), |
| 730 | dict(name="TDS - 194DA - No PAN / Invalid PAN", |
| 731 | category_name="Non-exempt payments made under a life insurance policy", |
| 732 | doctype="Tax Withholding Category", accounts=accounts, |
| 733 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20, |
| 734 | "single_threshold": 100000, "cumulative_threshold": 0}]), |
| 735 | dict(name="TDS - 194H - Company", |
| 736 | category_name="Commission / Brokerage", |
| 737 | doctype="Tax Withholding Category", accounts=accounts, |
| 738 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5, |
| 739 | "single_threshold": 15000, "cumulative_threshold": 0}]), |
| 740 | dict(name="TDS - 194H - Individual", |
| 741 | category_name="Commission / Brokerage", |
| 742 | doctype="Tax Withholding Category", accounts=accounts, |
| 743 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 5, |
| 744 | "single_threshold": 15000, "cumulative_threshold": 0}]), |
| 745 | dict(name="TDS - 194H - No PAN / Invalid PAN", |
| 746 | category_name="Commission / Brokerage", |
| 747 | doctype="Tax Withholding Category", accounts=accounts, |
| 748 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20, |
| 749 | "single_threshold": 15000, "cumulative_threshold": 0}]), |
| 750 | dict(name="TDS - 194I - Rent - Company", |
| 751 | category_name="Rent", |
| 752 | doctype="Tax Withholding Category", accounts=accounts, |
| 753 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10, |
| 754 | "single_threshold": 180000, "cumulative_threshold": 0}]), |
| 755 | dict(name="TDS - 194I - Rent - Individual", |
| 756 | category_name="Rent", |
| 757 | doctype="Tax Withholding Category", accounts=accounts, |
| 758 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10, |
| 759 | "single_threshold": 180000, "cumulative_threshold": 0}]), |
| 760 | dict(name="TDS - 194I - Rent - No PAN / Invalid PAN", |
| 761 | category_name="Rent", |
| 762 | doctype="Tax Withholding Category", accounts=accounts, |
| 763 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20, |
| 764 | "single_threshold": 180000, "cumulative_threshold": 0}]), |
| 765 | dict(name="TDS - 194I - Rent/Machinery - Company", |
| 766 | category_name="Rent-Plant / Machinery", |
| 767 | doctype="Tax Withholding Category", accounts=accounts, |
| 768 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2, |
| 769 | "single_threshold": 180000, "cumulative_threshold": 0}]), |
| 770 | dict(name="TDS - 194I - Rent/Machinery - Individual", |
| 771 | category_name="Rent-Plant / Machinery", |
| 772 | doctype="Tax Withholding Category", accounts=accounts, |
| 773 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 2, |
| 774 | "single_threshold": 180000, "cumulative_threshold": 0}]), |
| 775 | dict(name="TDS - 194I - Rent/Machinery - No PAN / Invalid PAN", |
| 776 | category_name="Rent-Plant / Machinery", |
| 777 | doctype="Tax Withholding Category", accounts=accounts, |
| 778 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20, |
| 779 | "single_threshold": 180000, "cumulative_threshold": 0}]), |
| 780 | dict(name="TDS - 194J - Professional Fees - Company", |
| 781 | category_name="Professional Fees", |
| 782 | doctype="Tax Withholding Category", accounts=accounts, |
| 783 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10, |
| 784 | "single_threshold": 30000, "cumulative_threshold": 0}]), |
| 785 | dict(name="TDS - 194J - Professional Fees - Individual", |
| 786 | category_name="Professional Fees", |
| 787 | doctype="Tax Withholding Category", accounts=accounts, |
| 788 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10, |
| 789 | "single_threshold": 30000, "cumulative_threshold": 0}]), |
| 790 | dict(name="TDS - 194J - Professional Fees - No PAN / Invalid PAN", |
| 791 | category_name="Professional Fees", |
| 792 | doctype="Tax Withholding Category", accounts=accounts, |
| 793 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20, |
| 794 | "single_threshold": 30000, "cumulative_threshold": 0}]), |
| 795 | dict(name="TDS - 194J - Director Fees - Company", |
| 796 | category_name="Director Fees", |
| 797 | doctype="Tax Withholding Category", accounts=accounts, |
| 798 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10, |
| 799 | "single_threshold": 0, "cumulative_threshold": 0}]), |
| 800 | dict(name="TDS - 194J - Director Fees - Individual", |
| 801 | category_name="Director Fees", |
| 802 | doctype="Tax Withholding Category", accounts=accounts, |
| 803 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10, |
| 804 | "single_threshold": 0, "cumulative_threshold": 0}]), |
| 805 | dict(name="TDS - 194J - Director Fees - No PAN / Invalid PAN", |
| 806 | category_name="Director Fees", |
| 807 | doctype="Tax Withholding Category", accounts=accounts, |
| 808 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20, |
| 809 | "single_threshold": 0, "cumulative_threshold": 0}]), |
| 810 | dict(name="TDS - 194 - Dividends - Company", |
| 811 | category_name="Dividends", |
| 812 | doctype="Tax Withholding Category", accounts=accounts, |
| 813 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10, |
| 814 | "single_threshold": 2500, "cumulative_threshold": 0}]), |
| 815 | dict(name="TDS - 194 - Dividends - Individual", |
| 816 | category_name="Dividends", |
| 817 | doctype="Tax Withholding Category", accounts=accounts, |
| 818 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 10, |
| 819 | "single_threshold": 2500, "cumulative_threshold": 0}]), |
| 820 | dict(name="TDS - 194 - Dividends - No PAN / Invalid PAN", |
| 821 | category_name="Dividends", |
| 822 | doctype="Tax Withholding Category", accounts=accounts, |
| 823 | rates=[{"fiscal_year": fiscal_year, "tax_withholding_rate": 20, |
| 824 | "single_threshold": 2500, "cumulative_threshold": 0}]) |
Shivam Mishra | 1d6395c | 2020-03-30 18:14:44 +0530 | [diff] [blame] | 825 | ] |