fix: Default year start and end dates in reports

This commit is contained in:
Deepesh Garg 2023-07-24 11:58:16 +05:30
parent 781e57f5bf
commit 3c92686f0a
31 changed files with 53 additions and 50 deletions

View File

@ -79,8 +79,8 @@ frappe.ui.form.on('Account', {
frm.add_custom_button(__('General Ledger'), function () {
frappe.route_options = {
"account": frm.doc.name,
"from_date": frappe.sys_defaults.year_start_date,
"to_date": frappe.sys_defaults.year_end_date,
"from_date": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
"to_date": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
"company": frm.doc.company
};
frappe.set_route("query-report", "General Ledger");

View File

@ -194,8 +194,8 @@ frappe.treeview_settings["Account"] = {
click: function(node, btn) {
frappe.route_options = {
"account": node.label,
"from_date": frappe.sys_defaults.year_start_date,
"to_date": frappe.sys_defaults.year_end_date,
"from_date": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
"to_date": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
"company": frappe.treeview_settings['Account'].treeview.page.fields_dict.company.get_value()
};
frappe.set_route("query-report", "General Ledger");

View File

@ -15,14 +15,14 @@ frappe.query_reports["Asset Depreciations and Balances"] = {
"fieldname":"from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_start_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
"reqd": 1
},
{
"fieldname":"to_date",
"label": __("To Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_end_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
"reqd": 1
},
{

View File

@ -7,7 +7,7 @@ frappe.query_reports["Bank Clearance Summary"] = {
"fieldname":"from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_start_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
"width": "80"
},
{

View File

@ -8,7 +8,7 @@ frappe.query_reports["Budget Variance Report"] = {
label: __("From Fiscal Year"),
fieldtype: "Link",
options: "Fiscal Year",
default: frappe.sys_defaults.fiscal_year,
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
reqd: 1
},
{
@ -16,7 +16,7 @@ frappe.query_reports["Budget Variance Report"] = {
label: __("To Fiscal Year"),
fieldtype: "Link",
options: "Fiscal Year",
default: frappe.sys_defaults.fiscal_year,
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
reqd: 1
},
{

View File

@ -38,14 +38,14 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
"fieldname": "from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_start_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
"reqd": 1
},
{
"fieldname": "to_date",
"label": __("To Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_end_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
"reqd": 1
},
{

View File

@ -15,14 +15,14 @@ frappe.query_reports["Gross Profit"] = {
"fieldname": "from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_start_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
"reqd": 1
},
{
"fieldname": "to_date",
"label": __("To Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_end_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
"reqd": 1
},
{

View File

@ -15,7 +15,7 @@ frappe.query_reports["Payment Period Based On Invoice Date"] = {
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_start_date"),
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
},
{
fieldname:"to_date",

View File

@ -45,13 +45,13 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
"fieldname": "from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_start_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
},
{
"fieldname": "to_date",
"label": __("To Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_end_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
},
{
"fieldname": "show_zero_values",

View File

@ -37,13 +37,13 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
"fieldname": "from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_start_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
},
{
"fieldname": "to_date",
"label": __("To Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_end_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
},
{
"fieldname": "cost_center",

View File

@ -36,13 +36,13 @@ frappe.query_reports["Trial Balance for Party"] = {
"fieldname": "from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_start_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
},
{
"fieldname": "to_date",
"label": __("To Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_end_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
},
{
"fieldname":"party_type",

View File

@ -27,13 +27,13 @@ frappe.query_reports["Procurement Tracker"] = {
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_start_date"),
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
},
{
fieldname:"to_date",
label: __("To Date"),
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_end_date"),
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
},
]
}

View File

@ -35,14 +35,14 @@ frappe.query_reports["Purchase Analytics"] = {
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_start_date"),
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
reqd: 1
},
{
fieldname:"to_date",
label: __("To Date"),
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_end_date"),
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
reqd: 1
},
{

View File

@ -6,13 +6,13 @@ frappe.query_reports["Campaign Efficiency"] = {
"fieldname": "from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_start_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
},
{
"fieldname": "to_date",
"label": __("To Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_end_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
}
]
};

View File

@ -6,12 +6,12 @@
"fieldname": "from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_start_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
},
{
"fieldname": "to_date",
"label": __("To Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_end_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
}
]};

View File

@ -37,14 +37,14 @@ frappe.query_reports["Job Card Summary"] = {
label: __("From Posting Date"),
fieldname:"from_date",
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_start_date"),
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
reqd: 1
},
{
label: __("To Posting Date"),
fieldname:"to_date",
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_end_date"),
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
reqd: 1,
},
{

View File

@ -16,14 +16,14 @@ frappe.query_reports["Production Analytics"] = {
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_start_date"),
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
reqd: 1
},
{
fieldname:"to_date",
label: __("To Date"),
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_end_date"),
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
reqd: 1
},
{

View File

@ -28,7 +28,7 @@ erpnext.get_purchase_trends_filters = function() {
"label": __("Fiscal Year"),
"fieldtype": "Link",
"options":'Fiscal Year',
"default": frappe.sys_defaults.fiscal_year
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today())
},
{
"fieldname":"period_based_on",

View File

@ -48,7 +48,7 @@ erpnext.get_sales_trends_filters = function() {
"label": __("Fiscal Year"),
"fieldtype": "Link",
"options":'Fiscal Year',
"default": frappe.sys_defaults.fiscal_year
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
},
{
"fieldname":"company",

View File

@ -400,7 +400,7 @@ $.extend(erpnext.utils, {
});
},
get_fiscal_year: function(date) {
get_fiscal_year: function(date, with_dates) {
if(!date) {
date = frappe.datetime.get_today();
}
@ -414,7 +414,10 @@ $.extend(erpnext.utils, {
async: false,
callback: function(r) {
if (r.message) {
fiscal_year = r.message[0];
if (with_dates)
fiscal_year = r.message;
else
fiscal_year = r.message[0];
}
}
});

View File

@ -23,14 +23,14 @@ frappe.query_reports["Customer Acquisition and Loyalty"] = {
"fieldname":"from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_start_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
"reqd": 1
},
{
"fieldname":"to_date",
"label": __("To Date"),
"fieldtype": "Date",
"default": frappe.defaults.get_user_default("year_end_date"),
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
"reqd": 1
}
],

View File

@ -35,14 +35,14 @@ frappe.query_reports["Sales Analytics"] = {
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_start_date"),
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
reqd: 1
},
{
fieldname:"to_date",
label: __("To Date"),
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_end_date"),
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
reqd: 1
},
{

View File

@ -16,7 +16,7 @@ frappe.query_reports["Sales Partner Target Variance based on Item Group"] = {
label: __("Fiscal Year"),
fieldtype: "Link",
options: "Fiscal Year",
default: frappe.sys_defaults.fiscal_year
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today())
},
{
fieldname: "doctype",

View File

@ -22,7 +22,7 @@ frappe.query_reports["Sales Person Commission Summary"] = {
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_start_date"),
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
},
{
fieldname:"to_date",

View File

@ -16,7 +16,7 @@ frappe.query_reports["Sales Person Target Variance Based On Item Group"] = {
label: __("Fiscal Year"),
fieldtype: "Link",
options: "Fiscal Year",
default: frappe.sys_defaults.fiscal_year
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
},
{
fieldname: "doctype",

View File

@ -20,7 +20,7 @@ frappe.query_reports["Sales Person-wise Transaction Summary"] = {
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
default: frappe.defaults.get_user_default("year_start_date"),
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
},
{
fieldname:"to_date",

View File

@ -16,7 +16,7 @@ frappe.query_reports["Territory Target Variance Based On Item Group"] = {
label: __("Fiscal Year"),
fieldtype: "Link",
options: "Fiscal Year",
default: frappe.sys_defaults.fiscal_year
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today())
},
{
fieldname: "doctype",

View File

@ -8,7 +8,7 @@ frappe.query_reports["Batch Item Expiry Status"] = {
"label": __("From Date"),
"fieldtype": "Date",
"width": "80",
"default": frappe.sys_defaults.year_start_date,
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
"reqd": 1,
},
{

View File

@ -16,7 +16,7 @@ frappe.query_reports["Batch-Wise Balance History"] = {
"label": __("From Date"),
"fieldtype": "Date",
"width": "80",
"default": frappe.sys_defaults.year_start_date,
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
"reqd": 1
},
{

View File

@ -22,14 +22,14 @@ frappe.query_reports["Incorrect Serial No Valuation"] = {
fieldtype: 'Date',
fieldname: 'from_date',
reqd: 1,
default: frappe.defaults.get_user_default("year_start_date")
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
},
{
label: __('To Date'),
fieldtype: 'Date',
fieldname: 'to_date',
reqd: 1,
default: frappe.defaults.get_user_default("year_end_date")
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[2],
}
]
};

View File

@ -7,7 +7,7 @@ frappe.query_reports["Itemwise Recommended Reorder Level"] = {
"fieldname":"from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.sys_defaults.year_start_date
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), with_dates=true)[1],
},
{
"fieldname":"to_date",