frappe.listview_settings["Account"] = {
    onload: function (listview) {
        listview.page.add_inner_button(__("Export Chart of Accounts"), function () {
            frappe.call({
                method: "jey_erp.custom.account_export.export_chart_of_accounts",
                callback: function (r) {
                    if (!r.message) return;
                    const json = JSON.stringify(r.message, null, 2);
                    const blob = new Blob([json], { type: "application/json" });
                    const url = URL.createObjectURL(blob);
                    const a = document.createElement("a");
                    a.href = url;
                    a.download = "az_chart_of_accounts.json";
                    a.click();
                    URL.revokeObjectURL(url);
                },
            });
        });
    },
};
