Resolved bug: if account of type 'Bank or Cash' does not exists, then it shows error in the email digest email but does not raise exception
This commit is contained in:
parent
c2a9cca4fd
commit
3fe9795020
@ -110,19 +110,19 @@ class DocType:
|
|||||||
|
|
||||||
for query in query_dict.keys():
|
for query in query_dict.keys():
|
||||||
if self.doc.fields[query]:
|
if self.doc.fields[query]:
|
||||||
#webnotes.msgprint(query)
|
if query_dict[query]:
|
||||||
res = webnotes.conn.sql(query_dict[query], as_dict=1)
|
#webnotes.msgprint(query)
|
||||||
if query == 'income':
|
res = webnotes.conn.sql(query_dict[query], as_dict=1)
|
||||||
for r in res:
|
if query == 'income':
|
||||||
r['value'] = float(r['credit'] - r['debit'])
|
for r in res:
|
||||||
elif query in ['expenses_booked', 'bank_balance']:
|
r['value'] = float(r['credit'] - r['debit'])
|
||||||
for r in res:
|
elif query in ['expenses_booked', 'bank_balance']:
|
||||||
r['value'] = float(r['debit'] - r['credit'])
|
for r in res:
|
||||||
#webnotes.msgprint(query)
|
r['value'] = float(r['debit'] - r['credit'])
|
||||||
#webnotes.msgprint(res)
|
#webnotes.msgprint(query)
|
||||||
result[query] = (res and len(res)==1) and res[0] or (res and res or None)
|
#webnotes.msgprint(res)
|
||||||
|
result[query] = (res and len(res)==1) and res[0] or (res and res or None)
|
||||||
|
|
||||||
#webnotes.msgprint(result)
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@ -149,18 +149,19 @@ class DocType:
|
|||||||
|
|
||||||
elif args['type'] in ['collections', 'payments']:
|
elif args['type'] in ['collections', 'payments']:
|
||||||
args['bc_accounts_regex'] = self.get_bc_accounts_regex()
|
args['bc_accounts_regex'] = self.get_bc_accounts_regex()
|
||||||
query = """
|
if args['bc_accounts_regex']:
|
||||||
SELECT
|
query = """
|
||||||
IFNULL(SUM(IFNULL(gle.%(field)s, 0)), 0) AS '%(field)s',
|
SELECT
|
||||||
%(common_select)s
|
IFNULL(SUM(IFNULL(gle.%(field)s, 0)), 0) AS '%(field)s',
|
||||||
FROM
|
%(common_select)s
|
||||||
%(common_from)s
|
FROM
|
||||||
WHERE
|
%(common_from)s
|
||||||
%(common_where)s AND
|
WHERE
|
||||||
ac.master_type = '%(master_type)s' AND
|
%(common_where)s AND
|
||||||
gle.against REGEXP '%(bc_accounts_regex)s' AND
|
ac.master_type = '%(master_type)s' AND
|
||||||
%(start_date_condition)s AND
|
gle.against REGEXP '%(bc_accounts_regex)s' AND
|
||||||
%(end_date_condition)s""" % args
|
%(start_date_condition)s AND
|
||||||
|
%(end_date_condition)s""" % args
|
||||||
|
|
||||||
elif args['type'] in ['income', 'expenses_booked']:
|
elif args['type'] in ['income', 'expenses_booked']:
|
||||||
query = """
|
query = """
|
||||||
@ -307,7 +308,8 @@ class DocType:
|
|||||||
FROM `tabAccount`
|
FROM `tabAccount`
|
||||||
WHERE account_type = 'Bank or Cash'""", as_list=1)
|
WHERE account_type = 'Bank or Cash'""", as_list=1)
|
||||||
|
|
||||||
return '(' + '|'.join([ac[0] for ac in bc_account_list]) + ')'
|
if bc_account_list:
|
||||||
|
return '(' + '|'.join([ac[0] for ac in bc_account_list]) + ')'
|
||||||
|
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
@ -653,13 +655,17 @@ class DocType:
|
|||||||
# Sort these keys depending on idx value
|
# Sort these keys depending on idx value
|
||||||
bd_keys = sorted(body_dict, key=lambda x: body_dict[x]['idx'])
|
bd_keys = sorted(body_dict, key=lambda x: body_dict[x]['idx'])
|
||||||
|
|
||||||
|
|
||||||
for k in bd_keys:
|
for k in bd_keys:
|
||||||
if self.doc.fields[k]:
|
if self.doc.fields[k]:
|
||||||
table_list.append(body_dict[k]['table'])
|
if k in result:
|
||||||
|
table_list.append(body_dict[k]['table'])
|
||||||
|
elif k in ['collections', 'payments']:
|
||||||
|
table_list.append(\
|
||||||
|
"<div style='font-size: 16px; color: grey'>[" + \
|
||||||
|
k.capitalize() + \
|
||||||
|
"]<br />Missing: Ledger of type 'Bank or Cash'\
|
||||||
|
</div>")
|
||||||
|
|
||||||
result = []
|
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
result = []
|
result = []
|
||||||
op_len = len(table_list)
|
op_len = len(table_list)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user