brotherton-erpnext/erpnext/accounts/report/financial_ratios/financial_ratios.js
RitvikSardana b86afb2964
feat: Financial Ratio Report (#36130)
* feat: Financial Ratio report added

* fix: Made columns dynamic

* fix: Changed fieldtype of year column

* fix: Added Financial Ratios for all Fiscal Years

* fix: Added Validation of only Parent Having account_type of Direct Income, Indirect Income, Current Asset and Current Liability

* fix: Added 4 more ratios

* fix: added a function for repeated code

* fix: added account_type in accounts utils and cleaned report code

* fix: created function for avg_ratio_values

* fix: cleaning code

* fix: basic ratios completed

* fix: cleaned the code

* chore: code cleanup

* chore: remove comments

* chore: code cleanup

* chore: cleanup account query

* chore: Remove unused variables

---------

Co-authored-by: Ritvik Sardana <ritviksardana@Ritviks-MacBook-Air.local>
Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
2023-08-04 22:05:30 +05:30

73 lines
1.8 KiB
JavaScript

// Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
/* eslint-disable */
frappe.query_reports["Financial Ratios"] = {
filters: [
{
fieldname: "company",
label: __("Company"),
fieldtype: "Link",
options: "Company",
default: frappe.defaults.get_user_default("Company"),
reqd: 1,
},
{
fieldname: "from_fiscal_year",
label: __("Start Year"),
fieldtype: "Link",
options: "Fiscal Year",
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
reqd: 1,
},
{
fieldname: "to_fiscal_year",
label: __("End Year"),
fieldtype: "Link",
options: "Fiscal Year",
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
reqd: 1,
},
{
fieldname: "periodicity",
label: __("Periodicity"),
fieldtype: "Data",
default: "Yearly",
reqd: 1,
hidden: 1,
},
{
fieldname: "period_start_date",
label: __("From Date"),
fieldtype: "Date",
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
hidden: 1,
},
{
fieldname: "period_end_date",
label: __("To Date"),
fieldtype: "Date",
default: erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
hidden: 1,
},
],
"formatter": function(value, row, column, data, default_formatter) {
let heading_ratios = ["Liquidity Ratios", "Solvency Ratios","Turnover Ratios"]
if (heading_ratios.includes(value)) {
value = $(`<span>${value}</span>`);
let $value = $(value).css("font-weight", "bold");
value = $value.wrap("<p></p>").parent().html();
}
if (heading_ratios.includes(row[1].content) && column.fieldtype == "Float") {
column.fieldtype = "Data";
}
value = default_formatter(value, row, column, data);
return value;
},
};