# Copyright (c) 2020, Wahni Green Technologies and Contributors
# License: GNU General Public License v3. See license.txt

import xhiveframework

from xhiveerp.regional.saudi_arabia.setup import add_print_formats


def execute():
	company = xhiveframework.get_all("Company", filters={"country": "Saudi Arabia"})
	if company:
		add_print_formats()
		return

	if xhiveframework.db.exists("DocType", "Print Format"):
		xhiveframework.reload_doc("regional", "print_format", "ksa_vat_invoice", force=True)
		xhiveframework.reload_doc("regional", "print_format", "ksa_pos_invoice", force=True)
		for d in ("KSA VAT Invoice", "KSA POS Invoice"):
			xhiveframework.db.set_value("Print Format", d, "disabled", 1)
