From 57d2f3cbbcc1dd1741e64765dc1530a0f6a44a4f Mon Sep 17 00:00:00 2001 From: wolfsolver Date: Fri, 9 Feb 2024 08:15:14 +0100 Subject: [PATCH 1/3] unify Category in both Recurring Transaction and Transaction list with neested category close issue #1558 next step: adapt edit transaction to select nested category (actually only view nested category on ammex) --- app/src/main/res/raw/query_alldata.sql | 37 ++++++++++++--------- app/src/main/res/raw/query_billdeposits.sql | 17 +++++++--- app/src/main/res/raw/query_mobiledata.sql | 25 +++++++++----- 3 files changed, 51 insertions(+), 28 deletions(-) diff --git a/app/src/main/res/raw/query_alldata.sql b/app/src/main/res/raw/query_alldata.sql index 37abe3cf39..47b56a3aa7 100644 --- a/app/src/main/res/raw/query_alldata.sql +++ b/app/src/main/res/raw/query_alldata.sql @@ -1,27 +1,34 @@ -- Account Transactions list +WITH RECURSIVE categories(categid, categname, parentid) AS + (SELECT a.categid, a.categname, a.parentid FROM category_v1 a WHERE parentid = '-1' + UNION ALL + SELECT c.categid, r.categname || ':' || c.categname, c.parentid + FROM categories r, category_v1 c + WHERE r.categid = c.parentid + ) SELECT TX.TransID AS ID, TX.TransCode AS TransactionType, date( TX.TransDate ) AS Date, d.userdate AS UserDate, - ifnull(PARENTCAT.CATEGNAME, CAT.CategName) as Category, - CAT.CategName as Subcategory, + CAT.categName AS Category, -- Wolfsolver set full category name + NULL AS Subcategory, -- Wolfsolver ignore subcategory TX.Status AS Status, TX.NOTES AS Notes, ifnull(cfTo.BaseConvRate, cf.BaseConvRate) AS BaseConvRate, - ( CASE TX.TRANSCODE WHEN 'Deposit' THEN 1 ELSE -1 END ) * TX.TransAmount as Amount, - FromAcc.CurrencyID as CurrencyID, + ( CASE TX.TRANSCODE WHEN 'Deposit' THEN 1 ELSE -1 END ) * TX.TransAmount AS Amount, + FromAcc.CurrencyID AS CurrencyID, cf.currency_symbol AS currency, - FromAcc.AccountID as AccountID, - FromAcc.AccountName as AccountName, + FromAcc.AccountID AS AccountID, + FromAcc.AccountName AS AccountName, -- Destination - ifnull(ToAcc.AccountId, FromAcc.AccountId) as ToAccountId, - ifnull(ToAcc.AccountName, FromAcc.AccountName) as ToAccountName, - TX.ToTransAmount as ToAmount, - ifnull(ToAcc.CurrencyId, FromAcc.CurrencyID) as ToCurrencyId, + ifnull(ToAcc.AccountId, FromAcc.AccountId) AS ToAccountId, + ifnull(ToAcc.AccountName, FromAcc.AccountName) AS ToAccountName, + TX.ToTransAmount AS ToAmount, + ifnull(ToAcc.CurrencyId, FromAcc.CurrencyID) AS ToCurrencyId, ( CASE ifnull( TX.CATEGID, -1 ) WHEN -1 THEN 1 ELSE 0 END ) AS SPLITTED, - ifnull( PARENTCAT.CategID, CAT.CategID ) AS ParentCategID, + -1 AS ParentCategID, -- Wolfsolver ignore subcategory (we use full category) TX.CATEGID AS CategID, - ifnull( CAT.CategID, -1 ) AS SubcategID, + -1 AS SubcategID, -- Wolfsolver ignore subcategory (we use full category) ifnull( PAYEE.PayeeName, '') AS Payee, ifnull( PAYEE.PayeeID, -1 ) AS PayeeID, TX.TRANSACTIONNUMBER AS TransactionNumber, @@ -30,8 +37,8 @@ SELECT TX.TransID AS ID, d.day AS Day, d.finyear AS finyear FROM CHECKINGACCOUNT_V1 TX - LEFT JOIN CATEGORY_V1 CAT ON CAT.CATEGID = TX.CATEGID - LEFT JOIN CATEGORY_V1 PARENTCAT ON PARENTCAT.CATEGID = CAT.PARENTID + LEFT JOIN categories CAT ON CAT.CATEGID = TX.CATEGID + LEFT JOIN categories PARENTCAT ON PARENTCAT.CATEGID = CAT.PARENTID LEFT JOIN PAYEE_V1 PAYEE ON PAYEE.PAYEEID = TX.PAYEEID LEFT JOIN ACCOUNTLIST_V1 FROMACC ON FROMACC.ACCOUNTID = TX.ACCOUNTID LEFT JOIN ACCOUNTLIST_V1 TOACC ON TOACC.ACCOUNTID = TX.TOACCOUNTID @@ -49,4 +56,4 @@ FROM CHECKINGACCOUNT_V1 TX LEFT JOIN infotable_v1 fm ON fm.infoname = 'FINANCIAL_YEAR_START_MONTH' LEFT JOIN infotable_v1 fd ON fd.infoname = 'FINANCIAL_YEAR_START_DAY' ) d ON d.id = TX.TRANSID -WHERE (TX.DELETEDTIME is null or TX.DELETEDTIME = '') +WHERE (TX.DELETEDTIME IS NULL OR TX.DELETEDTIME = '') diff --git a/app/src/main/res/raw/query_billdeposits.sql b/app/src/main/res/raw/query_billdeposits.sql index e22ff06153..3403ffc89a 100644 --- a/app/src/main/res/raw/query_billdeposits.sql +++ b/app/src/main/res/raw/query_billdeposits.sql @@ -1,3 +1,10 @@ +WITH RECURSIVE categories(categid, categname, parentid) AS + (SELECT a.categid, a.categname, a.parentid FROM category_v1 a WHERE parentid = '-1' + UNION ALL + SELECT c.categid, r.categname || ':' || c.categname, c.parentid + FROM categories r, category_v1 c + WHERE r.categid = c.parentid + ) SELECT BILLSDEPOSITS_V1.BDID, BILLSDEPOSITS_V1.PAYEEID, @@ -7,9 +14,9 @@ SELECT BILLSDEPOSITS_V1.ACCOUNTID, ACCOUNTLIST_V1.ACCOUNTNAME, ACCOUNTLIST_V1.CURRENCYID, - ifnull(CATEGORY_V1.CATEGNAME, '') || ifnull(' : ' || PARENTCAT.CATEGNAME, '') AS CATEGSUBCATEGNAME, - CATEGORY_V1.CATEGNAME AS SUBCATEGNAME, - COALESCE(PARENTCAT.CATEGNAME, CATEGORY_V1.CATEGNAME) AS CATEGNAME, + NULL AS CATEGSUBCATEGNAME, + NULL AS SUBCATEGNAME, + categories.CATEGNAME AS CATEGNAME, BILLSDEPOSITS_V1.TRANSCODE, BILLSDEPOSITS_V1.TRANSAMOUNT, BILLSDEPOSITS_V1.NEXTOCCURRENCEDATE, @@ -27,7 +34,7 @@ SELECT date( BILLSDEPOSITS_V1.NEXTOCCURRENCEDATE ) ) AS USERNEXTOCCURRENCEDATE FROM BILLSDEPOSITS_V1 LEFT OUTER JOIN PAYEE_V1 ON BILLSDEPOSITS_V1.PAYEEID = PAYEE_V1.PAYEEID LEFT OUTER JOIN ACCOUNTLIST_V1 TOACCOUNT ON BILLSDEPOSITS_V1.TOACCOUNTID = TOACCOUNT.ACCOUNTID - LEFT OUTER JOIN CATEGORY_V1 ON BILLSDEPOSITS_V1.CATEGID = CATEGORY_V1.CATEGID - LEFT JOIN CATEGORY_V1 PARENTCAT ON PARENTCAT.CATEGID = CATEGORY_V1.PARENTID + LEFT OUTER JOIN categories ON BILLSDEPOSITS_V1.CATEGID = categories.CATEGID + -- LEFT JOIN CATEGORY_V1 PARENTCAT ON PARENTCAT.CATEGID = CATEGORY_V1.PARENTID LEFT OUTER JOIN INFOTABLE_V1 DF ON DF.INFONAME = 'DATEFORMAT', ACCOUNTLIST_V1 WHERE BILLSDEPOSITS_V1.ACCOUNTID = ACCOUNTLIST_V1.ACCOUNTID diff --git a/app/src/main/res/raw/query_mobiledata.sql b/app/src/main/res/raw/query_mobiledata.sql index e7517314cd..d01c82f315 100644 --- a/app/src/main/res/raw/query_mobiledata.sql +++ b/app/src/main/res/raw/query_mobiledata.sql @@ -1,12 +1,20 @@ /* Query mobiledata. This is the base for most other queries. */ +WITH RECURSIVE categories(categid, categname, catshortname, parentid, parentcategname ) AS + (SELECT a.categid, a.categname, a.categname AS catshortname, a.parentid, NULL AS parentcategname FROM category_v1 a WHERE parentid = '-1' + UNION ALL + SELECT c.categid, r.categname || ':' || c.categname, c.CATEGNAME AS catshortname, c.parentid, r.categname AS parentcategname + FROM categories r, category_v1 c + WHERE r.categid = c.parentid + ) SELECT TX.TransID AS ID, TX.TransCode AS TransactionType, date( TX.TransDate ) AS Date, d.userdate AS UserDate, - coalesce( SPARENTCAT.CategName, PARENTCAT.CategName, SCAT.CategName, CAT.CategName, '' ) AS Category, - coalesce( SCAT.CategName, CAT.CategName, '' ) AS Subcategory, + COALESCE( SCAT.categname, CAT.categname ) AS CategoryFullName, + COALESCE( SCAT.parentcategname, SCAT.catshortname, CAT.parentcategname, CAT.catshortname ) AS Category, + COALESCE( SCAT.catshortname, CAT.catshortname ) AS Subcategory, cf.currency_symbol AS currency, TX.Status AS Status, TX.NOTES AS Notes, @@ -22,7 +30,7 @@ SELECT TX.TransID AS ID, ifnull( TOACC.CURRENCYID, -1 ) AS ToCurrencyID, ( CASE ifnull( TX.CATEGID, -1 ) WHEN -1 THEN 1 ELSE 0 END ) AS SPLITTED, coalesce( SPARENTCAT.CATEGID, PARENTCAT.CATEGID, st.CategId, TX.CategId ) AS CATEGID, - ifnull( ifnull(st.CategID, TX.CategId ) , -1 ) AS SubcategID, + -1 AS SubcategID, ifnull( PAYEE.PayeeName, '') AS Payee, ifnull( PAYEE.PayeeID, -1 ) AS PayeeID, TX.TRANSACTIONNUMBER AS TransactionNumber, @@ -33,16 +41,17 @@ SELECT TX.TransID AS ID, ROUND( ( CASE TX.TRANSCODE WHEN 'Deposit' THEN 1 ELSE -1 END ) * ( CASE TX.CATEGID WHEN -1 THEN st.splittransamount ELSE TX.TRANSAMOUNT END) , 2 ) * ifnull(cfTo.BaseConvRate, 1) As AmountBaseConvRate FROM CHECKINGACCOUNT_V1 TX - LEFT JOIN CATEGORY_V1 CAT ON CAT.CATEGID = TX.CATEGID - LEFT JOIN CATEGORY_V1 PARENTCAT ON PARENTCAT.CATEGID = CAT.PARENTID + LEFT JOIN categories CAT ON CAT.CATEGID = TX.CATEGID +-- LEFT JOIN categories PARENTCAT ON PARENTCAT.CATEGID = CAT.PARENTID + LEFT JOIN categories PARENTCAT ON PARENTCAT.CATEGID = CAT.CATEGID LEFT JOIN PAYEE_V1 PAYEE ON PAYEE.PAYEEID = TX.PAYEEID LEFT JOIN ACCOUNTLIST_V1 FROMACC ON FROMACC.ACCOUNTID = TX.ACCOUNTID LEFT JOIN ACCOUNTLIST_V1 TOACC ON TOACC.ACCOUNTID = TX.TOACCOUNTID LEFT JOIN currencyformats_v1 cf ON cf.currencyid = FROMACC.currencyid LEFT JOIN currencyformats_v1 cfTo ON cfTo.currencyid = TOACC.currencyid LEFT JOIN splittransactions_v1 st ON TX.transid = st.transid - LEFT JOIN CATEGORY_V1 SCAT ON SCAT.CATEGID = st.CATEGID AND TX.TransId = st.transid - LEFT JOIN CATEGORY_V1 SPARENTCAT ON SPARENTCAT.CATEGID = SCAT.PARENTID + LEFT JOIN categories SCAT ON SCAT.CATEGID = st.CATEGID AND TX.TransId = st.transid + LEFT JOIN categories SPARENTCAT ON SPARENTCAT.CATEGID = SCAT.CATEGID LEFT JOIN ( SELECT transid AS id, date( transdate ) AS transdate, @@ -55,4 +64,4 @@ FROM CHECKINGACCOUNT_V1 TX LEFT JOIN infotable_v1 fm ON fm.infoname = 'FINANCIAL_YEAR_START_MONTH' LEFT JOIN infotable_v1 fd ON fd.infoname = 'FINANCIAL_YEAR_START_DAY' ) d ON d.id = TX.TRANSID -WHERE (TX.DELETEDTIME is null or TX.DELETEDTIME = '') +WHERE (TX.DELETEDTIME IS NULL OR TX.DELETEDTIME = '') \ No newline at end of file From f607fcf41d9219b6f210ece8aab36fded1768d7c Mon Sep 17 00:00:00 2001 From: wolfsolver Date: Fri, 9 Feb 2024 20:29:28 +0100 Subject: [PATCH 2/3] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 459e3abb49..8ba9926623 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,10 @@ Money Manager Ex for Android is a mobile companion to PC/desktop personal financ [Get it on F-Droid](https://f-droid.org/packages/com.money.manager.ex) [Get it on GitHub](https://github.com/moneymanagerex/android-money-manager-ex/releases/latest) +#### Documentation +- [UserManual](docs/usermanual/index.md) +- [neested category](doc/nestedcategory.md) + #### Contributing From 3b6d231176d7dc6df7083c4d89e0a7abb56d72c2 Mon Sep 17 00:00:00 2001 From: wolfsolver Date: Fri, 9 Feb 2024 20:30:36 +0100 Subject: [PATCH 3/3] Update doc --- doc/nestedcategory.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 doc/nestedcategory.md diff --git a/doc/nestedcategory.md b/doc/nestedcategory.md new file mode 100644 index 0000000000..30706b05a1 --- /dev/null +++ b/doc/nestedcategory.md @@ -0,0 +1,3 @@ +https://github.com/moneymanagerex/android-money-manager-ex/issues/1376 + +put here documentation \ No newline at end of file