fixed accumulated values for cash flow
diff --git a/erpnext/accounts/report/cash_flow/cash_flow.py b/erpnext/accounts/report/cash_flow/cash_flow.py
index 73b5c4b..24c5cd2 100644
--- a/erpnext/accounts/report/cash_flow/cash_flow.py
+++ b/erpnext/accounts/report/cash_flow/cash_flow.py
@@ -6,6 +6,7 @@
from frappe import _
from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data)
from erpnext.accounts.report.profit_and_loss_statement.profit_and_loss_statement import get_net_profit_loss
+from erpnext.accounts.utils import get_fiscal_year
def execute(filters=None):
@@ -49,9 +50,9 @@
# compute net profit / loss
income = get_data(filters.company, "Income", "Credit", period_list,
- accumulated_values=filters.accumulated_values, ignore_closing_entries=True)
+ accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= True)
expense = get_data(filters.company, "Expense", "Debit", period_list,
- accumulated_values=filters.accumulated_values, ignore_closing_entries=True)
+ accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= True)
net_profit_loss = get_net_profit_loss(income, expense, period_list, filters.company)
@@ -98,33 +99,39 @@
return columns, data
-
def get_account_type_based_data(company, account_type, period_list, accumulated_values):
data = {}
total = 0
for period in period_list:
+ start_date = get_start_date(period, accumulated_values)
gl_sum = frappe.db.sql_list("""
select sum(credit) - sum(debit)
from `tabGL Entry`
where company=%s and posting_date >= %s and posting_date <= %s
and voucher_type != 'Period Closing Voucher'
and account in ( SELECT name FROM tabAccount WHERE account_type = %s)
- """, (company, period["year_start_date"] if accumulated_values else period['from_date'],
+ """, (company, start_date if accumulated_values else period['from_date'],
period['to_date'], account_type))
-
+
if gl_sum and gl_sum[0]:
amount = gl_sum[0]
if account_type == "Depreciation":
amount *= -1
else:
amount = 0
-
+
total += amount
data.setdefault(period["key"], amount)
-
+
data["total"] = total
return data
+def get_start_date(period, accumulated_values):
+ start_date = period["year_start_date"]
+ if accumulated_values:
+ start_date = get_fiscal_year(period.to_date)[1]
+
+ return start_date
def add_total_row_account(out, data, label, period_list, currency):
total_row = {
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index fb82213..f6968a1 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -16,13 +16,13 @@
to_fy_start_end_date = frappe.db.get_value("Fiscal Year", to_fiscal_year, ["year_start_date", "year_end_date"])
if not from_fy_start_end_date:
- frappe.throw(_("Fiscal Year {0} not found.").format(from_fiscal_year))
+ frappe.throw(_("Start Year {0} not found.").format(from_fiscal_year))
if not to_fy_start_end_date:
- frappe.throw(_("Fiscal Year {0} not found.").format(to_fiscal_year))
+ frappe.throw(_("End Year {0} not found.").format(to_fiscal_year))
# start with first day, so as to avoid year to_dates like 2-April if ever they occur]
- year_start_date = get_first_day(getdate(from_fy_start_end_date[0]))
+ year_start_date = getdate(from_fy_start_end_date[0])
year_end_date = getdate(to_fy_start_end_date[1])
validate_fiscal_year(year_start_date, year_end_date)
diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
index e15336b..3629d4d 100644
--- a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
+++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
@@ -54,7 +54,7 @@
return net_profit_loss
def get_chart_data(filters, columns, income, expense, net_profit_loss):
- x_intervals = ['x'] + [d.get("label") for d in columns[2:-1]]
+ x_intervals = ['x'] + [d.get("label") for d in columns[2:]]
income_data, expense_data, net_profit = [], [], []