blob: cf78f927c597ada96325f81d286a6c093ac0ad3b [file] [log] [blame]
Tyler Matteson53a64922019-01-17 14:04:01 -05001# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
2# License: GNU General Public License v3. See license.txt
3
4from __future__ import unicode_literals
5import frappe
Subin Tom70049442021-08-31 18:33:16 +05306import os
7import json
8from frappe.permissions import add_permission, update_permission_property
Tyler Matteson53a64922019-01-17 14:04:01 -05009from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
10
Tyler Matteson53a64922019-01-17 14:04:01 -050011def setup(company=None, patch=True):
Subin Tom70049442021-08-31 18:33:16 +053012 # 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
16def setup_company_independent_fixtures(company=None, patch=True):
Tyler Matteson53a64922019-01-17 14:04:01 -050017 make_custom_fields()
18 add_print_formats()
Tyler Matteson53a64922019-01-17 14:04:01 -050019
Deepesh Garg9df45322020-06-11 21:33:43 +053020def make_custom_fields(update=True):
Tyler Matteson53a64922019-01-17 14:04:01 -050021 custom_fields = {
22 'Supplier': [
23 dict(fieldname='irs_1099', fieldtype='Check', insert_after='tax_id',
24 label='Is IRS 1099 reporting required for supplier?')
vishdhad3ec1c12020-03-24 11:31:41 +053025 ],
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 Matteson53a64922019-01-17 14:04:01 -050041 ]
42 }
Deepesh Garg9df45322020-06-11 21:33:43 +053043 create_custom_fields(custom_fields, update=update)
Tyler Matteson53a64922019-01-17 14:04:01 -050044
Tyler Matteson53a64922019-01-17 14:04:01 -050045def add_print_formats():
46 frappe.reload_doc("regional", "print_format", "irs_1099_form")
barredterra1521b312021-03-03 12:33:48 +010047 frappe.db.set_value("Print Format", "IRS 1099 Form", "disabled", 0)