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