deprecated dashboard

This commit is contained in:
Nabin Hait
2012-10-05 12:11:23 +05:30
parent 367f059895
commit 5417f5666c
13 changed files with 2 additions and 605 deletions

View File

@@ -302,70 +302,4 @@ class DocType:
for p in self.period_list:
period_end_date = self.period_end_date[p].strftime('%Y-%m-%d')
ret.append(get_balance_on(acc, period_end_date))
return ret
def get_top_5_cust(self, company):
rec_grp = sql("select receivables_group from tabCompany where name=%s", company)
if rec_grp:
pa_lft_rgt = sql("select lft, rgt from tabAccount where name=%s and company=%s", (rec_grp[0][0], company))[0]
return sql("select t1.account_name, SUM(t2.debit) from tabAccount t1, `tabGL Entry` t2 where t1.lft > %s and t1.rgt < %s and t2.account = t1.name and ifnull(t2.is_cancelled, 'No') = 'No' GROUP BY t1.name ORDER BY SUM(t2.debit) desc limit 5", (pa_lft_rgt[0], pa_lft_rgt[1]))
else:
return []
def get_top_5_exp(self, company):
a = sql("select distinct account_name, name, debit_or_credit, lft, rgt from `tabAccount` where account_name=%s and company=%s", ('Expenses', company), as_dict=1)[0]
return sql("select t1.account_name, SUM(t2.debit) from tabAccount t1, `tabGL Entry` t2 where t1.lft>%s and t1.rgt<%s and t1.group_or_ledger = 'Ledger' and t2.account = t1.name and ifnull(t2.is_cancelled, 'No') = 'No' and t2.voucher_type != 'Period Closing Voucher' GROUP BY t1.name ORDER BY SUM(t2.debit) desc limit 5", (a['lft'],a['rgt']))
def bl(self, acc, company):
dt = getdate(nowdate())
r = []
# cur
r.append(get_balance_on(acc, get_fiscal_year(nowdate())))
# this month
r.append(get_balance_on(acc, get_last_day(dt)))
# last month
r.append(get_balance_on(acc, get_last_day(get_first_day(dt,0,-1))))
return r
def bl_bs(self, acc, company, sd):
dt = getdate(nowdate())
r = []
# cur
r.append(get_balance_on(acc, get_fiscal_year(nowdate())))
# last month
r.append(self.get_balance_on(acc, get_last_day(get_first_day(dt,0,-1))))
# opening
r.append(self.get_balance_on(acc, sd))
return r
def get_dashboard_values(self, arg=''):
d = get_defaults()
self.fiscal_year = d['fiscal_year']
if arg:
company = arg
else:
company = d['company']
r = {}
r['Income'] = self.bl('Income', company)
r['Expenses'] = self.bl('Expenses', company)
r['Profit'] = []
for i in range(3):
r['Profit'].append(r['Income'][i] - r['Expenses'][i])
r['Current Assets'] = self.bl_bs('Current Assets', company, getdate(d['year_start_date']))
r['Current Liabilities'] = self.bl_bs('Current Liabilities', company, getdate(d['year_start_date']))
r['Working Capital'] = []
for i in range(3):
r['Working Capital'].append(r['Current Assets'][i] - r['Current Liabilities'][i])
r['Bank Accounts'] = self.bl_bs('Bank Accounts', company, getdate(d['year_start_date']))
r['Top Customers'] = convert_to_lists(self.get_top_5_cust(company))
r['Top Expenses'] = convert_to_lists(self.get_top_5_exp(company))
return r
return ret