Account view

Share your cool Custom SQL reports or Lua scripts with other mmex users

Account view

Postby Nikolay » Sun Jan 03, 2010 4:56 pm

Query displays the specified account with the first of the last transaction.
For printing set: File - Page setup - Orientation - Album

Has been modified 10-th of january.

Code: Select all
select   c.transdate as Date, c.transactionnumber as Number
, ifnull(p.payeename,(select accountname from accountlist_v1 where accountid=(case c.toaccountid when u.accountid then c.accountid else c.toaccountid end))) as Payee
, c.status as Status
, ifnull((ca.categname||case when s.subcategname is not NULL then ':'||s.subcategname else '' end), 'Splited') as Category,
(case  when c.transcode='Withdrawal'  or (c.transcode='Transfer' and c.accountid=u.accountid ) then c.transamount else  '' end) as Withdrawal,
case  when c.transcode='Deposit'  then c.transamount when c.transcode='Transfer' and c.toaccountid=u.accountid then c.totransamount else  '' end as Deposit,
round((select a.initialbal from accountlist_v1 a where a.accountid=u.accountid )
+ifnull((select sum(c0.transamount*
(case  when c0.transcode='Deposit' then 1.0 else -1.0 end)
) from checkingaccount_v1 c0 where (c0.transdate<c.transdate or ( c0.transdate=c.transdate and c0.transid<=c.transid)) and c0.accountid=u.accountid and c0.status<>'V'),0)
+ifnull((select sum(c2.totransamount) from checkingaccount_v1 c2 where (c2.transdate<c.transdate or (c2.transdate=c.transdate and c2.transid<=c.transid)) and c2.transcode='Transfer' and c2.toaccountid=u.accountid) ,0),2)
as Balance,
c.notes as "------------= Notes =------------"
from checkingaccount_v1 c, (select accountid from accountlist_v1 where accountname='$Наличные') u /*Specifiy the name of account in this line */
left join payee_v1 p on  c.payeeid=p.payeeid
inner join category_v1 ca on c.categid=ca.categid
left join subcategory_v1 s on s.subcategid=c.subcategid
where c.accountid=u.accountid or c.toaccountid=u.accountid
order by c.transdate, c.transid   
Nikolay
MMEX Developer
 
Posts: 1173
Joined: Sat Dec 06, 2008 8:27 am
Location: Sankt-Petersburg, Russia

Re: Account view

Postby Eve » Mon Nov 05, 2012 2:04 pm

Thank you for your help.
I've managed to create the report template - but how do I populate with the information? - sorry I'm new to this software and probably being a bit thick ;-/
Eve
New MMEX User
 
Posts: 6
Joined: Sun Nov 04, 2012 4:09 pm
Location: Lancashire UK

Re: Account view

Postby PeCe » Mon Nov 05, 2012 4:03 pm

I assume you have copied the SQL code into the template.
Did you also change the name behind accountname to the name of your account that you want to create this report for.
Code: Select all
accountname='$Наличные') u
/*Specifiy the name of account in this line */

Change '$Наличные' to 'your account' (between the single quotes).

If you do this the report should automatically be populated with data.
Also be sure to type the name of the account exact as it is set up, use the same capitals, spaces etc. SQL is case sensitive, so Account is different from account and this can also be the cause that the SQL is not populated with data.
PeCe
Super MMEX User
 
Posts: 38
Joined: Sun May 13, 2012 4:26 pm


Return to Custom SQL and Lua Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron