fixes to dashboard and setup wizard
diff --git a/home/page/dashboard/dashboard.js b/home/page/dashboard/dashboard.js
index c5dd361..15e7cf3 100644
--- a/home/page/dashboard/dashboard.js
+++ b/home/page/dashboard/dashboard.js
@@ -10,12 +10,12 @@
pscript.dashboard_settings = {
company: sys_defaults.company,
- start: dateutil.obj_to_str(dateutil.add_days(new Date(), -60)),
+ start: dateutil.obj_to_str(dateutil.add_days(new Date(), -180)),
end: dateutil.obj_to_str(new Date()),
- interval: 7
+ interval: 30
}
- var ph = new PageHeader($('.dashboard .header').get(0), 'Dashboards');
+ var ph = new PageHeader($('.dashboard .header').get(0), 'Dashboard');
var db = new Dashboard();
ph.add_button('Settings', db.show_settings);
@@ -46,17 +46,19 @@
// give an id!
var cell = $td(t,ridx,cidx);
var title = $a(cell, 'div', 'dashboard-title', '', data[i][0].title);
- var parent = $a(cell, 'div', 'dashboard-graph')
+ var parent = $a(cell, 'div', 'dashboard-graph');
+ if(data[i][0].comment);
+ var comment = $a(cell, 'div', 'comment', '', data[i][0].comment)
parent.id = '_dashboard' + ridx + '-' + cidx;
// render graph
- me.render_graph(parent.id, data[i][1]);
+ me.render_graph(parent.id, data[i][1], data[i][0].fillColor);
cidx++;
}
},
- render_graph: function(parent, values) {
+ render_graph: function(parent, values, fillColor) {
var vl = [];
$.each(values, function(i,v) {
vl.push([dateutil.str_to_user(v[0]), v[1]]);
@@ -84,7 +86,8 @@
pad: 1.05,
tickOptions: {formatString: '%d'}
}
- }
+ },
+ seriesColors: [fillColor]
});
},
diff --git a/home/page/dashboard/dashboard.py b/home/page/dashboard/dashboard.py
index 2c76b15..c17e974 100644
--- a/home/page/dashboard/dashboard.py
+++ b/home/page/dashboard/dashboard.py
@@ -2,58 +2,63 @@
{
'type': 'account',
'account': 'Income',
- 'title': 'Income'
+ 'title': 'Income',
+ 'fillColor': '#90EE90'
},
{
'type': 'account',
'account': 'Expenses',
- 'title': 'Expenses'
+ 'title': 'Expenses',
+ 'fillColor': '#90EE90'
},
{
- 'type': 'from_company',
- 'account': 'receivables_group',
- 'title': 'Receivables'
+ 'type': 'receivables',
+ 'title': 'Receivables',
+ 'fillColor': '#FFE4B5'
},
{
- 'type': 'from_company',
- 'account': 'payables_group',
- 'title': 'Payables'
+ 'type': 'payables',
+ 'title': 'Payables',
+ 'fillColor': '#FFE4B5'
},
{
- 'type': 'cash',
- 'debit_or_credit': 'Debit',
- 'title': 'Cash Inflow'
+ 'type': 'collection',
+ 'title': 'Collection',
+ 'comment':'This info comes from the accounts your have marked as "Bank or Cash"',
+ 'fillColor': '#DDA0DD'
},
{
- 'type': 'cash',
- 'debit_or_credit': 'Credit',
- 'title': 'Cash Outflow'
+ 'type': 'payments',
+ 'title': 'Payments',
+ 'comment':'This info comes from the accounts your have marked as "Bank or Cash"',
+ 'fillColor': '#DDA0DD'
},
{
'type': 'creation',
'doctype': 'Quotation',
- 'title': 'New Quotations'
+ 'title': 'New Quotations',
+ 'fillColor': '#ADD8E6'
},
{
'type': 'creation',
'doctype': 'Sales Order',
- 'title': 'New Orders'
+ 'title': 'New Orders',
+ 'fillColor': '#ADD8E6'
}
]
-
class DashboardWidget:
def __init__(self, company, start, end, interval):
- import webnotes
from webnotes.utils import getdate
from webnotes.model.code import get_obj
+ import webnotes
self.company = company
self.abbr = webnotes.conn.get_value('Company', company, 'abbr')
@@ -61,17 +66,20 @@
self.end = getdate(end)
self.interval = interval
- self.fiscal_year = webnotes.conn.sql("""
- select name from `tabFiscal Year`
- where year_start_date <= %s and
- DATE_ADD(year_start_date, INTERVAL 1 YEAR) >= %s
- """, (start, start))[0][0]
+
self.glc = get_obj('GL Control')
self.cash_accounts = [d[0] for d in webnotes.conn.sql("""
select name from tabAccount
where account_type='Bank or Cash'
and company = %s and docstatus = 0
""", company)]
+
+ self.receivables_group = webnotes.conn.get_value('Company', company,'receivables_group')
+ self.payables_group = webnotes.conn.get_value('Company', company,'payables_group')
+
+ # list of bank and cash accounts
+ self.bc_list = [s[0] for s in webnotes.conn.sql("select name from tabAccount where account_type='Bank or Cash'")]
+
def timeline(self):
"""
@@ -125,8 +133,19 @@
print acc
raise e
- return self.glc.get_as_on_balance(acc, self.fiscal_year, start, debit_or_credit, lft, rgt)
+ return self.glc.get_as_on_balance(acc, self.get_fiscal_year(start), start, debit_or_credit, lft, rgt)
+ def get_fiscal_year(self, dt):
+ """
+ get fiscal year from date
+ """
+ import webnotes
+ self.fiscal_year = webnotes.conn.sql("""
+ select name from `tabFiscal Year`
+ where year_start_date <= %s and
+ DATE_ADD(year_start_date, INTERVAL 1 YEAR) >= %s
+ """, (dt, dt))[0][0]
+
def get_creation_trend(self, doctype, start, end):
"""
Get creation # of creations in period
@@ -158,6 +177,26 @@
return debit_or_credit=='Credit' and float(ret[1]-ret[0]) or float(ret[0]-ret[1])
+ def get_bank_amt(self, debit_or_credit, master_type, start, end):
+ """
+ Get collection (reduction in receivables over a period)
+ """
+ import webnotes
+
+ reg = '('+'|'.join(self.bc_list) + ')'
+
+ return webnotes.conn.sql("""
+ select sum(t1.%s)
+ from `tabGL Entry` t1, tabAccount t2
+ where t1.account = t2.name
+ and t2.master_type='%s'
+ and t1.%s > 0
+ and t1.against REGEXP '%s'
+ and ifnull(t1.is_cancelled, 'No')='No'
+ and t1.posting_date between '%s' and '%s'
+ """ % (debit_or_credit, master_type, debit_or_credit, reg, start, end))[0][0]
+
+
def value(self, opts, start, end):
"""
Value of the series on a particular date
@@ -170,17 +209,17 @@
return self.get_account_amt(opts['account'], start, end, debit_or_credit)
- elif opts['type']=='from_company':
- acc = webnotes.conn.get_value('Company', self.company, \
- opts['account'].split('.')[-1])
+ elif opts['type']=='receivables':
+ return self.get_account_balance(self.receivables_group, end)[2]
- return self.get_account_balance(acc, start)[2]
-
- elif opts['type']=='cash':
- if opts['debit_or_credit']=='Credit':
- return sum([self.get_account_amt(acc, start, end, opts['debit_or_credit']) for acc in self.cash_accounts]) or 0
- elif opts['debit_or_credit']=='Debit':
- return sum([self.get_account_amt(acc, start, end, opts['debit_or_credit']) for acc in self.cash_accounts]) or 0
+ elif opts['type']=='payables':
+ return self.get_account_balance(self.payables_group, end)[2]
+
+ elif opts['type']=='collection':
+ return self.get_bank_amt('credit', 'Customer', start, end)
+
+ elif opts['type']=='payments':
+ return self.get_bank_amt('credit', 'Supplier', start, end)
elif opts['type']=='creation':
return self.get_creation_trend(opts['doctype'], start, end)
diff --git a/home/page/event_updates/event_updates.js b/home/page/event_updates/event_updates.js
index 1574f53..834e887 100644
--- a/home/page/event_updates/event_updates.js
+++ b/home/page/event_updates/event_updates.js
@@ -25,12 +25,7 @@
wrapper.banner_area = $a(wrapper.head, 'div');
- wrapper.setup_wizard_area = $a(wrapper.body, 'div', 'setup-wizard')
-
- wrapper.system_message_area = $a(wrapper.body, 'div', '',
- {marginBottom:'16px', padding:'8px', backgroundColor:'#FFD', border:'1px dashed #AA6', display:'none'})
-
-
+ wrapper.setup_wizard_area = $a(wrapper.body, 'div', 'setup-wizard');
}
// ==================================
@@ -613,11 +608,7 @@
$c_page('home', 'event_updates', 'get_status_details', user,
function(r,rt) {
home_status_bar.render(r.message);
-
- // system_messages
- if(r.message.system_message)
- pscript.show_system_message(wrapper, r.message.system_message);
-
+
// render online users
pscript.online_users_obj.render(r.message.online_users);
pscript.online_users = r.message.online_users;
@@ -630,24 +621,6 @@
);
}
-// show system message
-// -------------------
-pscript.show_system_message = function(wrapper, msg) {
- $ds(wrapper.system_message_area);
- var txt = $a(wrapper.system_message_area, 'div', '', {lineHeight:'1.6em'});
- txt.innerHTML = msg;
-
- var span = $ln($a(wrapper.system_message_area, 'div', '', {textAlign:'right'}), 'Dismiss'.bold(),
- function(me) {
- me.set_working();
- $c_obj('Home Control', 'dismiss_message', '', function(r,rt) {
- me.done_working();
- $(wrapper.system_message_area).slideUp();
- });
- }, {fontSize:'11px'}
- )
-}
-
// complete my company registration
// --------------------------------
pscript.complete_registration = function()
diff --git a/home/page/event_updates/event_updates.py b/home/page/event_updates/event_updates.py
index 85a121b..1134273 100644
--- a/home/page/event_updates/event_updates.py
+++ b/home/page/event_updates/event_updates.py
@@ -28,18 +28,11 @@
online = get_online_users()
- # system messages
- msg_id = webnotes.conn.get_global('system_message_id')
- msg = ''
-
- if msg_id and msg_id != webnotes.conn.get_global('system_message_id', webnotes.session['user']):
- msg = webnotes.conn.get_global('system_message')
-
+ # system messages
ret = {
'user_count': len(online) or 0,
'unread_messages': get_unread_messages(),
'online_users': online or [],
- 'system_message':msg,
'is_trial': webnotes.conn.get_global('is_trial'),
'days_to_expiry': (webnotes.conn.get_global('days_to_expiry') or '0'),
'setup_status': get_setup_status()
@@ -56,9 +49,20 @@
percent = 20
ret = []
- header = webnotes.conn.get_value('Control Panel', None, 'client_name') or ''
- if header.startswith('<div style="padding:4px; font-size:20px;">'\
- +webnotes.conn.get_value('Control Panel', None, 'company_name')):
+ def is_header_set():
+ header = webnotes.conn.get_value('Control Panel', None, 'client_name') or ''
+
+ if header.startswith('<div style="padding:4px; font-size:20px;">'\
+ +webnotes.conn.get_value('Control Panel', None, 'company_name')):
+ return False
+
+ elif 'Banner Comes Here' in header:
+ return False
+
+ else:
+ return True
+
+ if not is_header_set():
ret.append('<a href="#!Form/Personalize/Personalize">Upload your company banner</a>')
else:
percent += 20