[Minor] Report related fixes (#14620)
* fix in query incase list is empty
* periodicity not found error
when called from consolidated financial statements and custom cash flow is activated
* unset currency filter to apply default currency or so
* python 2 - 3 fix
diff --git a/erpnext/accounts/report/cash_flow/custom_cash_flow.py b/erpnext/accounts/report/cash_flow/custom_cash_flow.py
index 160b200..ee0f38c 100644
--- a/erpnext/accounts/report/cash_flow/custom_cash_flow.py
+++ b/erpnext/accounts/report/cash_flow/custom_cash_flow.py
@@ -25,15 +25,14 @@
def get_accounts_in_mappers(mapping_names):
- return frappe.db.sql(
- 'select cfma.name, cfm.label, cfm.is_working_capital, cfm.is_income_tax_liability, '
- 'cfm.is_income_tax_expense, cfm.is_finance_cost, cfm.is_finance_cost_adjustment '
- 'from `tabCash Flow Mapping Accounts` cfma '
- 'join `tabCash Flow Mapping` cfm on cfma.parent=cfm.name '
- 'where cfma.parent in %s '
- 'order by cfm.is_working_capital',
- (mapping_names,)
- )
+ return frappe.db.sql('''
+ select cfma.name, cfm.label, cfm.is_working_capital, cfm.is_income_tax_liability,
+ cfm.is_income_tax_expense, cfm.is_finance_cost, cfm.is_finance_cost_adjustment
+ from `tabCash Flow Mapping Accounts` cfma
+ join `tabCash Flow Mapping` cfm on cfma.parent=cfm.name
+ where cfma.parent in (%s)
+ order by cfm.is_working_capital
+ ''', (', '.join(['"%s"' % d for d in mapping_names])))
def setup_mappers(mappers):
@@ -334,6 +333,7 @@
def execute(filters=None):
+ if not filters.periodicity: filters.periodicity = "Monthly"
period_list = get_period_list(
filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity,
filters.accumulated_values, filters.company
@@ -376,6 +376,7 @@
total = 0
for period in period_list:
start_date = get_start_date(period, accumulated_values, company)
+ accounts = ', '.join(['"%s"' % d for d in account_names])
if opening_balances:
date_info = dict(date=start_date)
@@ -397,19 +398,19 @@
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 name IN %s
- OR parent_account IN %s)
- """, (company, start, end, account_names, account_names))
+ and account in ( SELECT name FROM tabAccount WHERE name IN (%s)
+ OR parent_account IN (%s))
+ """, (company, start, end, accounts, accounts))
else:
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 name IN %s
- OR parent_account IN %s)
+ and account in ( SELECT name FROM tabAccount WHERE name IN (%s)
+ OR parent_account IN (%s))
""", (company, start_date if accumulated_values else period['from_date'],
- period['to_date'], account_names, account_names))
+ period['to_date'], accounts, accounts))
if gl_sum and gl_sum[0]:
amount = gl_sum[0]
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 01c4943..1f7cca1 100644
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -15,7 +15,8 @@
get_presentation_currency_list: () => {
const docs = frappe.boot.docs;
- const currency_list = docs.filter(d => d.doctype === ":Currency").map(d => d.name);
+ let currency_list = docs.filter(d => d.doctype === ":Currency").map(d => d.name);
+ currency_list.unshift("");
return currency_list;
},
diff --git a/erpnext/selling/report/address_and_contacts/address_and_contacts.py b/erpnext/selling/report/address_and_contacts/address_and_contacts.py
index 0a46d2c..a9e4303 100644
--- a/erpnext/selling/report/address_and_contacts/address_and_contacts.py
+++ b/erpnext/selling/report/address_and_contacts/address_and_contacts.py
@@ -77,8 +77,8 @@
result.extend(add_blank_columns_for("Address"))
data.append(result)
else:
- addresses = map(list, addresses)
- contacts = map(list, contacts)
+ addresses = list(map(list, addresses))
+ contacts = list(map(list, contacts))
max_length = max(len(addresses), len(contacts))
for idx in range(0, max_length):