blob: b8f85723f5116867eedf84008731904ed8e9fdda [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
Tyler Matteson53a64922019-01-17 14:04:01 -05004import frappe
Subin Tom70049442021-08-31 18:33:16 +05305import os
6import json
7from frappe.permissions import add_permission, update_permission_property
Tyler Matteson53a64922019-01-17 14:04:01 -05008from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
9
Ankush Menat494bd9e2022-03-28 18:52:46 +053010
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
Ankush Menat494bd9e2022-03-28 18:52:46 +053013 if frappe.db.count("Company", {"country": "United States"}) <= 1:
Subin Tom70049442021-08-31 18:33:16 +053014 setup_company_independent_fixtures(patch=patch)
15
Ankush Menat494bd9e2022-03-28 18:52:46 +053016
Subin Tom70049442021-08-31 18:33:16 +053017def setup_company_independent_fixtures(company=None, patch=True):
Tyler Matteson53a64922019-01-17 14:04:01 -050018 make_custom_fields()
19 add_print_formats()
Tyler Matteson53a64922019-01-17 14:04:01 -050020
Ankush Menat494bd9e2022-03-28 18:52:46 +053021
Deepesh Garg9df45322020-06-11 21:33:43 +053022def make_custom_fields(update=True):
Tyler Matteson53a64922019-01-17 14:04:01 -050023 custom_fields = {
Ankush Menat494bd9e2022-03-28 18:52:46 +053024 "Supplier": [
25 dict(
26 fieldname="irs_1099",
27 fieldtype="Check",
28 insert_after="tax_id",
29 label="Is IRS 1099 reporting required for supplier?",
30 )
vishdhad3ec1c12020-03-24 11:31:41 +053031 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +053032 "Sales Order": [
33 dict(
34 fieldname="exempt_from_sales_tax",
35 fieldtype="Check",
36 insert_after="taxes_and_charges",
37 label="Is customer exempted from sales tax?",
38 )
vishdhad3ec1c12020-03-24 11:31:41 +053039 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +053040 "Sales Invoice": [
41 dict(
42 fieldname="exempt_from_sales_tax",
43 fieldtype="Check",
44 insert_after="taxes_section",
45 label="Is customer exempted from sales tax?",
46 )
vishdhad3ec1c12020-03-24 11:31:41 +053047 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +053048 "Customer": [
49 dict(
50 fieldname="exempt_from_sales_tax",
51 fieldtype="Check",
52 insert_after="represents_company",
53 label="Is customer exempted from sales tax?",
54 )
vishdhad3ec1c12020-03-24 11:31:41 +053055 ],
Ankush Menat494bd9e2022-03-28 18:52:46 +053056 "Quotation": [
57 dict(
58 fieldname="exempt_from_sales_tax",
59 fieldtype="Check",
60 insert_after="taxes_and_charges",
61 label="Is customer exempted from sales tax?",
62 )
63 ],
Tyler Matteson53a64922019-01-17 14:04:01 -050064 }
Deepesh Garg9df45322020-06-11 21:33:43 +053065 create_custom_fields(custom_fields, update=update)
Tyler Matteson53a64922019-01-17 14:04:01 -050066
Ankush Menat494bd9e2022-03-28 18:52:46 +053067
Tyler Matteson53a64922019-01-17 14:04:01 -050068def add_print_formats():
69 frappe.reload_doc("regional", "print_format", "irs_1099_form")
barredterra1521b312021-03-03 12:33:48 +010070 frappe.db.set_value("Print Format", "IRS 1099 Form", "disabled", 0)