Merge branch 'accumulated_header_std' of https://github.com/RicardoJohann/erpnext into RicardoJohann-accumulated_header_std
This commit is contained in:
commit
39bcb3de4b
@ -3,6 +3,12 @@
|
||||
|
||||
frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
||||
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,14 @@ from frappe.utils import flt, cint
|
||||
from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data)
|
||||
|
||||
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)
|
||||
|
||||
asset = get_data(filters.company, "Asset", "Debit", period_list, only_current_fiscal_year=False)
|
||||
liability = get_data(filters.company, "Liability", "Credit", period_list, only_current_fiscal_year=False)
|
||||
equity = get_data(filters.company, "Equity", "Credit", period_list, only_current_fiscal_year=False)
|
||||
asset = get_data(filters.company, "Asset", "Debit", period_list, only_current_fiscal_year=False, filters=filters,
|
||||
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,
|
||||
period_list, filters.company)
|
||||
@ -43,9 +46,9 @@ def execute(filters=None):
|
||||
if 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
|
||||
|
||||
@ -107,7 +110,7 @@ def check_opening_balance(asset, liability, equity):
|
||||
return _("Previous Financial Year is not closed"),opening_balance
|
||||
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:]]
|
||||
|
||||
asset_data, liability_data, equity_data = [], [], []
|
||||
@ -128,9 +131,14 @@ def get_chart_data(columns, asset, liability, equity):
|
||||
if equity_data:
|
||||
columns.append(["Equity"] + equity_data)
|
||||
|
||||
return {
|
||||
chart = {
|
||||
"data": {
|
||||
'x': 'x',
|
||||
'columns': columns
|
||||
}
|
||||
}
|
||||
|
||||
if not filters.accumulated_values:
|
||||
chart["chart_type"] = "bar"
|
||||
|
||||
return chart
|
@ -10,8 +10,7 @@ from erpnext.accounts.utils import get_fiscal_year
|
||||
|
||||
|
||||
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)
|
||||
|
||||
operation_accounts = {
|
||||
"section_name": "Operations",
|
||||
@ -104,7 +103,7 @@ def get_account_type_based_data(company, account_type, period_list, accumulated_
|
||||
data = {}
|
||||
total = 0
|
||||
for period in period_list:
|
||||
start_date = get_start_date(period, accumulated_values, company)
|
||||
start_date = get_start_date(period, accumulated_values)
|
||||
gl_sum = frappe.db.sql_list("""
|
||||
select sum(credit) - sum(debit)
|
||||
from `tabGL Entry`
|
||||
|
@ -4,9 +4,10 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
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}
|
||||
Periodicity can be (Yearly, Quarterly, Monthly)"""
|
||||
|
||||
@ -58,10 +59,13 @@ def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, company):
|
||||
# common processing
|
||||
for opts in period_list:
|
||||
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")
|
||||
else:
|
||||
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({
|
||||
"key": key.replace(" ", "_").replace("-", "_"),
|
||||
|
@ -9,7 +9,7 @@ from erpnext.accounts.report.financial_statements import (get_period_list, get_c
|
||||
|
||||
def execute(filters=None):
|
||||
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,
|
||||
accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= True)
|
||||
|
Loading…
Reference in New Issue
Block a user