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