From 9ca7e5255b23db5e9ebeab00c9b5ff3573c65145 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Dec 2011 15:05:14 +0530 Subject: [PATCH 1/8] Patch to update idx.. start idx from 1 --- erpnext/patches/update_0_idx.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 erpnext/patches/update_0_idx.py diff --git a/erpnext/patches/update_0_idx.py b/erpnext/patches/update_0_idx.py new file mode 100644 index 00000000000..9c31f1d6641 --- /dev/null +++ b/erpnext/patches/update_0_idx.py @@ -0,0 +1,9 @@ +import webnotes +def execute(): + doc_type_list = webnotes.conn.sql("""SELECT DISTINCT parent FROM `tabDocField` where idx=0""") + for doc_type in doc_type_list: + if doc_type and doc_type[0]: + webnotes.conn.sql("""\ + UPDATE `tabDocField` SET idx=idx+1 + WHERE parent=%s + """, doc_type[0]) From f2f4c87bb6f04dcb879b72ddf68d6643be6a55a0 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Dec 2011 15:19:16 +0530 Subject: [PATCH 2/8] remove previous field property setter --- erpnext/patches/remove_previous_field_property_setter.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 erpnext/patches/remove_previous_field_property_setter.py diff --git a/erpnext/patches/remove_previous_field_property_setter.py b/erpnext/patches/remove_previous_field_property_setter.py new file mode 100644 index 00000000000..677188e6242 --- /dev/null +++ b/erpnext/patches/remove_previous_field_property_setter.py @@ -0,0 +1,6 @@ +import webnotes +def execute(): + webnotes.conn.sql("""\ + DELETE FROM `tabProperty Setter` + WHERE property='previous_field' + """) From 7792d08408888a6fd8666eeede5610bb844109e6 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Dec 2011 17:23:11 +0530 Subject: [PATCH 3/8] Dont show bank balance if no ledger of type "Bank or Cash" --- erpnext/setup/doctype/email_digest/email_digest.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py index 5b760245e25..62b1e3e2e41 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.py +++ b/erpnext/setup/doctype/email_digest/email_digest.py @@ -121,6 +121,8 @@ class DocType: #webnotes.msgprint(query) #webnotes.msgprint(res) result[query] = (res and len(res)==1) and res[0] or (res and res or None) + if result[query] is None: + del result[query] return result @@ -586,7 +588,7 @@ class DocType: }, 'bank_balance': { - 'table': 'bank_balance' in result and table({ + 'table': 'bank_balance' in result and result['bank_balance'] and table({ 'head': 'Bank Balance', 'body': [ [ @@ -658,7 +660,7 @@ class DocType: if self.doc.fields[k]: if k in result: table_list.append(body_dict[k]['table']) - elif k in ['collections', 'payments']: + elif k in ['collections', 'payments', 'bank_balance']: table_list.append(\ "
[" + \ k.capitalize() + \ From 94a18109d7690b8756995aadfd70e36ee0159495 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Dec 2011 17:34:11 +0530 Subject: [PATCH 4/8] Fixed issue: If account of type "Bank or Cash" is not associated to any GL Entry, then it displays an alert in the email digest email body --- erpnext/setup/doctype/email_digest/email_digest.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py index 62b1e3e2e41..3498a7f55f3 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.py +++ b/erpnext/setup/doctype/email_digest/email_digest.py @@ -660,12 +660,19 @@ class DocType: if self.doc.fields[k]: if k in result: table_list.append(body_dict[k]['table']) - elif k in ['collections', 'payments', 'bank_balance']: + elif k in ['collections', 'payments']: table_list.append(\ "
[" + \ k.capitalize() + \ - "]
Missing: Ledger of type 'Bank or Cash'\ + "]
Missing: Account of type 'Bank or Cash'\
") + elif k=='bank_balance': + table_list.append(\ + "
[" + \ + "Bank Balance" + \ + "]
Alert: GL Entry not found for Account of type 'Bank or Cash'\ +
") + i = 0 result = [] From 61a4a498cf9b27db9065ba0b1dcb40ec7b1d2c16 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Dec 2011 18:02:36 +0530 Subject: [PATCH 5/8] Added feature: Income Year To Date in Email Digest --- .../doctype/email_digest/email_digest.js | 2 + .../doctype/email_digest/email_digest.py | 37 ++++++++++++++++++- .../doctype/email_digest/email_digest.txt | 27 ++++++++++++-- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/erpnext/setup/doctype/email_digest/email_digest.js b/erpnext/setup/doctype/email_digest/email_digest.js index 728c8b4b7d2..81b37e43da5 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.js +++ b/erpnext/setup/doctype/email_digest/email_digest.js @@ -4,6 +4,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { var err_msg = "There was an error. One probable reason could be that you haven't saved the form. Please contact support@erpnext.com if the problem persists." cur_frm.add_custom_button('View Now', function() { + doc = locals[dt][dn]; if(doc.__unsaved != 1) { $c_obj(make_doclist(dt, dn), 'get', '', function(r, rt) { if(r.exc) { @@ -26,6 +27,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { } }, 1); cur_frm.add_custom_button('Send Now', function() { + doc = locals[dt][dn]; if(doc.__unsaved != 1) { $c_obj(make_doclist(dt, dn), 'send', '', function(r, rt) { if(r.exc) { diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py index 3498a7f55f3..cd84d1098a2 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.py +++ b/erpnext/setup/doctype/email_digest/email_digest.py @@ -1,4 +1,5 @@ import webnotes +import webnotes.utils class DocType: def __init__(self, doc, doclist=[]): @@ -61,6 +62,11 @@ class DocType: 'debit_or_credit': 'Credit' }), + 'income_year_to_date': self.generate_gle_query({ + 'type': 'income_year_to_date', + 'debit_or_credit': 'Credit' + }), + 'expenses_booked': self.generate_gle_query({ 'type': 'expenses_booked', 'debit_or_credit': 'Debit' @@ -112,7 +118,7 @@ class DocType: if self.doc.fields[query] and query_dict[query]: #webnotes.msgprint(query) res = webnotes.conn.sql(query_dict[query], as_dict=1) - if query == 'income': + if query in ['income', 'income_year_to_date']: for r in res: r['value'] = float(r['credit'] - r['debit']) elif query in ['expenses_booked', 'bank_balance']: @@ -179,6 +185,21 @@ class DocType: %(start_date_condition)s AND %(end_date_condition)s""" % args + elif args['type'] == 'income_year_to_date': + query = """ + SELECT + IFNULL(SUM(IFNULL(gle.debit, 0)), 0) AS 'debit', + IFNULL(SUM(IFNULL(gle.credit, 0)), 0) AS 'credit', + %(common_select)s + FROM + %(common_from)s + WHERE + %(common_where)s AND + ac.is_pl_account = 'Yes' AND + ac.debit_or_credit = '%(debit_or_credit)s' AND + %(fiscal_start_date_condition)s AND + %(end_date_condition)s""" % args + elif args['type'] == 'bank_balance': query = """ SELECT @@ -203,6 +224,7 @@ class DocType: Adds common conditions in dictionary "args" """ start_date, end_date = self.get_start_end_dates() + fiscal_start_date = webnotes.utils.get_defaults()['year_start_date'] if 'new' in args['type']: args.update({ @@ -233,7 +255,9 @@ class DocType: 'start_date_condition': "gle.posting_date >= '%s'" % start_date, - 'end_date_condition': "gle.posting_date <= '%s'" % end_date + 'end_date_condition': "gle.posting_date <= '%s'" % end_date, + + 'fiscal_start_date_condition': "gle.posting_date >= '%s'" % fiscal_start_date }) @@ -578,6 +602,15 @@ class DocType: 'idx': 302 }, + 'income_year_to_date': { + 'table': 'income_year_to_date' in result and table({ + 'head': 'Income Year To Date', + 'body': currency_amount_str \ + % (currency, fmt_money(result['income_year_to_date']['value'])) + }), + 'idx': 303 + }, + 'expenses_booked': { 'table': 'expenses_booked' in result and table({ 'head': 'Expenses Booked', diff --git a/erpnext/setup/doctype/email_digest/email_digest.txt b/erpnext/setup/doctype/email_digest/email_digest.txt index 3d8de7b8f7a..6d8a3dab678 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.txt +++ b/erpnext/setup/doctype/email_digest/email_digest.txt @@ -3,16 +3,16 @@ # These values are common in all dictionaries { - 'creation': '2011-12-12 10:41:40', + 'creation': '2011-12-14 12:15:09', 'docstatus': 0, - 'modified': '2011-12-15 13:53:08', + 'modified': '2011-12-22 17:55:57', 'modified_by': 'Administrator', 'owner': 'Administrator' }, # These values are common for all DocType { - '_last_update': '1323353260', + '_last_update': '1323937389', 'autoname': 'Prompt', 'colour': 'White:FFF', 'doctype': 'DocType', @@ -21,7 +21,7 @@ 'name': '__common__', 'section_style': 'Simple', 'show_in_menu': 0, - 'version': 79 + 'version': 80 }, # These values are common for all DocField @@ -134,6 +134,15 @@ 'search_index': 0 }, + # DocField + { + 'doctype': 'DocField', + 'fieldtype': 'Button', + 'label': 'Add Recipients', + 'permlevel': 0, + 'trigger': 'Client' + }, + # DocField { 'doctype': 'DocField', @@ -290,6 +299,16 @@ 'permlevel': 0 }, + # DocField + { + 'depends_on': 'eval:doc.use_standard', + 'doctype': 'DocField', + 'fieldname': 'income_year_to_date', + 'fieldtype': 'Check', + 'label': 'Income Year to Date', + 'permlevel': 0 + }, + # DocField { 'depends_on': 'eval:doc.use_standard', From 68f3967de0454c841222ade81907ad7ef85439ba Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Dec 2011 18:18:10 +0530 Subject: [PATCH 6/8] Patch to enable income year to date summary in email digest --- erpnext/patches/edigest_enable_income_year_to_date.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 erpnext/patches/edigest_enable_income_year_to_date.py diff --git a/erpnext/patches/edigest_enable_income_year_to_date.py b/erpnext/patches/edigest_enable_income_year_to_date.py new file mode 100644 index 00000000000..16e8932ed34 --- /dev/null +++ b/erpnext/patches/edigest_enable_income_year_to_date.py @@ -0,0 +1,10 @@ +import webnotes + +def execute(): + companies_list = webnotes.conn.sql("SELECT company_name FROM `tabCompany`", as_list=1) + for company in companies_list: + if company and company[0]: + edigest = Document('Email Digest', "Default Weekly Digest - " + company[0]) + if edigest: + edigest.income_year_to_date = 1 + edigest.save() From 0188df1609b9125a2a26f3a31018ccbe8eb19122 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Dec 2011 18:21:57 +0530 Subject: [PATCH 7/8] Amended the patch to import class Document --- erpnext/patches/edigest_enable_income_year_to_date.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/patches/edigest_enable_income_year_to_date.py b/erpnext/patches/edigest_enable_income_year_to_date.py index 16e8932ed34..380de832b80 100644 --- a/erpnext/patches/edigest_enable_income_year_to_date.py +++ b/erpnext/patches/edigest_enable_income_year_to_date.py @@ -1,4 +1,5 @@ import webnotes +from webnotes.model.doc import Document def execute(): companies_list = webnotes.conn.sql("SELECT company_name FROM `tabCompany`", as_list=1) From f5d5f10ff30e613cf58539a03e53881866487638 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 22 Dec 2011 19:02:15 +0530 Subject: [PATCH 8/8] Remove "Add Recipients" button from Email Digest (again!) --- .../setup/doctype/email_digest/email_digest.txt | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/erpnext/setup/doctype/email_digest/email_digest.txt b/erpnext/setup/doctype/email_digest/email_digest.txt index 6d8a3dab678..897adadd2bb 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.txt +++ b/erpnext/setup/doctype/email_digest/email_digest.txt @@ -5,14 +5,14 @@ { 'creation': '2011-12-14 12:15:09', 'docstatus': 0, - 'modified': '2011-12-22 17:55:57', + 'modified': '2011-12-22 19:01:33', 'modified_by': 'Administrator', 'owner': 'Administrator' }, # These values are common for all DocType { - '_last_update': '1323937389', + '_last_update': '1324556758', 'autoname': 'Prompt', 'colour': 'White:FFF', 'doctype': 'DocType', @@ -21,7 +21,7 @@ 'name': '__common__', 'section_style': 'Simple', 'show_in_menu': 0, - 'version': 80 + 'version': 81 }, # These values are common for all DocField @@ -134,15 +134,6 @@ 'search_index': 0 }, - # DocField - { - 'doctype': 'DocField', - 'fieldtype': 'Button', - 'label': 'Add Recipients', - 'permlevel': 0, - 'trigger': 'Client' - }, - # DocField { 'doctype': 'DocField',