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