Merge branch 'RicardoJohann-accumulated_header_std' into develop
This commit is contained in:
commit
7cfacb315b
@ -3,6 +3,12 @@
|
|||||||
|
|
||||||
frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
||||||
frappe.query_reports["Balance Sheet"] = erpnext.financial_statements;
|
frappe.query_reports["Balance Sheet"] = erpnext.financial_statements;
|
||||||
|
|
||||||
|
frappe.query_reports["Balance Sheet"]["filters"].push({
|
||||||
|
"fieldname": "accumulated_values",
|
||||||
|
"label": __("Accumulated Values"),
|
||||||
|
"fieldtype": "Check"
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,11 +8,23 @@ from frappe.utils import flt, cint
|
|||||||
from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data)
|
from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data)
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, filters.company)
|
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
|
||||||
|
filters.periodicity, filters.accumulated_values, filters.company)
|
||||||
|
|
||||||
asset = get_data(filters.company, "Asset", "Debit", period_list, only_current_fiscal_year=False)
|
asset = get_data(filters.company, "Asset", "Debit", period_list,
|
||||||
liability = get_data(filters.company, "Liability", "Credit", period_list, only_current_fiscal_year=False)
|
only_current_fiscal_year=False, filters=filters,
|
||||||
equity = get_data(filters.company, "Equity", "Credit", period_list, only_current_fiscal_year=False)
|
accumulated_values=filters.accumulated_values,
|
||||||
|
ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
|
||||||
|
|
||||||
|
liability = get_data(filters.company, "Liability", "Credit", period_list,
|
||||||
|
only_current_fiscal_year=False, filters=filters,
|
||||||
|
accumulated_values=filters.accumulated_values,
|
||||||
|
ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
|
||||||
|
|
||||||
|
equity = get_data(filters.company, "Equity", "Credit", period_list,
|
||||||
|
only_current_fiscal_year=False, filters=filters,
|
||||||
|
accumulated_values=filters.accumulated_values,
|
||||||
|
ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
|
||||||
|
|
||||||
provisional_profit_loss, total_credit = get_provisional_profit_loss(asset, liability, equity,
|
provisional_profit_loss, total_credit = get_provisional_profit_loss(asset, liability, equity,
|
||||||
period_list, filters.company)
|
period_list, filters.company)
|
||||||
@ -43,9 +55,9 @@ def execute(filters=None):
|
|||||||
if total_credit:
|
if total_credit:
|
||||||
data.append(total_credit)
|
data.append(total_credit)
|
||||||
|
|
||||||
columns = get_columns(filters.periodicity, period_list, company=filters.company)
|
columns = get_columns(filters.periodicity, period_list, filters.accumulated_values, company=filters.company)
|
||||||
|
|
||||||
chart = get_chart_data(columns, asset, liability, equity)
|
chart = get_chart_data(filters, columns, asset, liability, equity)
|
||||||
|
|
||||||
return columns, data, message, chart
|
return columns, data, message, chart
|
||||||
|
|
||||||
@ -107,7 +119,7 @@ def check_opening_balance(asset, liability, equity):
|
|||||||
return _("Previous Financial Year is not closed"),opening_balance
|
return _("Previous Financial Year is not closed"),opening_balance
|
||||||
return None,None
|
return None,None
|
||||||
|
|
||||||
def get_chart_data(columns, asset, liability, equity):
|
def get_chart_data(filters, columns, asset, liability, equity):
|
||||||
x_intervals = ['x'] + [d.get("label") for d in columns[2:]]
|
x_intervals = ['x'] + [d.get("label") for d in columns[2:]]
|
||||||
|
|
||||||
asset_data, liability_data, equity_data = [], [], []
|
asset_data, liability_data, equity_data = [], [], []
|
||||||
@ -128,9 +140,14 @@ def get_chart_data(columns, asset, liability, equity):
|
|||||||
if equity_data:
|
if equity_data:
|
||||||
columns.append(["Equity"] + equity_data)
|
columns.append(["Equity"] + equity_data)
|
||||||
|
|
||||||
return {
|
chart = {
|
||||||
"data": {
|
"data": {
|
||||||
'x': 'x',
|
'x': 'x',
|
||||||
'columns': columns
|
'columns': columns
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if not filters.accumulated_values:
|
||||||
|
chart["chart_type"] = "bar"
|
||||||
|
|
||||||
|
return chart
|
@ -11,7 +11,7 @@ from erpnext.accounts.utils import get_fiscal_year
|
|||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
|
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
|
||||||
filters.periodicity, filters.company)
|
filters.periodicity, filters.accumulated_values, filters.company)
|
||||||
|
|
||||||
operation_accounts = {
|
operation_accounts = {
|
||||||
"section_name": "Operations",
|
"section_name": "Operations",
|
||||||
|
@ -4,9 +4,10 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import flt, getdate, get_first_day, add_months, add_days, formatdate
|
from frappe.utils import (flt, getdate, get_first_day, get_last_day, date_diff,
|
||||||
|
add_months, add_days, formatdate, cint)
|
||||||
|
|
||||||
def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, company):
|
def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_values=False, company=None):
|
||||||
"""Get a list of dict {"from_date": from_date, "to_date": to_date, "key": key, "label": label}
|
"""Get a list of dict {"from_date": from_date, "to_date": to_date, "key": key, "label": label}
|
||||||
Periodicity can be (Yearly, Quarterly, Monthly)"""
|
Periodicity can be (Yearly, Quarterly, Monthly)"""
|
||||||
|
|
||||||
@ -58,11 +59,14 @@ def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, company):
|
|||||||
# common processing
|
# common processing
|
||||||
for opts in period_list:
|
for opts in period_list:
|
||||||
key = opts["to_date"].strftime("%b_%Y").lower()
|
key = opts["to_date"].strftime("%b_%Y").lower()
|
||||||
if periodicity == "Monthly":
|
if periodicity == "Monthly" and not accumulated_values:
|
||||||
label = formatdate(opts["to_date"], "MMM YYYY")
|
label = formatdate(opts["to_date"], "MMM YYYY")
|
||||||
else:
|
else:
|
||||||
label = get_label(periodicity, opts["from_date"], opts["to_date"])
|
if not accumulated_values:
|
||||||
|
label = get_label(periodicity, opts["from_date"], opts["to_date"])
|
||||||
|
else:
|
||||||
|
label = get_label(periodicity, period_list[0]["from_date"], opts["to_date"])
|
||||||
|
|
||||||
opts.update({
|
opts.update({
|
||||||
"key": key.replace(" ", "_").replace("-", "_"),
|
"key": key.replace(" ", "_").replace("-", "_"),
|
||||||
"label": label,
|
"label": label,
|
||||||
@ -139,7 +143,8 @@ def calculate_values(accounts_by_name, gl_entries_by_account, period_list, accum
|
|||||||
|
|
||||||
if entry.posting_date <= period.to_date:
|
if entry.posting_date <= period.to_date:
|
||||||
if (accumulated_values or entry.posting_date >= period.from_date) and \
|
if (accumulated_values or entry.posting_date >= period.from_date) and \
|
||||||
(not ignore_accumulated_values_for_fy or entry.fiscal_year == period.to_date_fiscal_year):
|
(not ignore_accumulated_values_for_fy or
|
||||||
|
entry.fiscal_year == period.to_date_fiscal_year):
|
||||||
d[period.key] = d.get(period.key, 0.0) + flt(entry.debit) - flt(entry.credit)
|
d[period.key] = d.get(period.key, 0.0) + flt(entry.debit) - flt(entry.credit)
|
||||||
|
|
||||||
if entry.posting_date < period_list[0].year_start_date:
|
if entry.posting_date < period_list[0].year_start_date:
|
||||||
|
@ -9,12 +9,15 @@ from erpnext.accounts.report.financial_statements import (get_period_list, get_c
|
|||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
|
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
|
||||||
filters.periodicity, filters.company)
|
filters.periodicity, filters.accumulated_values, filters.company)
|
||||||
|
|
||||||
income = get_data(filters.company, "Income", "Credit", period_list, filters = filters,
|
income = get_data(filters.company, "Income", "Credit", period_list, filters = filters,
|
||||||
accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= 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, filters=filters,
|
expense = get_data(filters.company, "Expense", "Debit", period_list, filters=filters,
|
||||||
accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= 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)
|
net_profit_loss = get_net_profit_loss(income, expense, period_list, filters.company)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user