2021-07-14 07:03:45 +00:00
|
|
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
|
2021-08-09 12:28:52 +00:00
|
|
|
import frappe
|
2021-07-28 19:24:48 +00:00
|
|
|
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
2021-07-14 07:03:45 +00:00
|
|
|
from frappe.permissions import add_permission, update_permission_property
|
|
|
|
|
2022-03-28 13:22:46 +00:00
|
|
|
|
2021-07-26 12:41:38 +00:00
|
|
|
def setup(company=None, patch=True):
|
2021-08-09 12:28:52 +00:00
|
|
|
make_custom_fields()
|
2021-07-14 07:03:45 +00:00
|
|
|
add_permissions()
|
|
|
|
|
2022-03-28 13:22:46 +00:00
|
|
|
|
2021-07-28 19:24:48 +00:00
|
|
|
def make_custom_fields(update=True):
|
|
|
|
is_zero_rated = dict(
|
|
|
|
fieldname="is_zero_rated",
|
|
|
|
label="Is Zero Rated",
|
|
|
|
fieldtype="Check",
|
|
|
|
fetch_from="item_code.is_zero_rated",
|
|
|
|
insert_after="description",
|
|
|
|
print_hide=1,
|
|
|
|
)
|
|
|
|
custom_fields = {
|
|
|
|
"Item": [
|
|
|
|
dict(
|
|
|
|
fieldname="is_zero_rated",
|
|
|
|
label="Is Zero Rated",
|
|
|
|
fieldtype="Check",
|
|
|
|
insert_after="item_group",
|
|
|
|
print_hide=1,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
"Sales Invoice Item": is_zero_rated,
|
|
|
|
"Purchase Invoice Item": is_zero_rated,
|
|
|
|
}
|
2021-08-19 08:11:10 +00:00
|
|
|
|
2021-07-28 19:24:48 +00:00
|
|
|
create_custom_fields(custom_fields, update=update)
|
|
|
|
|
2022-03-28 13:22:46 +00:00
|
|
|
|
2021-07-14 07:03:45 +00:00
|
|
|
def add_permissions():
|
2021-08-09 12:28:52 +00:00
|
|
|
"""Add Permissions for South Africa VAT Settings and South Africa VAT Account
|
|
|
|
and VAT Audit Report"""
|
2021-07-14 07:03:45 +00:00
|
|
|
for doctype in ("South Africa VAT Settings", "South Africa VAT Account"):
|
|
|
|
add_permission(doctype, "All", 0)
|
|
|
|
for role in ("Accounts Manager", "Accounts User", "System Manager"):
|
|
|
|
add_permission(doctype, role, 0)
|
|
|
|
update_permission_property(doctype, role, 0, "write", 1)
|
2021-08-09 12:28:52 +00:00
|
|
|
update_permission_property(doctype, role, 0, "create", 1)
|
2022-03-28 13:22:46 +00:00
|
|
|
|
2021-08-09 12:28:52 +00:00
|
|
|
if not frappe.db.get_value("Custom Role", dict(report="VAT Audit Report")):
|
|
|
|
frappe.get_doc(
|
|
|
|
dict(
|
|
|
|
doctype="Custom Role",
|
|
|
|
report="VAT Audit Report",
|
|
|
|
roles=[dict(role="Accounts User"), dict(role="Accounts Manager"), dict(role="Auditor")],
|
|
|
|
)
|
|
|
|
).insert()
|