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
