Tyler Matteson | 53a6492 | 2019-01-17 14:04:01 -0500 | [diff] [blame] | 1 | # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors |
| 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
Tyler Matteson | 53a6492 | 2019-01-17 14:04:01 -0500 | [diff] [blame] | 4 | import frappe |
Subin Tom | 7004944 | 2021-08-31 18:33:16 +0530 | [diff] [blame] | 5 | import os |
| 6 | import json |
| 7 | from frappe.permissions import add_permission, update_permission_property |
Tyler Matteson | 53a6492 | 2019-01-17 14:04:01 -0500 | [diff] [blame] | 8 | from frappe.custom.doctype.custom_field.custom_field import create_custom_fields |
| 9 | |
Tyler Matteson | 53a6492 | 2019-01-17 14:04:01 -0500 | [diff] [blame] | 10 | def setup(company=None, patch=True): |
Subin Tom | 7004944 | 2021-08-31 18:33:16 +0530 | [diff] [blame] | 11 | # Company independent fixtures should be called only once at the first company setup |
| 12 | if frappe.db.count('Company', {'country': 'United States'}) <=1: |
| 13 | setup_company_independent_fixtures(patch=patch) |
| 14 | |
| 15 | def setup_company_independent_fixtures(company=None, patch=True): |
Tyler Matteson | 53a6492 | 2019-01-17 14:04:01 -0500 | [diff] [blame] | 16 | make_custom_fields() |
| 17 | add_print_formats() |
Tyler Matteson | 53a6492 | 2019-01-17 14:04:01 -0500 | [diff] [blame] | 18 | |
Deepesh Garg | 9df4532 | 2020-06-11 21:33:43 +0530 | [diff] [blame] | 19 | def make_custom_fields(update=True): |
Tyler Matteson | 53a6492 | 2019-01-17 14:04:01 -0500 | [diff] [blame] | 20 | custom_fields = { |
| 21 | 'Supplier': [ |
| 22 | dict(fieldname='irs_1099', fieldtype='Check', insert_after='tax_id', |
| 23 | label='Is IRS 1099 reporting required for supplier?') |
vishdha | d3ec1c1 | 2020-03-24 11:31:41 +0530 | [diff] [blame] | 24 | ], |
| 25 | 'Sales Order': [ |
| 26 | dict(fieldname='exempt_from_sales_tax', fieldtype='Check', insert_after='taxes_and_charges', |
| 27 | label='Is customer exempted from sales tax?') |
| 28 | ], |
| 29 | 'Sales Invoice': [ |
| 30 | dict(fieldname='exempt_from_sales_tax', fieldtype='Check', insert_after='taxes_section', |
| 31 | label='Is customer exempted from sales tax?') |
| 32 | ], |
| 33 | 'Customer': [ |
| 34 | dict(fieldname='exempt_from_sales_tax', fieldtype='Check', insert_after='represents_company', |
| 35 | label='Is customer exempted from sales tax?') |
| 36 | ], |
| 37 | 'Quotation': [ |
| 38 | dict(fieldname='exempt_from_sales_tax', fieldtype='Check', insert_after='taxes_and_charges', |
| 39 | label='Is customer exempted from sales tax?') |
Tyler Matteson | 53a6492 | 2019-01-17 14:04:01 -0500 | [diff] [blame] | 40 | ] |
| 41 | } |
Deepesh Garg | 9df4532 | 2020-06-11 21:33:43 +0530 | [diff] [blame] | 42 | create_custom_fields(custom_fields, update=update) |
Tyler Matteson | 53a6492 | 2019-01-17 14:04:01 -0500 | [diff] [blame] | 43 | |
Tyler Matteson | 53a6492 | 2019-01-17 14:04:01 -0500 | [diff] [blame] | 44 | def add_print_formats(): |
| 45 | frappe.reload_doc("regional", "print_format", "irs_1099_form") |
barredterra | 1521b31 | 2021-03-03 12:33:48 +0100 | [diff] [blame] | 46 | frappe.db.set_value("Print Format", "IRS 1099 Form", "disabled", 0) |