From 1cb47a231cd13b696d61371f95f34ee328008f43 Mon Sep 17 00:00:00 2001 From: AO1 <44472390+andrewaimia@users.noreply.github.com> Date: Wed, 13 Mar 2019 17:34:37 +0400 Subject: [PATCH 01/49] SQL to exclude Duplicate transactions also --- AccountForecast/sqlcontent.sql | 4 +-- AccountSummary/sqlcontent.sql | 2 +- AccountTrend/sqlcontent.sql | 4 +-- BudgetMonitoringCurrentMonth/sqlcontent.sql | 2 +- BudgetMonitoringLastMonth/sqlcontent.sql | 2 +- CategoryForecast/sqlcontent.sql | 4 +-- CategoryTrend/sqlcontent.sql | 4 +-- .../sqlcontent.sql | 2 +- PayeeTrend/sqlcontent.sql | 2 +- SavingsProgress/sqlcontent.sql | 26 +++++++++---------- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/AccountForecast/sqlcontent.sql b/AccountForecast/sqlcontent.sql index 6f3fcdb..401e5de 100644 --- a/AccountForecast/sqlcontent.sql +++ b/AccountForecast/sqlcontent.sql @@ -10,7 +10,7 @@ select b.TRANSAMOUNT, b.REPEATS, b.NUMOCCURRENCES, b.NEXTOCCURRENCEDATE, c.PFX_S from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer') as t where t.ACCOUNTID = a.ACCOUNTID - and t.STATUS <> 'V') as Balance + and t.STATUS NOT IN ('V','D')) as Balance from (select ACCOUNTID, STATUS, REPEATS, NUMOCCURRENCES, NEXTOCCURRENCEDATE, (case when TRANSCODE = 'Deposit' then TRANSAMOUNT else -TRANSAMOUNT end) as TRANSAMOUNT @@ -22,4 +22,4 @@ from inner join ACCOUNTLIST_V1 as a on b.ACCOUNTID = a.ACCOUNTID inner join CURRENCYFORMATS_V1 as c on c.CURRENCYID = a.CURRENCYID where a.ACCOUNTNAME = 'Account1' -and b.STATUS <> 'V'; +and b.STATUS NOT IN ('V','D'); diff --git a/AccountSummary/sqlcontent.sql b/AccountSummary/sqlcontent.sql index 49da208..0de8be3 100644 --- a/AccountSummary/sqlcontent.sql +++ b/AccountSummary/sqlcontent.sql @@ -9,7 +9,7 @@ select a.ACCOUNTNAME, c.BASECONVRATE, c.PFX_SYMBOL, c.SFX_SYMBOL, from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer') as t where t.ACCOUNTID = a.ACCOUNTID - and t.STATUS <> 'V') as Balance + and t.STATUS NOT IN ('D', 'V')) as Balance from ACCOUNTLIST_V1 as a inner join CURRENCYFORMATS_V1 as c on c.CURRENCYID = a.CURRENCYID where a.ACCOUNTTYPE in ('Checking', 'Term') and a.STATUS = 'Open' diff --git a/AccountTrend/sqlcontent.sql b/AccountTrend/sqlcontent.sql index 4a69425..a39b35f 100644 --- a/AccountTrend/sqlcontent.sql +++ b/AccountTrend/sqlcontent.sql @@ -13,7 +13,7 @@ select strftime('%Y', t1.TRANSDATE) as YEAR from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer') as t2 where t2.ACCOUNTID = t1.ACCOUNTID - and t2.STATUS <> 'V' + and t2.STATUS NOT IN ('D', 'V') and (strftime('%Y', t2.TRANSDATE) < strftime('%Y', t1.TRANSDATE) or (strftime('%Y', t2.TRANSDATE) = strftime('%Y', t1.TRANSDATE) and strftime('%m', t2.TRANSDATE) < strftime('%m', t1.TRANSDATE))) @@ -29,6 +29,6 @@ from inner join ACCOUNTLIST_V1 as a on a.ACCOUNTID = t1.ACCOUNTID inner join CURRENCYFORMATS_V1 as c on c.CURRENCYID = a.CURRENCYID where ACCOUNTNAME = 'Account1' - and t1.STATUS <> 'V' + and t1.STATUS NOT IN ('D', 'V') group by YEAR, MONTH order by YEAR asc, MONTH asc; diff --git a/BudgetMonitoringCurrentMonth/sqlcontent.sql b/BudgetMonitoringCurrentMonth/sqlcontent.sql index 6f1b59d..c8577e4 100644 --- a/BudgetMonitoringCurrentMonth/sqlcontent.sql +++ b/BudgetMonitoringCurrentMonth/sqlcontent.sql @@ -33,7 +33,7 @@ from ( join CurrencyFormats_v1 cf on (a.CurrencyId = cf.CurrencyId) where 1=1 and t.TransCode <> 'Transfer' - and t.Status <> 'V' + and t.STATUS NOT IN ('D', 'V') and TransDate between date('now', '0 month', 'start of month') and date('now', 'start of month', '1 month', '-1 day') diff --git a/BudgetMonitoringLastMonth/sqlcontent.sql b/BudgetMonitoringLastMonth/sqlcontent.sql index ee66b1c..4643656 100644 --- a/BudgetMonitoringLastMonth/sqlcontent.sql +++ b/BudgetMonitoringLastMonth/sqlcontent.sql @@ -33,7 +33,7 @@ from ( join CurrencyFormats_v1 cf on (a.CurrencyId = cf.CurrencyId) where 1=1 and t.TransCode <> 'Transfer' - and t.Status <> 'V' + and t.STATUS NOT IN ('D', 'V') and TransDate between date('now', '-1 month', 'start of month') and date('now', 'start of month', '0 month', '-1 day') diff --git a/CategoryForecast/sqlcontent.sql b/CategoryForecast/sqlcontent.sql index 25f885d..66c0205 100644 --- a/CategoryForecast/sqlcontent.sql +++ b/CategoryForecast/sqlcontent.sql @@ -6,11 +6,11 @@ select TRANSAMOUNT, REPEATS, NUMOCCURRENCES, NEXTOCCURRENCEDATE, (case when TRANSCODE = 'Deposit' then TRANSAMOUNT else -TRANSAMOUNT end) as TRANSAMOUNT from CHECKINGACCOUNT_V1) as t where t.CATEGID = a.CATEGID - and t.STATUS <> 'V' AND t.TRANSDATE>=date('now','start of year')) as Balance + and t.STATUS NOT IN ('D', 'V') AND t.TRANSDATE>=date('now','start of year')) as Balance from (select CATEGID, STATUS, REPEATS, NUMOCCURRENCES, NEXTOCCURRENCEDATE, (case when TRANSCODE = 'Deposit' then TRANSAMOUNT else -TRANSAMOUNT end) as TRANSAMOUNT from BILLSDEPOSITS_V1) as b inner join CATEGORY_V1 as a on b.CATEGID = a.CATEGID where a.CATEGNAME = 'Donations' -and b.STATUS <> 'V'; \ No newline at end of file +and b.STATUS NOT IN ('D', 'V'); \ No newline at end of file diff --git a/CategoryTrend/sqlcontent.sql b/CategoryTrend/sqlcontent.sql index 4e3eeed..ba8728b 100644 --- a/CategoryTrend/sqlcontent.sql +++ b/CategoryTrend/sqlcontent.sql @@ -4,12 +4,12 @@ select strftime('%Y', TRANSDATE) as YEAR , total((case when TRANSCODE = 'Deposit' then TRANSAMOUNT else -TRANSAMOUNT end) * c1.BASECONVRATE) as AMOUNT from (select ACCOUNTID, TRANSDATE, TRANSCODE, CATEGID, SUBCATEGID, TRANSAMOUNT from CHECKINGACCOUNT_V1 - where STATUS <> 'V' + where STATUS NOT IN ('D', 'V') union all select t1.ACCOUNTID, t1.TRANSDATE, t1.TRANSCODE, t2.CATEGID, t2.SUBCATEGID, t2.SPLITTRANSAMOUNT from SPLITTRANSACTIONS_V1 as t2 inner join CHECKINGACCOUNT_V1 as t1 on t1.TRANSID = t2.TRANSID - where t1.STATUS <> 'V') as t3 + where t1.STATUS NOT IN ('D', 'V')) as t3 inner join ACCOUNTLIST_V1 as a1 on a1.ACCOUNTID = t3.ACCOUNTID inner join CURRENCYFORMATS_V1 as c1 on c1.CURRENCYID = a1.CURRENCYID inner join CATEGORY_V1 as cat on t3.CATEGID = cat.CATEGID diff --git a/DepositVsExpensesAndLoanRepaymentByMonth/sqlcontent.sql b/DepositVsExpensesAndLoanRepaymentByMonth/sqlcontent.sql index d701ef0..287b8ec 100644 --- a/DepositVsExpensesAndLoanRepaymentByMonth/sqlcontent.sql +++ b/DepositVsExpensesAndLoanRepaymentByMonth/sqlcontent.sql @@ -27,7 +27,7 @@ SELECT 'month' AS periode_name, ) THEN ca.transamount ELSE 0 END AS Transfer FROM checkingaccount_V1 AS ca - WHERE ca.status NOT IN ('V', 'D')-- and TRANSDATE > date('now', 'start of month','-5 year','localtime') + WHERE ca.STATUS NOT IN ('D', 'V')-- and TRANSDATE > date('now', 'start of month','-5 year','localtime') ) AS cadata GROUP BY periode diff --git a/PayeeTrend/sqlcontent.sql b/PayeeTrend/sqlcontent.sql index 343fc7b..2a55e06 100644 --- a/PayeeTrend/sqlcontent.sql +++ b/PayeeTrend/sqlcontent.sql @@ -18,6 +18,6 @@ inner join CURRENCYFORMATS_V1 as c on c.CURRENCYID = a.CURRENCYID inner join PAYEE_V1 as p on t.PAYEEID = p.PAYEEID where p.PAYEENAME = 'Payee1' and t.TRANSCODE='Withdrawal' - and t.STATUS <> 'V' + and t.STATUS NOT IN ('D', 'V') group by year order by year desc; diff --git a/SavingsProgress/sqlcontent.sql b/SavingsProgress/sqlcontent.sql index f90f5c5..7dbcf9f 100644 --- a/SavingsProgress/sqlcontent.sql +++ b/SavingsProgress/sqlcontent.sql @@ -24,7 +24,7 @@ select a.ACCOUNTNAME, from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer' and TRANSDATE < date('now', 'start of month', '-12 month') ) as t - where t.ACCOUNTID = a.ACCOUNTID and t.STATUS <> 'V' + where t.ACCOUNTID = a.ACCOUNTID and t.STATUS NOT IN ('D', 'V') ) * (select BASECONVRATE from CURRENCYFORMATS_V1 where CURRENCYID = a.CURRENCYID) as Balance12ago, (select a.INITIALBAL + total(t.TRANSAMOUNT) @@ -38,7 +38,7 @@ select a.ACCOUNTNAME, from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer' and TRANSDATE < date('now', 'start of month', '-11 month') ) as t - where t.ACCOUNTID = a.ACCOUNTID and t.STATUS <> 'V' + where t.ACCOUNTID = a.ACCOUNTID and t.STATUS NOT IN ('D', 'V') ) * (select BASECONVRATE from CURRENCYFORMATS_V1 where CURRENCYID = a.CURRENCYID) as Balance11ago, (select a.INITIALBAL + total(t.TRANSAMOUNT) @@ -52,7 +52,7 @@ select a.ACCOUNTNAME, from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer' and TRANSDATE < date('now', 'start of month', '-10 month') ) as t - where t.ACCOUNTID = a.ACCOUNTID and t.STATUS <> 'V' + where t.ACCOUNTID = a.ACCOUNTID and t.STATUS NOT IN ('D', 'V') ) * (select BASECONVRATE from CURRENCYFORMATS_V1 where CURRENCYID = a.CURRENCYID) as Balance10ago, (select a.INITIALBAL + total(t.TRANSAMOUNT) @@ -66,7 +66,7 @@ select a.ACCOUNTNAME, from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer' and TRANSDATE < date('now', 'start of month', '-9 month') ) as t - where t.ACCOUNTID = a.ACCOUNTID and t.STATUS <> 'V' + where t.ACCOUNTID = a.ACCOUNTID and t.STATUS NOT IN ('D', 'V') ) * (select BASECONVRATE from CURRENCYFORMATS_V1 where CURRENCYID = a.CURRENCYID) as Balance9ago, (select a.INITIALBAL + total(t.TRANSAMOUNT) @@ -80,7 +80,7 @@ select a.ACCOUNTNAME, from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer' and TRANSDATE < date('now', 'start of month', '-8 month') ) as t - where t.ACCOUNTID = a.ACCOUNTID and t.STATUS <> 'V' + where t.ACCOUNTID = a.ACCOUNTID and t.STATUS NOT IN ('D', 'V') ) * (select BASECONVRATE from CURRENCYFORMATS_V1 where CURRENCYID = a.CURRENCYID) as Balance8ago, (select a.INITIALBAL + total(t.TRANSAMOUNT) @@ -94,7 +94,7 @@ select a.ACCOUNTNAME, from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer' and TRANSDATE < date('now', 'start of month', '-7 month') ) as t - where t.ACCOUNTID = a.ACCOUNTID and t.STATUS <> 'V' + where t.ACCOUNTID = a.ACCOUNTID and t.STATUS NOT IN ('D', 'V') ) * (select BASECONVRATE from CURRENCYFORMATS_V1 where CURRENCYID = a.CURRENCYID) as Balance7ago, (select a.INITIALBAL + total(t.TRANSAMOUNT) @@ -108,7 +108,7 @@ select a.ACCOUNTNAME, from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer' and TRANSDATE < date('now', 'start of month', '-6 month') ) as t - where t.ACCOUNTID = a.ACCOUNTID and t.STATUS <> 'V' + where t.ACCOUNTID = a.ACCOUNTID and t.STATUS NOT IN ('D', 'V') ) * (select BASECONVRATE from CURRENCYFORMATS_V1 where CURRENCYID = a.CURRENCYID) as Balance6ago, (select a.INITIALBAL + total(t.TRANSAMOUNT) @@ -122,7 +122,7 @@ select a.ACCOUNTNAME, from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer' and TRANSDATE < date('now', 'start of month', '-5 month') ) as t - where t.ACCOUNTID = a.ACCOUNTID and t.STATUS <> 'V' + where t.ACCOUNTID = a.ACCOUNTID and t.STATUS NOT IN ('D', 'V') ) * (select BASECONVRATE from CURRENCYFORMATS_V1 where CURRENCYID = a.CURRENCYID) as Balance5ago, (select a.INITIALBAL + total(t.TRANSAMOUNT) @@ -136,7 +136,7 @@ select a.ACCOUNTNAME, from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer' and TRANSDATE < date('now', 'start of month', '-4 month') ) as t - where t.ACCOUNTID = a.ACCOUNTID and t.STATUS <> 'V' + where t.ACCOUNTID = a.ACCOUNTID and t.STATUS NOT IN ('D', 'V') ) * (select BASECONVRATE from CURRENCYFORMATS_V1 where CURRENCYID = a.CURRENCYID) as Balance4ago, (select a.INITIALBAL + total(t.TRANSAMOUNT) from @@ -149,7 +149,7 @@ select a.ACCOUNTNAME, from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer' and TRANSDATE < date('now', 'start of month', '-3 month') ) as t - where t.ACCOUNTID = a.ACCOUNTID and t.STATUS <> 'V' + where t.ACCOUNTID = a.ACCOUNTID and t.STATUS NOT IN ('D', 'V') ) * (select BASECONVRATE from CURRENCYFORMATS_V1 where CURRENCYID = a.CURRENCYID) as Balance3ago, (select a.INITIALBAL + total(t.TRANSAMOUNT) @@ -163,7 +163,7 @@ select a.ACCOUNTNAME, from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer' and TRANSDATE < date('now', 'start of month', '-2 month') ) as t - where t.ACCOUNTID = a.ACCOUNTID and t.STATUS <> 'V' + where t.ACCOUNTID = a.ACCOUNTID and t.STATUS NOT IN ('D', 'V') ) * (select BASECONVRATE from CURRENCYFORMATS_V1 where CURRENCYID = a.CURRENCYID) as Balance2ago, (select a.INITIALBAL + total(t.TRANSAMOUNT) @@ -177,7 +177,7 @@ select a.ACCOUNTNAME, from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer' and TRANSDATE < date('now', 'start of month', '-1 month') ) as t - where t.ACCOUNTID = a.ACCOUNTID and t.STATUS <> 'V' + where t.ACCOUNTID = a.ACCOUNTID and t.STATUS NOT IN ('D', 'V') ) * (select BASECONVRATE from CURRENCYFORMATS_V1 where CURRENCYID = a.CURRENCYID) as Balance1ago, (select a.INITIALBAL + total(t.TRANSAMOUNT) @@ -190,7 +190,7 @@ select a.ACCOUNTNAME, from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer' ) as t - where t.ACCOUNTID = a.ACCOUNTID and t.STATUS <> 'V' + where t.ACCOUNTID = a.ACCOUNTID and t.STATUS NOT IN ('D', 'V') ) * (select BASECONVRATE from CURRENCYFORMATS_V1 where CURRENCYID = a.CURRENCYID) as BalanceNow From 2721940d0f9f7bd14cbe6050f172b320ad7d479e Mon Sep 17 00:00:00 2001 From: AO1 <44472390+andrewaimia@users.noreply.github.com> Date: Thu, 14 Mar 2019 16:22:30 +0400 Subject: [PATCH 02/49] General updates Changed so account name come from SQL and no editing of htt is needed. --- AccountForecast/description.txt | 3 +-- AccountForecast/luacontent.lua | 3 +++ AccountForecast/sqlcontent.sql | 14 +++++++------- AccountForecast/template.htt | 6 +++--- AccountTrend/description.txt | 5 ++--- AccountTrend/luacontent.lua | 12 ++++++++++-- AccountTrend/sqlcontent.sql | 8 ++++---- AccountTrend/template.htt | 8 ++++---- 8 files changed, 34 insertions(+), 25 deletions(-) diff --git a/AccountForecast/description.txt b/AccountForecast/description.txt index 24b4618..215bc1d 100644 --- a/AccountForecast/description.txt +++ b/AccountForecast/description.txt @@ -3,5 +3,4 @@ Account Forecast Report using Repeating Transactions Note: Requires at least one entry for account name in repeating transactions. TODO: -1. Update account name in SQL (line 24). -2. Update account name in Template (line 12). +1. Update account name in SQL (line 24). diff --git a/AccountForecast/luacontent.lua b/AccountForecast/luacontent.lua index 58f296c..7987bc3 100644 --- a/AccountForecast/luacontent.lua +++ b/AccountForecast/luacontent.lua @@ -6,6 +6,7 @@ local period = 6; local initialized = 0; local repeatcode = 0; local numrepeats = 0; +local accountname = ''; function is_leap_year(year) local ly = 0; @@ -143,6 +144,7 @@ function handle_record(record) total = record:get("Balance"); prefix = record:get("PFX_SYMBOL"); suffix = record:get("SFX_SYMBOL"); + accountname = record:get("ACCOUNTNAME"); for i=1,period do forecast[i] = total; end @@ -199,4 +201,5 @@ function complete(result) result:set("Month" .. i .. "_Label", string.format("(%d-%02d-%02d)",date.year,date.month,date.day)); end result:set('CHART_DATA', string.sub(data,1,-2) .. "]}]"); + result:set('ACCOUNTNAME', accountname); end diff --git a/AccountForecast/sqlcontent.sql b/AccountForecast/sqlcontent.sql index 401e5de..f42f9b9 100644 --- a/AccountForecast/sqlcontent.sql +++ b/AccountForecast/sqlcontent.sql @@ -1,4 +1,4 @@ --- TODO: Update account name in line 24. +-- TODO: Update account name in line 24. select b.TRANSAMOUNT, b.REPEATS, b.NUMOCCURRENCES, b.NEXTOCCURRENCEDATE, c.PFX_SYMBOL, c.SFX_SYMBOL, (select a.INITIALBAL + total(t.TRANSAMOUNT) from @@ -6,12 +6,12 @@ select b.TRANSAMOUNT, b.REPEATS, b.NUMOCCURRENCES, b.NEXTOCCURRENCEDATE, c.PFX_S (case when TRANSCODE = 'Deposit' then TRANSAMOUNT else -TRANSAMOUNT end) as TRANSAMOUNT from CHECKINGACCOUNT_V1 union all - select TOACCOUNTID, STATUS, TOTRANSAMOUNT + select TOACCOUNTID, STATUS, TOTRANSAMOUNT from CHECKINGACCOUNT_V1 where TRANSCODE = 'Transfer') as t where t.ACCOUNTID = a.ACCOUNTID - and t.STATUS NOT IN ('V','D')) as Balance -from + and t.STATUS NOT IN ('V','D')) as Balance, a.ACCOUNTNAME as ACCOUNTNAME +from (select ACCOUNTID, STATUS, REPEATS, NUMOCCURRENCES, NEXTOCCURRENCEDATE, (case when TRANSCODE = 'Deposit' then TRANSAMOUNT else -TRANSAMOUNT end) as TRANSAMOUNT from BILLSDEPOSITS_V1 @@ -19,7 +19,7 @@ from select TOACCOUNTID, STATUS, REPEATS, NUMOCCURRENCES, NEXTOCCURRENCEDATE, TOTRANSAMOUNT from BILLSDEPOSITS_V1 where TRANSCODE = 'Transfer') as b -inner join ACCOUNTLIST_V1 as a on b.ACCOUNTID = a.ACCOUNTID +inner join ACCOUNTLIST_V1 as a on b.ACCOUNTID = a.ACCOUNTID inner join CURRENCYFORMATS_V1 as c on c.CURRENCYID = a.CURRENCYID -where a.ACCOUNTNAME = 'Account1' -and b.STATUS NOT IN ('V','D'); +where a.ACCOUNTNAME = 'AccountName' +and b.STATUS NOT IN ('V','D'); \ No newline at end of file diff --git a/AccountForecast/template.htt b/AccountForecast/template.htt index d70adeb..773a2db 100644 --- a/AccountForecast/template.htt +++ b/AccountForecast/template.htt @@ -9,8 +9,8 @@
Report Date: