blob: 3afcf538839e29d53da04e9d3ce540fbe1f14a60 [file] [log] [blame]
rohitwaghchaure4e17fae2017-12-12 14:40:52 +05301# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
2# License: GNU General Public License v3. See license.txt
3
Ahmadcb0c2d12021-08-26 07:35:59 +05004import frappe
5from frappe.permissions import add_permission, update_permission_property
Ahmad87380d02021-09-06 23:36:55 +05006from erpnext.regional.united_arab_emirates.setup import make_custom_fields as uae_custom_fields, add_print_formats
Ahmadcb0c2d12021-08-26 07:35:59 +05007from erpnext.regional.saudi_arabia.wizard.operations.setup_ksa_vat_setting import create_ksa_vat_setting
Deepesh Gargc81d4732021-11-08 17:14:03 +05308from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
rohitwaghchaure4e17fae2017-12-12 14:40:52 +05309
10def setup(company=None, patch=True):
Ahmad87380d02021-09-06 23:36:55 +050011 uae_custom_fields()
rohitwaghchaure4e17fae2017-12-12 14:40:52 +053012 add_print_formats()
Ahmadcb0c2d12021-08-26 07:35:59 +050013 add_permissions()
ahmadpak2a5beec2021-10-30 17:18:45 +030014 make_custom_fields()
Ahmadcb0c2d12021-08-26 07:35:59 +050015
16def add_permissions():
17 """Add Permissions for KSA VAT Setting."""
18 add_permission('KSA VAT Setting', 'All', 0)
19 for role in ('Accounts Manager', 'Accounts User', 'System Manager'):
20 add_permission('KSA VAT Setting', role, 0)
21 update_permission_property('KSA VAT Setting', role, 0, 'write', 1)
22 update_permission_property('KSA VAT Setting', role, 0, 'create', 1)
23
24 """Enable KSA VAT Report"""
25 frappe.db.set_value('Report', 'KSA VAT', 'disabled', 0)
Ahmad87380d02021-09-06 23:36:55 +050026
ahmadpak2a5beec2021-10-30 17:18:45 +030027def make_custom_fields():
28 """Create Custom fields
29 - QR code Image file
30 - Company Name in Arabic
31 - Address in Arabic
32 """
Deepesh Gargc81d4732021-11-08 17:14:03 +053033 custom_fields = {
34 'Sales Invoice': [
35 dict(
Dany Robert6a6d6f72021-12-07 12:17:45 +053036 fieldname='ksa_einv_qr',
37 label='KSA E-Invoicing QR',
Deepesh Gargc81d4732021-11-08 17:14:03 +053038 fieldtype='Attach Image',
39 read_only=1, no_copy=1, hidden=1
40 )
41 ],
42 'Address': [
43 dict(
44 fieldname='address_in_arabic',
45 label='Address in Arabic',
46 fieldtype='Data',
47 insert_after='address_line2'
48 )
49 ],
50 'Company': [
51 dict(
52 fieldname='company_name_in_arabic',
53 label='Company Name In Arabic',
54 fieldtype='Data',
55 insert_after='company_name'
56 )
57 ]
58 }
Ahmad9dae36b2021-09-17 01:51:32 +050059
Deepesh Gargc81d4732021-11-08 17:14:03 +053060 create_custom_fields(custom_fields, update=True)
ahmadpak2a5beec2021-10-30 17:18:45 +030061
Deepesh Gargc81d4732021-11-08 17:14:03 +053062def update_regional_tax_settings(country, company):
63 create_ksa_vat_setting(company)