mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-05 05:09:11 +00:00
Merge pull request #54479 from Abdeali099/cash-flow-fixes
This commit is contained in:
@@ -226,14 +226,38 @@ class FinancialReportEngine:
|
|||||||
return context.get_result()
|
return context.get_result()
|
||||||
|
|
||||||
def _validate_filters(self, filters: dict[str, Any]) -> None:
|
def _validate_filters(self, filters: dict[str, Any]) -> None:
|
||||||
required_filters = ["report_template", "period_start_date", "period_end_date"]
|
filter_labels = {
|
||||||
|
"report_template": _("Report Template"),
|
||||||
|
"filter_based_on": _("Filter Based On"),
|
||||||
|
"period_start_date": _("Start Date"),
|
||||||
|
"period_end_date": _("End Date"),
|
||||||
|
"from_fiscal_year": _("Start Year"),
|
||||||
|
"to_fiscal_year": _("End Year"),
|
||||||
|
}
|
||||||
|
|
||||||
|
required_filters_by_basis = {
|
||||||
|
"Date Range": ("period_start_date", "period_end_date"),
|
||||||
|
"Fiscal Year": ("from_fiscal_year", "to_fiscal_year"),
|
||||||
|
}
|
||||||
|
|
||||||
|
required_filters = ["report_template", "filter_based_on"]
|
||||||
|
required_filters.extend(required_filters_by_basis.get(filters.get("filter_based_on"), ()))
|
||||||
|
|
||||||
for filter_key in required_filters:
|
for filter_key in required_filters:
|
||||||
if not filters.get(filter_key):
|
if not filters.get(filter_key):
|
||||||
frappe.throw(_("Missing required filter: {0}").format(filter_key))
|
frappe.throw(
|
||||||
|
title=_("Missing Required Filter"),
|
||||||
|
msg=_("Missing required filter: {0}").format(
|
||||||
|
frappe.bold(filter_labels.get(filter_key, filter_key))
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
if filters.get("presentation_currency"):
|
if filters.get("presentation_currency"):
|
||||||
frappe.msgprint(_("Currency filters are currently unsupported in Custom Financial Report."))
|
frappe.msgprint(
|
||||||
|
title=_("Unsupported Feature"),
|
||||||
|
msg=_("Currency filters are currently unsupported in Custom Financial Report."),
|
||||||
|
indicator="orange",
|
||||||
|
)
|
||||||
|
|
||||||
# Margin view is dependent on first row being an income account. Hence not supported.
|
# Margin view is dependent on first row being an income account. Hence not supported.
|
||||||
# Way to implement this would be using calculated rows with formulas.
|
# Way to implement this would be using calculated rows with formulas.
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ erpnext.financial_statements = {
|
|||||||
const isPeriodColumn = periodKeys.includes(baseName);
|
const isPeriodColumn = periodKeys.includes(baseName);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isAccount: baseName === erpnext.financial_statements.name_field,
|
isAccount: baseName === "account", // DO NOT USE `name_field` ! This can be overridden in some reports!
|
||||||
isPeriod: isPeriodColumn,
|
isPeriod: isPeriodColumn,
|
||||||
segmentIndex: valueMatch && valueMatch[1] ? parseInt(valueMatch[1]) : null,
|
segmentIndex: valueMatch && valueMatch[1] ? parseInt(valueMatch[1]) : null,
|
||||||
fieldname: baseName,
|
fieldname: baseName,
|
||||||
@@ -298,7 +298,7 @@ erpnext.financial_statements = {
|
|||||||
let fiscal_year = erpnext.utils.get_fiscal_year(frappe.datetime.get_today());
|
let fiscal_year = erpnext.utils.get_fiscal_year(frappe.datetime.get_today());
|
||||||
var filters = report.get_values();
|
var filters = report.get_values();
|
||||||
|
|
||||||
if (!filters.period_start_date || !filters.period_end_date) {
|
if (fiscal_year && (!filters.period_start_date || !filters.period_end_date)) {
|
||||||
frappe.model.with_doc("Fiscal Year", fiscal_year, function (r) {
|
frappe.model.with_doc("Fiscal Year", fiscal_year, function (r) {
|
||||||
var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
|
var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
|
||||||
frappe.query_report.set_filter_value({
|
frappe.query_report.set_filter_value({
|
||||||
@@ -422,16 +422,16 @@ function get_filters() {
|
|||||||
label: __("Start Year"),
|
label: __("Start Year"),
|
||||||
fieldtype: "Link",
|
fieldtype: "Link",
|
||||||
options: "Fiscal Year",
|
options: "Fiscal Year",
|
||||||
reqd: 1,
|
|
||||||
depends_on: "eval:doc.filter_based_on == 'Fiscal Year'",
|
depends_on: "eval:doc.filter_based_on == 'Fiscal Year'",
|
||||||
|
mandatory_depends_on: "eval:doc.filter_based_on == 'Fiscal Year'",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "to_fiscal_year",
|
fieldname: "to_fiscal_year",
|
||||||
label: __("End Year"),
|
label: __("End Year"),
|
||||||
fieldtype: "Link",
|
fieldtype: "Link",
|
||||||
options: "Fiscal Year",
|
options: "Fiscal Year",
|
||||||
reqd: 1,
|
|
||||||
depends_on: "eval:doc.filter_based_on == 'Fiscal Year'",
|
depends_on: "eval:doc.filter_based_on == 'Fiscal Year'",
|
||||||
|
mandatory_depends_on: "eval:doc.filter_based_on == 'Fiscal Year'",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "periodicity",
|
fieldname: "periodicity",
|
||||||
|
|||||||
Reference in New Issue
Block a user