blob: 2e31c03d5c6ae06ade8e4cc654a6f8197f2b944c [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
Dany Robertbb3119c2021-12-07 11:05:41 +00006from erpnext.regional.united_arab_emirates.setup import make_custom_fields as uae_custom_fields
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
Dany Robertbb3119c2021-12-07 11:05:41 +000016def add_print_formats():
Dany Roberta0aeace2021-12-07 12:39:39 +000017 frappe.reload_doc("regional", "print_format", "detailed_tax_invoice", force=True)
18 frappe.reload_doc("regional", "print_format", "simplified_tax_invoice", force=True)
19 frappe.reload_doc("regional", "print_format", "tax_invoice", force=True)
20 frappe.reload_doc("regional", "print_format", "ksa_vat_invoice", force=True)
21 frappe.reload_doc("regional", "print_format", "ksa_pos_invoice", force=True)
Dany Robertbb3119c2021-12-07 11:05:41 +000022
Dany Robertca850942021-12-08 07:52:06 +053023 for d in ('Simplified Tax Invoice', 'Detailed Tax Invoice', 'Tax Invoice', 'KSA VAT Invoice', 'KSA POS Invoice'):
24 frappe.db.set_value("Print Format", d, "disabled", 0)
Dany Robertbb3119c2021-12-07 11:05:41 +000025
Ahmadcb0c2d12021-08-26 07:35:59 +050026def add_permissions():
27 """Add Permissions for KSA VAT Setting."""
28 add_permission('KSA VAT Setting', 'All', 0)
29 for role in ('Accounts Manager', 'Accounts User', 'System Manager'):
30 add_permission('KSA VAT Setting', role, 0)
31 update_permission_property('KSA VAT Setting', role, 0, 'write', 1)
32 update_permission_property('KSA VAT Setting', role, 0, 'create', 1)
33
34 """Enable KSA VAT Report"""
35 frappe.db.set_value('Report', 'KSA VAT', 'disabled', 0)
Ahmad87380d02021-09-06 23:36:55 +050036
ahmadpak2a5beec2021-10-30 17:18:45 +030037def make_custom_fields():
38 """Create Custom fields
39 - QR code Image file
40 - Company Name in Arabic
41 - Address in Arabic
42 """
Deepesh Gargc81d4732021-11-08 17:14:03 +053043 custom_fields = {
44 'Sales Invoice': [
45 dict(
Dany Robert6a6d6f72021-12-07 12:17:45 +053046 fieldname='ksa_einv_qr',
47 label='KSA E-Invoicing QR',
Deepesh Gargc81d4732021-11-08 17:14:03 +053048 fieldtype='Attach Image',
49 read_only=1, no_copy=1, hidden=1
50 )
51 ],
Dany Robertd06c4b52021-12-07 12:29:59 +053052 'POS Invoice': [
53 dict(
54 fieldname='ksa_einv_qr',
55 label='KSA E-Invoicing QR',
56 fieldtype='Attach Image',
57 read_only=1, no_copy=1, hidden=1
58 )
59 ],
Deepesh Gargc81d4732021-11-08 17:14:03 +053060 'Address': [
61 dict(
62 fieldname='address_in_arabic',
63 label='Address in Arabic',
64 fieldtype='Data',
65 insert_after='address_line2'
66 )
67 ],
68 'Company': [
69 dict(
70 fieldname='company_name_in_arabic',
71 label='Company Name In Arabic',
72 fieldtype='Data',
73 insert_after='company_name'
74 )
75 ]
76 }
Ahmad9dae36b2021-09-17 01:51:32 +050077
Deepesh Gargc81d4732021-11-08 17:14:03 +053078 create_custom_fields(custom_fields, update=True)
ahmadpak2a5beec2021-10-30 17:18:45 +030079
Deepesh Gargc81d4732021-11-08 17:14:03 +053080def update_regional_tax_settings(country, company):
81 create_ksa_vat_setting(company)