style: format js files

This commit is contained in:
Ankush Menat
2024-03-11 10:58:48 +05:30
parent c46be27e9e
commit 4c629d31c6
605 changed files with 27454 additions and 18952 deletions

View File

@@ -1,39 +1,39 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
frappe.ui.form.on('Import Supplier Invoice', {
onload: function(frm) {
frappe.ui.form.on("Import Supplier Invoice", {
onload: function (frm) {
frappe.realtime.on("import_invoice_update", function (data) {
frm.dashboard.show_progress(data.title, (data.count / data.total) * 100, data.message);
if (data.count == data.total) {
window.setTimeout(title => frm.dashboard.hide_progress(title), 1500, data.title);
window.setTimeout((title) => frm.dashboard.hide_progress(title), 1500, data.title);
}
});
},
setup: function(frm) {
frm.set_query("tax_account", function(doc) {
setup: function (frm) {
frm.set_query("tax_account", function (doc) {
return {
filters: {
account_type: 'Tax',
company: doc.company
}
account_type: "Tax",
company: doc.company,
},
};
});
frm.set_query("default_buying_price_list", function(doc) {
frm.set_query("default_buying_price_list", function (doc) {
return {
filters: {
currency: frappe.get_doc(":Company", doc.company).default_currency
}
currency: frappe.get_doc(":Company", doc.company).default_currency,
},
};
});
},
refresh: function(frm) {
refresh: function (frm) {
frm.trigger("toggle_read_only_fields");
},
toggle_read_only_fields: function(frm) {
toggle_read_only_fields: function (frm) {
if (in_list(["File Import Completed", "Processing File Data"], frm.doc.status)) {
cur_frm.set_read_only();
cur_frm.refresh_fields();
@@ -41,6 +41,5 @@ frappe.ui.form.on('Import Supplier Invoice', {
} else {
frm.set_df_property("import_invoices", "hidden", 0);
}
}
},
});

View File

@@ -1,8 +1,7 @@
// Copyright (c) 2021, Havenir Solutions and contributors
// For license information, please see license.txt
frappe.ui.form.on('KSA VAT Sales Account', {
frappe.ui.form.on("KSA VAT Sales Account", {
// refresh: function(frm) {
// }
});

View File

@@ -1,8 +1,8 @@
// Copyright (c) 2021, Havenir Solutions and contributors
// For license information, please see license.txt
frappe.ui.form.on('KSA VAT Setting', {
frappe.ui.form.on("KSA VAT Setting", {
onload: function () {
frappe.breadcrumbs.add('Accounts', 'KSA VAT Setting');
}
frappe.breadcrumbs.add("Accounts", "KSA VAT Setting");
},
});

View File

@@ -1,5 +1,5 @@
frappe.listview_settings['KSA VAT Setting'] = {
onload () {
frappe.breadcrumbs.add('Accounts');
}
}
frappe.listview_settings["KSA VAT Setting"] = {
onload() {
frappe.breadcrumbs.add("Accounts");
},
};

View File

@@ -1,8 +1,7 @@
// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on('Lower Deduction Certificate', {
frappe.ui.form.on("Lower Deduction Certificate", {
// refresh: function(frm) {
// }
});

View File

@@ -1,8 +1,7 @@
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on('Product Tax Category', {
frappe.ui.form.on("Product Tax Category", {
// refresh: function(frm) {
// }
});

View File

@@ -1,23 +1,23 @@
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on('South Africa VAT Settings', {
refresh: function(frm) {
frm.set_query("company", function() {
frappe.ui.form.on("South Africa VAT Settings", {
refresh: function (frm) {
frm.set_query("company", function () {
return {
filters: {
country: "South Africa",
}
},
};
});
frm.set_query("account", "vat_accounts", function() {
frm.set_query("account", "vat_accounts", function () {
return {
filters: {
company: frm.doc.company,
account_type: "Tax",
is_group: 0
}
is_group: 0,
},
};
});
}
},
});

View File

@@ -1,14 +1,14 @@
// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on('UAE VAT Settings', {
onload: function(frm) {
frm.set_query('account', 'uae_vat_accounts', function() {
frappe.ui.form.on("UAE VAT Settings", {
onload: function (frm) {
frm.set_query("account", "uae_vat_accounts", function () {
return {
filters: {
'company': frm.doc.company
}
company: frm.doc.company,
},
};
});
}
},
});

View File

@@ -3,51 +3,53 @@
/* eslint-disable */
frappe.query_reports["Electronic Invoice Register"] = {
"filters": [
filters: [
{
"fieldname":"from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
"width": "80"
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
width: "80",
},
{
"fieldname":"to_date",
"label": __("To Date"),
"fieldtype": "Date",
"default": frappe.datetime.get_today()
fieldname: "to_date",
label: __("To Date"),
fieldtype: "Date",
default: frappe.datetime.get_today(),
},
{
"fieldname":"customer",
"label": __("Customer"),
"fieldtype": "Link",
"options": "Customer"
fieldname: "customer",
label: __("Customer"),
fieldtype: "Link",
options: "Customer",
},
{
"fieldname":"company",
"label": __("Company"),
"fieldtype": "Link",
"options": "Company",
"default": frappe.defaults.get_user_default("Company")
fieldname: "company",
label: __("Company"),
fieldtype: "Link",
options: "Company",
default: frappe.defaults.get_user_default("Company"),
},
],
"onload": function(reportview) {
reportview.page.add_inner_button(__("Export E-Invoices"), function() {
onload: function (reportview) {
reportview.page.add_inner_button(__("Export E-Invoices"), function () {
//TODO: refactor condition to disallow export if report has no data.
if (!reportview.data.length) {
frappe.msgprint(__("No data to export"));
return
return;
}
var w = window.open(
frappe.urllib.get_full_url(
"/api/method/erpnext.regional.italy.utils.export_invoices?"
+ "filters=" + JSON.stringify(reportview.get_filter_values())
"/api/method/erpnext.regional.italy.utils.export_invoices?" +
"filters=" +
JSON.stringify(reportview.get_filter_values())
)
);
if (!w) {
frappe.msgprint(__("Please enable pop-ups")); return;
frappe.msgprint(__("Please enable pop-ups"));
return;
}
})
}
}
});
},
};

View File

@@ -2,40 +2,40 @@
// For license information, please see license.txt
frappe.query_reports["Fichier des Ecritures Comptables [FEC]"] = {
"filters": [
filters: [
{
"fieldname": "company",
"label": __("Company"),
"fieldtype": "Link",
"options": "Company",
"default": frappe.defaults.get_user_default("Company"),
"reqd": 1
fieldname: "company",
label: __("Company"),
fieldtype: "Link",
options: "Company",
default: frappe.defaults.get_user_default("Company"),
reqd: 1,
},
{
"fieldname": "fiscal_year",
"label": __("Fiscal Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"reqd": 1
}
fieldname: "fiscal_year",
label: __("Fiscal Year"),
fieldtype: "Link",
options: "Fiscal Year",
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
reqd: 1,
},
],
onload: function(query_report) {
query_report.page.add_inner_button(__("Export"), function() {
onload: function (query_report) {
query_report.page.add_inner_button(__("Export"), function () {
fec_export(query_report);
});
query_report.add_make_chart_button = function() {
query_report.add_make_chart_button = function () {
//
};
query_report.export_report = function() {
query_report.export_report = function () {
fec_export(query_report);
};
}
},
};
let fec_export = function(query_report) {
let fec_export = function (query_report) {
const fiscal_year = query_report.get_values().fiscal_year;
const company = query_report.get_values().company;
@@ -46,38 +46,38 @@ let fec_export = function(query_report) {
} else {
frappe.db.get_value("Fiscal Year", fiscal_year, "year_end_date", (r) => {
const fy = r.year_end_date;
const title = company_data + "FEC" + moment(fy).format('YYYYMMDD');
const column_row = query_report.columns.map(col => col.label);
const title = company_data + "FEC" + moment(fy).format("YYYYMMDD");
const column_row = query_report.columns.map((col) => col.label);
const column_data = query_report.get_data_for_csv(false);
const result = [column_row].concat(column_data);
downloadify(result, null, title);
});
}
});
};
let downloadify = function(data, roles, title) {
let downloadify = function (data, roles, title) {
if (roles && roles.length && !has_common(roles, roles)) {
frappe.msgprint(__("Export not allowed. You need {0} role to export.", [frappe.utils.comma_or(roles)]));
frappe.msgprint(
__("Export not allowed. You need {0} role to export.", [frappe.utils.comma_or(roles)])
);
return;
}
const filename = title + ".txt";
let csv_data = to_tab_csv(data);
const a = document.createElement('a');
const a = document.createElement("a");
if ("download" in a) {
// Used Blob object, because it can handle large files
let blob_object = new Blob([csv_data], {
type: 'text/csv;charset=UTF-8'
type: "text/csv;charset=UTF-8",
});
a.href = URL.createObjectURL(blob_object);
a.download = filename;
} else {
// use old method
a.href = 'data:attachment/csv,' + encodeURIComponent(csv_data);
a.href = "data:attachment/csv," + encodeURIComponent(csv_data);
a.download = filename;
a.target = "_blank";
}
@@ -88,9 +88,9 @@ let downloadify = function(data, roles, title) {
document.body.removeChild(a);
};
let to_tab_csv = function(data) {
let to_tab_csv = function (data) {
let res = [];
$.each(data, function(i, row) {
$.each(data, function (i, row) {
res.push(row.join("\t"));
});
return res.join("\n");

View File

@@ -2,33 +2,33 @@
// License: GNU General Public License v3. See license.txt
frappe.query_reports["IRS 1099"] = {
"filters": [
filters: [
{
"fieldname": "company",
"label": __("Company"),
"fieldtype": "Link",
"options": "Company",
"default": frappe.defaults.get_user_default("Company"),
"reqd": 1,
"width": 80,
fieldname: "company",
label: __("Company"),
fieldtype: "Link",
options: "Company",
default: frappe.defaults.get_user_default("Company"),
reqd: 1,
width: 80,
},
{
"fieldname": "fiscal_year",
"label": __("Fiscal Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
"reqd": 1,
"width": 80,
fieldname: "fiscal_year",
label: __("Fiscal Year"),
fieldtype: "Link",
options: "Fiscal Year",
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
reqd: 1,
width: 80,
},
{
"fieldname": "supplier_group",
"label": __("Supplier Group"),
"fieldtype": "Link",
"options": "Supplier Group",
"default": "",
"reqd": 0,
"width": 80
fieldname: "supplier_group",
label: __("Supplier Group"),
fieldtype: "Link",
options: "Supplier Group",
default: "",
reqd: 0,
width: 80,
},
],
@@ -36,12 +36,15 @@ frappe.query_reports["IRS 1099"] = {
query_report.page.add_inner_button(__("Print IRS 1099 Forms"), () => {
build_1099_print(query_report);
});
}
},
};
function build_1099_print(query_report) {
let filters = JSON.stringify(query_report.get_values());
let w = window.open('/api/method/erpnext.regional.report.irs_1099.irs_1099.irs_1099_print?' +
'&filters=' + encodeURIComponent(filters));
let w = window.open(
"/api/method/erpnext.regional.report.irs_1099.irs_1099.irs_1099_print?" +
"&filters=" +
encodeURIComponent(filters)
);
// w.print();
}

View File

@@ -4,54 +4,56 @@
frappe.query_reports["KSA VAT"] = {
onload() {
frappe.breadcrumbs.add('Accounts');
frappe.breadcrumbs.add("Accounts");
},
"filters": [
filters: [
{
"fieldname": "company",
"label": __("Company"),
"fieldtype": "Link",
"options": "Company",
"reqd": 1,
"default": frappe.defaults.get_user_default("Company")
fieldname: "company",
label: __("Company"),
fieldtype: "Link",
options: "Company",
reqd: 1,
default: frappe.defaults.get_user_default("Company"),
},
{
"fieldname": "from_date",
"label": __("From Date"),
"fieldtype": "Date",
"reqd": 1,
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
reqd: 1,
default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
},
{
"fieldname": "to_date",
"label": __("To Date"),
"fieldtype": "Date",
"reqd": 1,
"default": frappe.datetime.get_today()
}
fieldname: "to_date",
label: __("To Date"),
fieldtype: "Date",
reqd: 1,
default: frappe.datetime.get_today(),
},
],
"formatter": function(value, row, column, data, default_formatter) {
if (data
&& (data.title=='VAT on Sales' || data.title=='VAT on Purchases')
&& data.title==value) {
formatter: function (value, row, column, data, default_formatter) {
if (
data &&
(data.title == "VAT on Sales" || data.title == "VAT on Purchases") &&
data.title == value
) {
value = $(`<span>${value}</span>`);
var $value = $(value).css("font-weight", "bold");
value = $value.wrap("<p></p>").parent().html();
return value
}else if (data.title=='Grand Total'){
if (data.title==value) {
return value;
} else if (data.title == "Grand Total") {
if (data.title == value) {
value = $(`<span>${value}</span>`);
var $value = $(value).css("font-weight", "bold");
value = $value.wrap("<p></p>").parent().html();
return value
}else{
return value;
} else {
value = default_formatter(value, row, column, data);
value = $(`<span>${value}</span>`);
var $value = $(value).css("font-weight", "bold");
value = $value.wrap("<p></p>").parent().html();
return value
return value;
}
}else{
} else {
value = default_formatter(value, row, column, data);
return value;
}

View File

@@ -3,34 +3,37 @@
/* eslint-disable */
frappe.query_reports["UAE VAT 201"] = {
"filters": [
filters: [
{
"fieldname": "company",
"label": __("Company"),
"fieldtype": "Link",
"options": "Company",
"reqd": 1,
"default": frappe.defaults.get_user_default("Company")
fieldname: "company",
label: __("Company"),
fieldtype: "Link",
options: "Company",
reqd: 1,
default: frappe.defaults.get_user_default("Company"),
},
{
"fieldname": "from_date",
"label": __("From Date"),
"fieldtype": "Date",
"reqd": 1,
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -3),
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
reqd: 1,
default: frappe.datetime.add_months(frappe.datetime.get_today(), -3),
},
{
"fieldname": "to_date",
"label": __("To Date"),
"fieldtype": "Date",
"reqd": 1,
"default": frappe.datetime.get_today()
fieldname: "to_date",
label: __("To Date"),
fieldtype: "Date",
reqd: 1,
default: frappe.datetime.get_today(),
},
],
"formatter": function(value, row, column, data, default_formatter) {
if (data
&& (data.legend=='VAT on Sales and All Other Outputs' || data.legend=='VAT on Expenses and All Other Inputs')
&& data.legend==value) {
formatter: function (value, row, column, data, default_formatter) {
if (
data &&
(data.legend == "VAT on Sales and All Other Outputs" ||
data.legend == "VAT on Expenses and All Other Inputs") &&
data.legend == value
) {
value = $(`<span>${value}</span>`);
var $value = $(value).css("font-weight", "bold");
value = $value.wrap("<p></p>").parent().html();

View File

@@ -3,29 +3,29 @@
/* eslint-disable */
frappe.query_reports["VAT Audit Report"] = {
"filters": [
filters: [
{
"fieldname": "company",
"label": __("Company"),
"fieldtype": "Link",
"options": "Company",
"reqd": 1,
"default": frappe.defaults.get_user_default("Company")
fieldname: "company",
label: __("Company"),
fieldtype: "Link",
options: "Company",
reqd: 1,
default: frappe.defaults.get_user_default("Company"),
},
{
"fieldname": "from_date",
"label": __("From Date"),
"fieldtype": "Date",
"reqd": 1,
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -2),
"width": "80"
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
reqd: 1,
default: frappe.datetime.add_months(frappe.datetime.get_today(), -2),
width: "80",
},
{
"fieldname": "to_date",
"label": __("To Date"),
"fieldtype": "Date",
"reqd": 1,
"default": frappe.datetime.get_today()
}
]
fieldname: "to_date",
label: __("To Date"),
fieldtype: "Date",
reqd: 1,
default: frappe.datetime.get_today(),
},
],
};