From a5a6610fe45b4fee86584e53eaebe10c838c9618 Mon Sep 17 00:00:00 2001 From: Aysha-sithara Date: Wed, 13 May 2026 13:12:36 +0300 Subject: [PATCH 1/2] Moved reports to Standard from Custom --- zatca_erpgulf/fixtures/report.json | 44 ----- zatca_erpgulf/hooks.py | 304 +---------------------------- 2 files changed, 3 insertions(+), 345 deletions(-) delete mode 100644 zatca_erpgulf/fixtures/report.json diff --git a/zatca_erpgulf/fixtures/report.json b/zatca_erpgulf/fixtures/report.json deleted file mode 100644 index c94f39a..0000000 --- a/zatca_erpgulf/fixtures/report.json +++ /dev/null @@ -1,44 +0,0 @@ -[ - { - "add_total_row": 0, - "columns": [], - "disabled": 0, - "docstatus": 0, - "doctype": "Report", - "filters": [], - "is_standard": "Yes", - "javascript": "frappe.query_reports[\"Zatca Status Report\"] = {\r\n \"filters\": [\r\n {\r\n fieldname: \"company\",\r\n label: __(\"Company\"),\r\n fieldtype: \"Link\",\r\n options: \"Company\",\r\n default: frappe.defaults.get_user_default(\"Company\"),\r\n reqd: 1\r\n },\r\n {\r\n fieldname: \"dt_from\",\r\n label: __(\"From\"),\r\n fieldtype: \"Date\",\r\n default: frappe.datetime.add_months(frappe.datetime.get_today(), -12)\r\n },\r\n {\r\n fieldname: \"dt_to\",\r\n label: __(\"To\"),\r\n fieldtype: \"Date\",\r\n default: frappe.datetime.get_today()\r\n },\r\n {\r\n fieldname: \"status\",\r\n label: __(\"Status\"),\r\n fieldtype: \"Select\",\r\n options: \"\\nReported\\nCleared\\n503 Service Unavailable\\nIntra-company transfer\\nNot Submitted\",\r\n default: \"Reported\"\r\n }\r\n ],\r\n\r\n onload: function(report) {\r\n // onload code if needed\r\n }\r\n};\r\n", - "json": null, - "letter_head": "Sample letterhead", - "modified": "2026-02-04 13:49:07.709031", - "module": "Zatca Erpgulf", - "name": "Zatca Status Report", - "prepared_report": 0, - "query": "", - "ref_doctype": "Sales Invoice", - "reference_report": null, - "report_name": "Zatca Status Report", - "report_script": "def get_columns():\r\n return [\r\n {'fieldname': 'name', 'label': _('Inv.Number'), 'fieldtype': 'Link', 'options': 'Sales Invoice', 'width': 220},\r\n {'fieldname': 'posting_date', 'label': _('Date'), 'fieldtype': 'Date', 'width': 160},\r\n {'fieldname': 'customer_name', 'label': _('Customer'), 'fieldtype': 'Data', 'width': 220},\r\n {'fieldname': 'grand_total', 'label': _('Total'), 'fieldtype': 'Currency', 'width': 160},\r\n {'fieldname': 'custom_zatca_status', 'label': _('Status'), 'fieldtype': 'Data', 'width': 180}\r\n ]\r\n\r\n\r\ndef get_data_and_chart(filters):\r\n dt_from = filters.get('dt_from')\r\n dt_to = filters.get('dt_to')\r\n status = filters.get('status')\r\n company = filters.get('company')\r\n\r\n conditions = [\"1=1\"]\r\n values = {}\r\n\r\n if company:\r\n conditions.append(\"company = %(company)s\")\r\n values['company'] = company\r\n\r\n if dt_from and dt_to:\r\n conditions.append(\"posting_date BETWEEN %(dt_from)s AND %(dt_to)s\")\r\n values['dt_from'] = dt_from\r\n values['dt_to'] = dt_to\r\n elif dt_from:\r\n conditions.append(\"posting_date >= %(dt_from)s\")\r\n values['dt_from'] = dt_from\r\n elif dt_to:\r\n conditions.append(\"posting_date <= %(dt_to)s\")\r\n values['dt_to'] = dt_to\r\n\r\n if status and status != \"Not Submitted\":\r\n conditions.append(\"custom_zatca_status = %(status)s\")\r\n values['status'] = status\r\n\r\n where_clause = \" AND \".join(conditions)\r\n\r\n query = f\"\"\"\r\n SELECT \r\n name,\r\n customer_name,\r\n posting_date,\r\n grand_total,\r\n custom_zatca_status,\r\n docstatus\r\n FROM `tabSales Invoice`\r\n WHERE {where_clause}\r\n ORDER BY posting_date DESC\r\n \"\"\"\r\n\r\n invoices = frappe.db.sql(query, values, as_dict=True)\r\n\r\n # Apply 'Not Submitted' filter\r\n if status == \"Not Submitted\":\r\n invoices = [inv for inv in invoices if inv.get(\"docstatus\") == 0 or not inv.get(\"custom_zatca_status\")]\r\n\r\n return invoices\r\n\r\n\r\n# Run report\r\ncolumns = get_columns()\r\ndata = get_data_and_chart(filters)\r\ndata = columns, data, None, None\r\n", - "report_type": "Script Report", - "roles": [ - { - "parent": "Zatca Status Report", - "parentfield": "roles", - "parenttype": "Report", - "role": "Accounts Manager" - }, - { - "parent": "Zatca Status Report", - "parentfield": "roles", - "parenttype": "Report", - "role": "Accounts User" - }, - { - "parent": "Zatca Status Report", - "parentfield": "roles", - "parenttype": "Report", - "role": "Sales User" - } - ] - } -] \ No newline at end of file diff --git a/zatca_erpgulf/hooks.py b/zatca_erpgulf/hooks.py index 0933cd8..9d83a12 100644 --- a/zatca_erpgulf/hooks.py +++ b/zatca_erpgulf/hooks.py @@ -21,216 +21,6 @@ ] -# Includes in -# ------------------ - -# include js, css files in header of desk.html -# app_include_css = "/assets/zatca_erpgulf/css/zatca_erpgulf.css" -# app_include_js = "/assets/zatca_erpgulf/js/zatca_erpgulf.js" - -# include js, css files in header of web template -# web_include_css = "/assets/zatca_erpgulf/css/zatca_erpgulf.css" -# web_include_js = "/assets/zatca_erpgulf/js/zatca_erpgulf.js" - -# include custom scss in every website theme (without file extension ".scss") -# website_theme_scss = "zatca_erpgulf/public/scss/website" - -# include js, css files in header of web form -# webform_include_js = {"doctype": "public/js/doctype.js"} -# webform_include_css = {"doctype": "public/css/doctype.css"} - -# include js in page -# page_js = {"page" : "public/js/file.js"} - -# include js in doctype views -# doctype_js = {"doctype" : "public/js/doctype.js"} -# doctype_list_js = {"doctype" : "public/js/doctype_list.js"} -# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"} -# doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"} - -# Home Pages -# ---------- - -# application home page (will override Website Settings) -# home_page = "login" - -# website user home page (by Role) -# role_home_page = { -# "Role": "home_page" -# } - -# Generators -# ---------- - -# automatically create page for each record of this doctype -# website_generators = ["Web Page"] - -# Jinja -# ---------- - -# add methods and filters to jinja environment -# jinja = { -# "methods": "zatca_erpgulf.utils.jinja_methods", -# "filters": "zatca_erpgulf.utils.jinja_filters" -# } - -# Installation -# ------------ - -# before_install = "zatca_erpgulf.install.before_install" -# after_install = "zatca_erpgulf.install.after_install" - -# Uninstallation -# ------------ - -# before_uninstall = "zatca_erpgulf.uninstall.before_uninstall" -# after_uninstall = "zatca_erpgulf.uninstall.after_uninstall" - -# Integration Setup -# ------------------ -# To set up dependencies/integrations with other apps -# Name of the app being installed is passed as an argument - -# before_app_install = "zatca_erpgulf.utils.before_app_install" -# after_app_install = "zatca_erpgulf.utils.after_app_install" - -# Integration Cleanup -# ------------------- -# To clean up dependencies/integrations with other apps -# Name of the app being uninstalled is passed as an argument - -# before_app_uninstall = "zatca_erpgulf.utils.before_app_uninstall" -# after_app_uninstall = "zatca_erpgulf.utils.after_app_uninstall" - -# Desk Notifications -# ------------------ -# See frappe.core.notifications.get_notification_config - -# notification_config = "zatca_erpgulf.notifications.get_notification_config" - -# Permissions -# ----------- -# Permissions evaluated in scripted ways - -# permission_query_conditions = { -# "Event": "frappe.desk.doctype.event.event.get_permission_query_conditions", -# } -# -# has_permission = { -# "Event": "frappe.desk.doctype.event.event.has_permission", -# } - -# DocType Class -# --------------- -# Override standard doctype classes - -# override_doctype_class = { -# "ToDo": "custom_app.overrides.CustomToDo" -# } - -# Document Events -# --------------- -# Hook on document methods and events - -# doc_events = { -# "*": { -# "on_update": "method", -# "on_cancel": "method", -# "on_trash": "method" -# } -# } - -# Scheduled Tasks -# --------------- - -# scheduler_events = { -# "all": [ -# "zatca_erpgulf.tasks.all" -# ], -# "daily": [ -# "zatca_erpgulf.tasks.daily" -# ], -# "hourly": [ -# "zatca_erpgulf.tasks.hourly" -# ], -# "weekly": [ -# "zatca_erpgulf.tasks.weekly" -# ], -# "monthly": [ -# "zatca_erpgulf.tasks.monthly" -# ], -# } - -# Testing -# ------- - -# before_tests = "zatca_erpgulf.install.before_tests" - -# Overriding Methods -# ------------------------------ -# -# override_whitelisted_methods = { -# "frappe.desk.doctype.event.event.get_events": "zatca_erpgulf.event.get_events" -# } -# -# each overriding function accepts a `data` argument; -# generated from the base implementation of the doctype dashboard, -# along with any modifications made in other Frappe apps -# override_doctype_dashboards = { -# "Task": "zatca_erpgulf.task.get_dashboard_data" -# } - -# exempt linked doctypes from being automatically cancelled -# -# auto_cancel_exempted_doctypes = ["Auto Repeat"] - -# Ignore links to specified DocTypes when deleting documents -# ----------------------------------------------------------- - -# ignore_links_on_delete = ["Communication", "ToDo"] - -# Request Events -# ---------------- -# before_request = ["zatca_erpgulf.utils.before_request"] -# after_request = ["zatca_erpgulf.utils.after_request"] - -# Job Events -# ---------- -# before_job = ["zatca_erpgulf.utils.before_job"] -# after_job = ["zatca_erpgulf.utils.after_job"] - -# User Data Protection -# -------------------- - -# user_data_fields = [ -# { -# "doctype": "{doctype_1}", -# "filter_by": "{filter_by}", -# "redact_fields": ["{field_1}", "{field_2}"], -# "partial": 1, -# }, -# { -# "doctype": "{doctype_2}", -# "filter_by": "{filter_by}", -# "partial": 1, -# }, -# { -# "doctype": "{doctype_3}", -# "strict": False, -# }, -# { -# "doctype": "{doctype_4}" -# } -# ] - -# Authentication and authorization -# -------------------------------- - -# auth_hooks = [ -# "zatca_erpgulf.auth.validate" -# ] - -# schedule for every 10 minutes every day 24 hours scheduler_events = { "cron": { "*/30 * * * *": [ @@ -240,14 +30,6 @@ } -# # schdule for every 10 minutes from 1 am to 7 am -# scheduler_events = { -# "cron": { -# "*/10 1-7 * * * ": [ -# "zatca_erpgulf.zatca_erpgulf.scheduler_event.submit_invoices_to_zatca_background_process" -# ] -# } -# } doc_events = { "Sales Invoice": { # "before_insert":"zatca_erpgulf.zatca_erpgulf.sales_invoice_hooks.set_draft_series", @@ -277,20 +59,6 @@ ] } -# doc_events = { -# "Sales Invoice": { -# "before_cancel": "zatca_erpgulf.zatca_erpgulf.validations.before_save", -# "before_submit": "zatca_erpgulf.zatca_erpgulf.tax_error.validate_sales_invoice_taxes", -# "after_insert": "zatca_erpgulf.zatca_erpgulf.validations.duplicating_invoice", -# "on_submit": "zatca_erpgulf.zatca_erpgulf.sign_invoice.zatca_background_on_submit", -# }, -# "POS Invoice": { -# "before_cancel": "zatca_erpgulf.zatca_erpgulf.validations.before_save", -# "before_submit": "zatca_erpgulf.zatca_erpgulf.tax_error.validate_sales_invoice_taxes", -# "after_insert": "zatca_erpgulf.zatca_erpgulf.validations.duplicating_invoice", -# "on_submit": "zatca_erpgulf.zatca_erpgulf.pos_sign.zatca_background_on_submit", -# }, -# } doctype_js = { "Sales Invoice": [ # "public/js/draft.js", @@ -309,79 +77,13 @@ } -# fixtures = [ {"dt": "Custom Field","filters": [["module", "=", "Zatca Erpgulf"]] }] - -# fixtures = [ -# # { -# # "dt": "Number Card", -# # "filters": [ -# # [ -# # "name", -# # "in", -# # [ -# # "Cleared This Month", -# # "Not Submitted This Month", -# # "Reported This Month", -# # "503 Service Unavailable This Month", -# # ], -# # ] -# # ], -# # }, -# # { -# # "dt": "Dashboard Chart", -# # "filters": [["name", "=", "Monthly Invoices Reported to ZATCA"]], -# # }, -# # {"dt": "Dashboard", "filters": [["name", "=", "ZATCA Dashboard"]]}, -# # { -# # "dt": "Workspace", -# # "filters": [["name", "=", "ZATCA ERPGulf"]], # Use actual Workspace name here -# # }, -# # {"dt": "Workspace", "filters": {"module": "Zatca Erpgulf"}}, -# {"dt": "Custom Field", "filters": [["module", "=", "Zatca Erpgulf"]]}, -# # {"dt": "Report", "filters": {"module": "Zatca Erpgulf"}}, -# { -# "dt": "Report", -# "filters": [ -# [ -# "name", -# "in", -# [ -# "Item-wise Sales Register", -# "Item-wise Purchase Register", -# "Zatca Status Report", -# ], -# ] -# ], -# }, -# # {"dt": "Page", "filters": [["name", "in", ["setup-zatca-phase-2"]]]}, -# # {"dt": "Page", "filters": {"module": "Zatca Erpgulf"}}, -# ] - app_include_css = "/assets/zatca_erpgulf/css/tooltip.css" app_include_js = "/assets/zatca_erpgulf/js/tooltip.js" + fixtures = [ { "dt": "Desktop Icon", - "filters": [ - ["label", "=", "ZATCA ERPGulf"] - ] - } -] -fixtures = [ - {"dt": "Custom Field", "filters": [["module", "=", "Zatca Erpgulf"]]}, - - { - "dt": "Report", - "filters": [ - [ - "name", - "in", - [ - # "Item-wise Sales Register", - # "Item-wise Purchase Register", - "Zatca Status Report", - ], - ] - ], + "filters": [["label", "=", "ZATCA ERPGulf"]] }, + {"dt": "Custom Field", "filters": [["module", "=", "Zatca Erpgulf"]]}, ] \ No newline at end of file From 5739b69143385de5ff9293e353e72d3be2d4f459 Mon Sep 17 00:00:00 2001 From: Aysha-sithara Date: Wed, 13 May 2026 14:26:19 +0300 Subject: [PATCH 2/2] Fixed routing issue --- zatca_erpgulf/hooks.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zatca_erpgulf/hooks.py b/zatca_erpgulf/hooks.py index 9d83a12..493c449 100644 --- a/zatca_erpgulf/hooks.py +++ b/zatca_erpgulf/hooks.py @@ -15,8 +15,7 @@ "name": app_name, "logo": "/assets/zatca_erpgulf/images/ERPGulf.png", "title": app_title, - "route": "zatca-erpgulf", - # "has_permission": "zatca_erpgulf.check_app_permission", + "route": "/app/zatca-erpgulf", # <-- add leading /app/ } ]