Frappe cloud
https://site.erpnext.com/api/method/frappe.desk.query_report.get_script
{“message”:{“script”:“frappe.query_reports[‘MoM Expenses’]={}”,“html_format”:null,“execution_time”:0.002079,“filters”:,“custom_report_name”:null}}
Local setup
{“message”:{“script”:“// Copyright (c) 2024, Nitin Jain and contributors\n// For license information, please see license.txt\n\nfrappe.query_reports["MoM Expenses"] = {\n "filters": [\n {\n "fieldname": "period",\n "label": __("Period"),\n "fieldtype": "Select",\n "options": ["Monthly", "Quarterly", "Yearly"],\n "default": "Monthly",\n "reqd": 1\n },\n {\n "fieldname": "financial_year",\n "label": __("Financial Year"),\n "fieldtype": "Select",\n "options": get_financial_years(),\n "default": get_default_financial_year(),\n "reqd": 1\n },\n {\n "fieldname": "vendor_name",\n "label": __("Selected Vendor"),\n "fieldtype": "Link",\n "options": "NG 02 Vendor Master", // Link to the correct doctype\n "reqd": 0\n }\n ]\n};\n\n\n// Helper function to generate financial year options\nfunction get_financial_years() {\n const currentYear = new Date().getFullYear();\n const financialYears = ;\n for (let i = 0; i < 5; i++) {\n const startYear = currentYear - i;\n const endYear = startYear + 1;\n financialYears.push(${startYear}-${endYear}
);\n }\n return financialYears;\n}\n\n// Helper function to get the default financial year\nfunction get_default_financial_year() {\n const currentDate = new Date();\n const currentMonth = currentDate.getMonth() + 1; // Months are 0-indexed in JS\n const currentYear = currentDate.getFullYear();\n\n // If before April, return the previous financial year\n if (currentMonth < 4) {\n return ${currentYear - 1}-${currentYear}
;\n } else {\n return ${currentYear}-${currentYear + 1}
;\n }\n}\n\n\n\n//# sourceURL=mom_expenses.js”,“html_format”:null,“execution_time”:0,“filters”:,“custom_report_name”:null}}