Skip to content

Commit

Permalink
Merge pull request #15 from vomikan/master
Browse files Browse the repository at this point in the history
Invalid Transactions
  • Loading branch information
guanlisheng committed Dec 18, 2014
2 parents b649035 + 3bda9b4 commit c791786
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 0 deletions.
1 change: 1 addition & 0 deletions InvalidTransactions/description.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The report displays invalid transactions
9 changes: 9 additions & 0 deletions InvalidTransactions/luacontent.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

function handle_record(record)
record:set("TRX_LINK", string.format('<a href="trx:%s">%s</a>', record:get('TRANSID'), record:get('TRANSID')));
record:set("TRX_LINK_GO", string.format('<a href="trxid:%s">%s</a>', record:get('TRANSID'), record:get('Account')));
end

function complete(result)

end
69 changes: 69 additions & 0 deletions InvalidTransactions/sqlcontent.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
select c.transid, c.transdate, c.notes
, 'ERROR' as Account
, 'OK' as category
, p.PayeeName as Payee
from checkingaccount_v1 c
inner join payee_v1 p on p.payeeid=c.payeeid
where c.accountid not in (select accountid from accountlist_v1)
union all
select c.transid, c.transdate, c.notes
, 'ERROR' as Account
, 'OK' as category
, '' as Payee
from checkingaccount_v1 c
where c.transcode ='Transfer' and c.toaccountid not in (select accountid from accountlist_v1)
union all
select c.transid, c.transdate, c.notes
, a.AccountName
, 'OK'
, 'ERROR'
from checkingaccount_v1 c
inner join accountlist_v1 a on a.accountid=c.accountid
where c.payeeid not in (select payeeid from payee_v1) and transcode!='Transfer'
union all
select c.transid, c.transdate, c.notes
, a.AccountName
, 'ERROR'
, p.PayeeName
from checkingaccount_v1 c
inner join payee_v1 p on p.payeeid=c.payeeid
inner join accountlist_v1 a on a.accountid=c.accountid
where c.categid=-1 and c.transid not in (select transid from splittransactions_v1)
union all
select c.transid, c.transdate, c.notes
, a.AccountName
, 'ERROR'
, p.PayeeName
from checkingaccount_v1 c
inner join payee_v1 p on p.payeeid=c.payeeid
inner join accountlist_v1 a on a.accountid=c.accountid
where c.categid > 0 and c.categid not in (select categid from category_v1)
union all
select c.transid, c.transdate, c.notes
, a.AccountName
, 'ERROR'
, p.PayeeName
from checkingaccount_v1 c
inner join payee_v1 p on p.payeeid=c.payeeid
inner join accountlist_v1 a on a.accountid=c.accountid
where c.categid > 0 and c.subcategid > 0 and c.subcategid not in (select subcategid from subcategory_v1)
union all
select c.transid, c.transdate, c.notes
, a.AccountName
, 'ERROR'
, p.PayeeName
from checkingaccount_v1 c
inner join payee_v1 p on p.payeeid=c.payeeid
inner join accountlist_v1 a on a.accountid=c.accountid
inner join splittransactions_v1 s on c.transid=s.transid
where s.categid > 0 and s.subcategid > 0 and s.subcategid not in (select subcategid from subcategory_v1)
union all
select c.transid, c.transdate, c.notes
, a.AccountName
, 'ERROR'
, p.PayeeName
from checkingaccount_v1 c
inner join payee_v1 p on p.payeeid=c.payeeid
inner join accountlist_v1 a on a.accountid=c.accountid
inner join splittransactions_v1 s on c.transid=s.transid
where s.categid > 0 and s.categid not in (select categid from category_v1)
79 changes: 79 additions & 0 deletions InvalidTransactions/template.htt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><TMPL_VAR REPORTNAME></title>
<link href = "master.css" rel = "stylesheet" />
</head>
<body>
<TMPL_VAR TODAY>
<h3 class="i18n">_Title</h3>
<hr>

<table class='table'>
<thead>
<tr>
<th class="i18n">ID</td>
<th class="i18n">Date</th>
<th class="i18n">Account</th>
<th class="i18n">Payee</th>
<th class="i18n">Category</th>
<th class="i18n">Notes</th>
</tr>
</thead>
<tbody>
<TMPL_LOOP NAME=CONTENTS>
<tr>
<td><TMPL_VAR TRX_LINK></td>
<td><TMPL_VAR TRANSDATE></td>
<td class='ERROR i18n'><TMPL_VAR TRX_LINK_GO></td>
<td class='ERROR i18n'><TMPL_VAR Payee></td>
<td class='ERROR i18n'><TMPL_VAR Category></td>
<td><TMPL_VAR NOTES></td>
</tr>
</TMPL_LOOP>
</tbody>
</table>
<TMPL_LOOP ERRORS>
<hr> <TMPL_VAR ERROR>
</TMPL_LOOP>
</body>

<script type="text/javascript">
<!-- Red color for ERRORS-->
function currency(n) {n = parseFloat(n); return isNaN(n) ? 0 : n.toFixed(2);}
var elements= document.getElementsByClassName("ERROR");
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerHTML.indexOf("ERROR") > -1) {
elements[i].style.color="#ff0000";
}
}
</script>
<!-- Translations -->
<script>
var translations =
{
"english":[{
"_Title":"Invalid Transactions"
}],
"russian": [{
"_Title":"Транзакции с ошибками"
, "Date":"Дата"
, "Payee":"Получатель"
, "Category":"Категория"
, "Account":"Счёт"
, "Notes":"Примечания"
, "ERROR":"Ошибка"
}],
};

var elements= document.getElementsByClassName('i18n');
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var my_lang = translations.<TMPL_VAR LANGUAGE>;
if (my_lang == null) my_lang = translations.english;
var item = my_lang[0][element.innerHTML];
element.innerHTML = (item == null) ? element.innerHTML : item;
}
</script>
</html>

0 comments on commit c791786

Please sign in to comment.