Added feature: Income Year To Date in Email Digest
This commit is contained in:
parent
94a18109d7
commit
61a4a498cf
@ -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) {
|
||||
|
@ -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',
|
||||
|
@ -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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user