Added finance book in trial balance and fixed cost center not working issue in trial balance
This commit is contained in:
parent
df7215dcb2
commit
bdee57ca8d
@ -12,21 +12,6 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
|||||||
"default": frappe.defaults.get_user_default("Company"),
|
"default": frappe.defaults.get_user_default("Company"),
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname":"cost_center",
|
|
||||||
"label": __("Cost Center"),
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Cost Center",
|
|
||||||
"get_query": function() {
|
|
||||||
var company = frappe.query_report.get_filter_value('company');
|
|
||||||
return {
|
|
||||||
"doctype": "Cost Center",
|
|
||||||
"filters": {
|
|
||||||
"company": company,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "fiscal_year",
|
"fieldname": "fiscal_year",
|
||||||
"label": __("Fiscal Year"),
|
"label": __("Fiscal Year"),
|
||||||
@ -60,6 +45,27 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
|||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": frappe.defaults.get_user_default("year_end_date"),
|
"default": frappe.defaults.get_user_default("year_end_date"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"cost_center",
|
||||||
|
"label": __("Cost Center"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Cost Center",
|
||||||
|
"get_query": function() {
|
||||||
|
var company = frappe.query_report.get_filter_value('company');
|
||||||
|
return {
|
||||||
|
"doctype": "Cost Center",
|
||||||
|
"filters": {
|
||||||
|
"company": company,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"finance_book",
|
||||||
|
"label": __("Finance Book"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Finance Book",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "with_period_closing_entry",
|
"fieldname": "with_period_closing_entry",
|
||||||
"label": __("Period Closing Entry"),
|
"label": __("Period Closing Entry"),
|
||||||
@ -75,6 +81,11 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
|||||||
"fieldname": "show_unclosed_fy_pl_balances",
|
"fieldname": "show_unclosed_fy_pl_balances",
|
||||||
"label": __("Show unclosed fiscal year's P&L balances"),
|
"label": __("Show unclosed fiscal year's P&L balances"),
|
||||||
"fieldtype": "Check"
|
"fieldtype": "Check"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "include_non_finance_book_entries",
|
||||||
|
"label": __("Include Non Finance Book Entries"),
|
||||||
|
"fieldtype": "Check"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"formatter": erpnext.financial_statements.formatter,
|
"formatter": erpnext.financial_statements.formatter,
|
||||||
|
@ -67,11 +67,10 @@ def get_data(filters):
|
|||||||
|
|
||||||
gl_entries_by_account = {}
|
gl_entries_by_account = {}
|
||||||
|
|
||||||
|
opening_balances = get_opening_balances(filters)
|
||||||
set_gl_entries_by_account(filters.company, filters.from_date,
|
set_gl_entries_by_account(filters.company, filters.from_date,
|
||||||
filters.to_date, min_lft, max_rgt, filters, gl_entries_by_account, ignore_closing_entries=not flt(filters.with_period_closing_entry))
|
filters.to_date, min_lft, max_rgt, filters, gl_entries_by_account, ignore_closing_entries=not flt(filters.with_period_closing_entry))
|
||||||
|
|
||||||
opening_balances = get_opening_balances(filters)
|
|
||||||
|
|
||||||
total_row = calculate_values(accounts, gl_entries_by_account, opening_balances, filters, company_currency)
|
total_row = calculate_values(accounts, gl_entries_by_account, opening_balances, filters, company_currency)
|
||||||
accumulate_values_into_parents(accounts, accounts_by_name)
|
accumulate_values_into_parents(accounts, accounts_by_name)
|
||||||
|
|
||||||
@ -98,6 +97,18 @@ def get_rootwise_opening_balances(filters, report_type):
|
|||||||
if not flt(filters.with_period_closing_entry):
|
if not flt(filters.with_period_closing_entry):
|
||||||
additional_conditions += " and ifnull(voucher_type, '')!='Period Closing Voucher'"
|
additional_conditions += " and ifnull(voucher_type, '')!='Period Closing Voucher'"
|
||||||
|
|
||||||
|
if filters.cost_center:
|
||||||
|
lft, rgt = frappe.db.get_value('Cost Center', filters.cost_center, ['lft', 'rgt'])
|
||||||
|
additional_conditions += """ and cost_center in (select name from `tabCost Center`
|
||||||
|
where lft >= %s and rgt <= %s)""" % (lft, rgt)
|
||||||
|
|
||||||
|
if filters.finance_book:
|
||||||
|
fb_conditions = " and finance_book = %(finance_book)s"
|
||||||
|
if filters.include_non_finance_book_entries:
|
||||||
|
fb_conditions = " and (finance_book = %(finance_book)s or finance_book is null)"
|
||||||
|
|
||||||
|
additional_conditions += fb_conditions
|
||||||
|
|
||||||
gle = frappe.db.sql("""
|
gle = frappe.db.sql("""
|
||||||
select
|
select
|
||||||
account, sum(debit) as opening_debit, sum(credit) as opening_credit
|
account, sum(debit) as opening_debit, sum(credit) as opening_credit
|
||||||
@ -112,7 +123,8 @@ def get_rootwise_opening_balances(filters, report_type):
|
|||||||
"company": filters.company,
|
"company": filters.company,
|
||||||
"from_date": filters.from_date,
|
"from_date": filters.from_date,
|
||||||
"report_type": report_type,
|
"report_type": report_type,
|
||||||
"year_start_date": filters.year_start_date
|
"year_start_date": filters.year_start_date,
|
||||||
|
"finance_book": filters.finance_book
|
||||||
},
|
},
|
||||||
as_dict=True)
|
as_dict=True)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user