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