mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 08:24:47 +00:00
add presentation currency logic to financial statement reports
This commit is contained in:
@@ -1,15 +1,36 @@
|
|||||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
const get_currencies = () => {
|
||||||
frappe.query_reports["Balance Sheet"] = erpnext.financial_statements;
|
// frappe.db.get_list returns a Promise
|
||||||
|
return frappe.db.get_list('GL Entry',
|
||||||
|
{
|
||||||
|
distinct: true,
|
||||||
|
fields:['account_currency'],
|
||||||
|
as_list: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
frappe.query_reports["Balance Sheet"]["filters"].push({
|
const flatten = (array) => {
|
||||||
"fieldname": "accumulated_values",
|
return [].concat.apply([], array);
|
||||||
"label": __("Accumulated Values"),
|
}
|
||||||
"fieldtype": "Check",
|
|
||||||
"default": 1
|
get_currencies().then(currency_list => flatten(currency_list)).then(currency_list => {
|
||||||
|
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",
|
||||||
|
"default": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "presentation_currency",
|
||||||
|
"label": __("Currency"),
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"options": currency_list
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,36 @@
|
|||||||
// Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
const get_currencies = () => {
|
||||||
frappe.query_reports["Cash Flow"] = $.extend({},
|
// frappe.db.get_list returns a Promise
|
||||||
erpnext.financial_statements);
|
return frappe.db.get_list('GL Entry',
|
||||||
|
{
|
||||||
|
distinct: true,
|
||||||
|
fields:['account_currency'],
|
||||||
|
as_list: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
frappe.query_reports["Cash Flow"]["filters"].push({
|
const flatten = (array) => {
|
||||||
"fieldname": "accumulated_values",
|
return [].concat.apply([], array);
|
||||||
"label": __("Accumulated Values"),
|
}
|
||||||
"fieldtype": "Check"
|
|
||||||
|
get_currencies().then(currency_list => flatten(currency_list)).then(currency_list => {
|
||||||
|
frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
||||||
|
frappe.query_reports["Cash Flow"] = $.extend({},
|
||||||
|
erpnext.financial_statements);
|
||||||
|
|
||||||
|
frappe.query_reports["Cash Flow"]["filters"].push({
|
||||||
|
"fieldname": "accumulated_values",
|
||||||
|
"label": __("Accumulated Values"),
|
||||||
|
"fieldtype": "Check"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "presentation_currency",
|
||||||
|
"label": __("Currency"),
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"options": currency_list
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -51,9 +51,9 @@ def execute(filters=None):
|
|||||||
|
|
||||||
# compute net profit / loss
|
# compute net profit / loss
|
||||||
income = get_data(filters.company, "Income", "Credit", period_list,
|
income = get_data(filters.company, "Income", "Credit", period_list,
|
||||||
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, filters=filters)
|
||||||
expense = get_data(filters.company, "Expense", "Debit", period_list,
|
expense = get_data(filters.company, "Expense", "Debit", period_list,
|
||||||
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, filters=filters)
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from erpnext.accounts.report.general_ledger.general_ledger import convert_to_presentation_currency, get_currency
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import (flt, getdate, get_first_day, get_last_day, date_diff,
|
from frappe.utils import (flt, getdate, get_first_day, get_last_day, date_diff,
|
||||||
add_months, add_days, formatdate, cint)
|
add_months, add_days, formatdate, cint)
|
||||||
@@ -305,7 +307,7 @@ def set_gl_entries_by_account(company, from_date, to_date, root_lft, root_rgt, f
|
|||||||
|
|
||||||
additional_conditions = get_additional_conditions(from_date, ignore_closing_entries, filters)
|
additional_conditions = get_additional_conditions(from_date, ignore_closing_entries, filters)
|
||||||
|
|
||||||
gl_entries = frappe.db.sql("""select posting_date, account, debit, credit, is_opening, fiscal_year from `tabGL Entry`
|
gl_entries = frappe.db.sql("""select posting_date, account, debit, credit, is_opening, fiscal_year, debit_in_account_currency, credit_in_account_currency, account_currency from `tabGL Entry`
|
||||||
where company=%(company)s
|
where company=%(company)s
|
||||||
{additional_conditions}
|
{additional_conditions}
|
||||||
and posting_date <= %(to_date)s
|
and posting_date <= %(to_date)s
|
||||||
@@ -321,6 +323,10 @@ def set_gl_entries_by_account(company, from_date, to_date, root_lft, root_rgt, f
|
|||||||
},
|
},
|
||||||
as_dict=True)
|
as_dict=True)
|
||||||
|
|
||||||
|
if filters and filters.get('presentation_currency'):
|
||||||
|
gl = convert_to_presentation_currency(gl_entries, get_currency(filters))
|
||||||
|
print('presentation currency - ', gl[0:2])
|
||||||
|
|
||||||
for entry in gl_entries:
|
for entry in gl_entries:
|
||||||
gl_entries_by_account.setdefault(entry.account, []).append(entry)
|
gl_entries_by_account.setdefault(entry.account, []).append(entry)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
const get_currencies = () => {
|
const get_currencies = () => {
|
||||||
@@ -16,9 +16,7 @@ const flatten = (array) => {
|
|||||||
return [].concat.apply([], array);
|
return [].concat.apply([], array);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_currencies()
|
const show_report = (currency_list) => {
|
||||||
.then((r) => flatten(r))
|
|
||||||
.then((currency_list) => {
|
|
||||||
frappe.query_reports["General Ledger"] = {
|
frappe.query_reports["General Ledger"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
@@ -132,4 +130,8 @@ get_currencies()
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
get_currencies()
|
||||||
|
.then((currency_list) => flatten(currency_list))
|
||||||
|
.then((currency_list) => show_report(currency_list));
|
||||||
@@ -153,7 +153,7 @@ def get_currency(filters):
|
|||||||
company = get_appropriate_company(filters)
|
company = get_appropriate_company(filters)
|
||||||
company_currency = get_company_currency(company)
|
company_currency = get_company_currency(company)
|
||||||
presentation_currency = filters['presentation_currency'] if filters.get('presentation_currency') else company_currency
|
presentation_currency = filters['presentation_currency'] if filters.get('presentation_currency') else company_currency
|
||||||
report_date = filters['to_date']
|
report_date = filters.get('to_date') or filters.get('to_fiscal_year')
|
||||||
|
|
||||||
currency_map = dict(company=company, company_currency=company_currency, presentation_currency=presentation_currency, report_date=report_date)
|
currency_map = dict(company=company, company_currency=company_currency, presentation_currency=presentation_currency, report_date=report_date)
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,50 @@
|
|||||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
const get_currencies = () => {
|
||||||
frappe.query_reports["Profit and Loss Statement"] = $.extend({},
|
// frappe.db.get_list returns a Promise
|
||||||
erpnext.financial_statements);
|
return frappe.db.get_list('GL Entry',
|
||||||
|
|
||||||
frappe.query_reports["Profit and Loss Statement"]["filters"].push(
|
|
||||||
{
|
{
|
||||||
"fieldname":"cost_center",
|
distinct: true,
|
||||||
"label": __("Cost Center"),
|
fields:['account_currency'],
|
||||||
"fieldtype": "Link",
|
as_list: true
|
||||||
"options": "Cost Center"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname":"project",
|
|
||||||
"label": __("Project"),
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Project"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "accumulated_values",
|
|
||||||
"label": __("Accumulated Values"),
|
|
||||||
"fieldtype": "Check"
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
const flatten = (array) => {
|
||||||
|
return [].concat.apply([], array);
|
||||||
|
}
|
||||||
|
|
||||||
|
get_currencies().then(currency_list => flatten(currency_list)).then(currency_list => {
|
||||||
|
frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
||||||
|
frappe.query_reports["Profit and Loss Statement"] = $.extend({},
|
||||||
|
erpnext.financial_statements);
|
||||||
|
|
||||||
|
frappe.query_reports["Profit and Loss Statement"]["filters"].push(
|
||||||
|
{
|
||||||
|
"fieldname":"cost_center",
|
||||||
|
"label": __("Cost Center"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Cost Center"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"project",
|
||||||
|
"label": __("Project"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Project"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "accumulated_values",
|
||||||
|
"label": __("Accumulated Values"),
|
||||||
|
"fieldtype": "Check"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "presentation_currency",
|
||||||
|
"label": __("Currency"),
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"options": currency_list
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user