From 2a9a6daeda345052f2cb907bd7ef4ce2fb24f9dc Mon Sep 17 00:00:00 2001 From: Dmitry Astapov Date: Fri, 16 Sep 2022 00:26:13 +0100 Subject: [PATCH] Section 06 simplified using new tabular rules from hledger 1.19+ --- .../export/export.hs | 11 +-- .../import/lloyds/generated.rules | 24 ------ .../import/lloyds/lloyds.rules | 2 +- .../import/lloyds/rules.psv | 13 ++-- .../import/psv-to-rules.awk | 30 -------- 07-investments-easy-approach/export/export.hs | 14 +--- .../import/lloyds/generated.rules | 24 ------ .../import/lloyds/lloyds.rules | 2 +- .../import/lloyds/rules.psv | 13 ++-- .../import/psv-to-rules.awk | 30 -------- 08-mortgage/export/export.hs | 14 +--- 08-mortgage/import/lloyds/generated.rules | 28 ------- 08-mortgage/import/lloyds/lloyds.rules | 2 +- 08-mortgage/import/lloyds/rules.psv | 15 ++-- 08-mortgage/import/psv-to-rules.awk | 30 -------- 09-remortgage/export/export.hs | 14 +--- 09-remortgage/import/lloyds/generated.rules | 28 ------- 09-remortgage/import/lloyds/lloyds.rules | 2 +- 09-remortgage/import/lloyds/rules.psv | 15 ++-- 09-remortgage/import/psv-to-rules.awk | 30 -------- 10-foreign-currency/export/export.hs | 14 +--- .../import/lloyds/generated.rules | 33 -------- .../import/lloyds/lloyds.rules | 2 +- 10-foreign-currency/import/lloyds/rules.psv | 19 ++--- 10-foreign-currency/import/psv-to-rules.awk | 30 -------- 11-sorting-unknowns/export/export.hs | 14 +--- .../import/lloyds/generated.rules | 39 ---------- .../import/lloyds/lloyds.rules | 2 +- 11-sorting-unknowns/import/lloyds/rules.psv | 19 ++--- 11-sorting-unknowns/import/psv-to-rules.awk | 30 -------- 11-sorting-unknowns/resolve.sh | 2 +- 12-file-specific-rules/export/export.hs | 14 +--- .../import/lloyds/generated.rules | 39 ---------- .../import/lloyds/lloyds.rules | 2 +- .../import/lloyds/rules.psv | 19 ++--- .../import/psv-to-rules.awk | 30 -------- 12-file-specific-rules/resolve.sh | 2 +- diffs/05-to-06.diff | 76 +++---------------- diffs/06-to-07.diff | 15 ++-- diffs/07-to-08.diff | 14 ++-- diffs/09-to-10.diff | 14 ++-- diffs/10-to-11.diff | 10 +-- diffs/11-to-12.diff | 4 +- filterdiff.sh | 1 - 44 files changed, 134 insertions(+), 651 deletions(-) delete mode 100644 06-maintaining-lots-of-csv-rules/import/lloyds/generated.rules delete mode 100644 06-maintaining-lots-of-csv-rules/import/psv-to-rules.awk delete mode 100644 07-investments-easy-approach/import/lloyds/generated.rules delete mode 100644 07-investments-easy-approach/import/psv-to-rules.awk delete mode 100644 08-mortgage/import/lloyds/generated.rules delete mode 100644 08-mortgage/import/psv-to-rules.awk delete mode 100644 09-remortgage/import/lloyds/generated.rules delete mode 100644 09-remortgage/import/psv-to-rules.awk delete mode 100644 10-foreign-currency/import/lloyds/generated.rules delete mode 100644 10-foreign-currency/import/psv-to-rules.awk delete mode 100644 11-sorting-unknowns/import/lloyds/generated.rules delete mode 100644 11-sorting-unknowns/import/psv-to-rules.awk delete mode 100644 12-file-specific-rules/import/lloyds/generated.rules delete mode 100644 12-file-specific-rules/import/psv-to-rules.awk diff --git a/06-maintaining-lots-of-csv-rules/export/export.hs b/06-maintaining-lots-of-csv-rules/export/export.hs index 5751ffa..f917931 100755 --- a/06-maintaining-lots-of-csv-rules/export/export.hs +++ b/06-maintaining-lots-of-csv-rules/export/export.hs @@ -62,7 +62,7 @@ reports first current = -- Extra dependencies of the import files ----------------------------------------- extraDeps file - | "//lloyds//*.journal" ?== file = ["lloyds.rules", "generated.rules"] + | "//lloyds//*.journal" ?== file = ["lloyds.rules", "rules.psv"] | otherwise = [] ----------------------------------------------- @@ -133,9 +133,6 @@ export_all flags targets = return $ Just $ do -- Enumerate directories with auto-generated journals [ "//import/lloyds/journal/*.journal" ] |%> csv2journal - -- Whenever we need generated.rules, produce them from rules.psv - "//import//generated.rules" %> generated_rules - ------------------------------------- -- Implementations of the build rules ------------------------------------- @@ -191,12 +188,6 @@ csv2journal out = do (Stdout output) <- cmd (Cwd source_dir) Shell "./csv2journal" [makeRelative source_dir input] writeFileChanged out output -generated_rules out = do - let (dir, file) = splitFileName out - need [ dir "rules.psv", dir ".." "psv-to-rules.awk" ] - (Stdout output) <- cmd (Cwd dir) "awk" ["-F", "|", "-f", "../psv-to-rules.awk", "rules.psv"] - writeFileChanged out output - ------------------- -- Helper functions ------------------- diff --git a/06-maintaining-lots-of-csv-rules/import/lloyds/generated.rules b/06-maintaining-lots-of-csv-rules/import/lloyds/generated.rules deleted file mode 100644 index 160bc07..0000000 --- a/06-maintaining-lots-of-csv-rules/import/lloyds/generated.rules +++ /dev/null @@ -1,24 +0,0 @@ - -if -INTEREST - account2 income:interest - -if -EMPLOYER INC - account2 income:employer - -if -WAITROSE - account2 expenses:groceries - -if -AVIVA - account2 assets:pension:aviva - -if -TRANSFER - account2 assets:Lloyds:transfers - -if -OASIS COFFEE - account2 expenses:coffee diff --git a/06-maintaining-lots-of-csv-rules/import/lloyds/lloyds.rules b/06-maintaining-lots-of-csv-rules/import/lloyds/lloyds.rules index b10e874..b752d98 100644 --- a/06-maintaining-lots-of-csv-rules/import/lloyds/lloyds.rules +++ b/06-maintaining-lots-of-csv-rules/import/lloyds/lloyds.rules @@ -5,4 +5,4 @@ date-format %d/%m/%Y currency1 £ account2 expenses:unknown -include generated.rules +include rules.psv diff --git a/06-maintaining-lots-of-csv-rules/import/lloyds/rules.psv b/06-maintaining-lots-of-csv-rules/import/lloyds/rules.psv index e5f17ed..03aa18b 100644 --- a/06-maintaining-lots-of-csv-rules/import/lloyds/rules.psv +++ b/06-maintaining-lots-of-csv-rules/import/lloyds/rules.psv @@ -1,6 +1,7 @@ -INTEREST|income:interest -EMPLOYER INC|income:employer -TRANSFER|assets:Lloyds:transfers -WAITROSE|expenses:groceries -OASIS COFFEE|expenses:coffee -AVIVA|assets:pension:aviva +if|account2|comment +INTEREST|income:interest| +EMPLOYER INC|income:employer| +TRANSFER|assets:Lloyds:transfers| +WAITROSE|expenses:groceries| +OASIS COFFEE|expenses:coffee| +AVIVA|assets:pension:aviva| diff --git a/06-maintaining-lots-of-csv-rules/import/psv-to-rules.awk b/06-maintaining-lots-of-csv-rules/import/psv-to-rules.awk deleted file mode 100644 index 0dd24ec..0000000 --- a/06-maintaining-lots-of-csv-rules/import/psv-to-rules.awk +++ /dev/null @@ -1,30 +0,0 @@ -# Read pipe-separated file of "regex|account|comment" lines, -# collate regexps together by (account,comment) and print result -# as a file of hledger rules: -# -# if -# regex1 -# regex2 -# ... -# regexN -# account2 -# comment -# -function add_regex(account,comment,rex){ - if(regexs[account,comment]=="") { - regexs[account,comment]=rex - } else { - regexs[account,comment]=regexs[account,comment] "\n" rex - } -} -/^[^# ]/{add_regex($2,$3,$1)} -END { - for(key in regexs) { - split(key,parts,/\034/); - account=parts[1]; - comment=parts[2]; - print "\nif\n" regexs[key]; - if (account!="") {print " account2 " account} - if (comment!="") {print " comment " comment} - } -} diff --git a/07-investments-easy-approach/export/export.hs b/07-investments-easy-approach/export/export.hs index 7772392..6d1e7dd 100755 --- a/07-investments-easy-approach/export/export.hs +++ b/07-investments-easy-approach/export/export.hs @@ -69,7 +69,7 @@ reports first current = -- Extra dependencies of the import files ----------------------------------------- extraDeps file - | "//lloyds//*.journal" ?== file = ["lloyds.rules", "generated.rules"] + | "//lloyds//*.journal" ?== file = ["lloyds.rules", "rules.psv"] | otherwise = [] ----------------------------------------------- @@ -140,9 +140,6 @@ export_all flags targets = return $ Just $ do -- Enumerate directories with auto-generated journals [ "//import/lloyds/journal/*.journal" ] |%> csv2journal - -- Whenever we need generated.rules, produce them from rules.psv - "//import//generated.rules" %> generated_rules - ("//" ++ investments) %> generate_investments_report current year_inputs ------------------------------------- @@ -200,12 +197,9 @@ csv2journal out = do (Stdout output) <- cmd (Cwd source_dir) Shell "./csv2journal" [makeRelative source_dir input] writeFileChanged out output -generated_rules out = do - let (dir, file) = splitFileName out - need [ dir "rules.psv", dir ".." "psv-to-rules.awk" ] - (Stdout output) <- cmd (Cwd dir) "awk" ["-F", "|", "-f", "../psv-to-rules.awk", "rules.psv"] - writeFileChanged out output - +------------------- +-- Helper functions +------------------- generate_investments_report current year_inputs out = do deps <- mapM (year_inputs . show) (investment_years current) need (concat deps) diff --git a/07-investments-easy-approach/import/lloyds/generated.rules b/07-investments-easy-approach/import/lloyds/generated.rules deleted file mode 100644 index 160bc07..0000000 --- a/07-investments-easy-approach/import/lloyds/generated.rules +++ /dev/null @@ -1,24 +0,0 @@ - -if -INTEREST - account2 income:interest - -if -EMPLOYER INC - account2 income:employer - -if -WAITROSE - account2 expenses:groceries - -if -AVIVA - account2 assets:pension:aviva - -if -TRANSFER - account2 assets:Lloyds:transfers - -if -OASIS COFFEE - account2 expenses:coffee diff --git a/07-investments-easy-approach/import/lloyds/lloyds.rules b/07-investments-easy-approach/import/lloyds/lloyds.rules index b10e874..b752d98 100644 --- a/07-investments-easy-approach/import/lloyds/lloyds.rules +++ b/07-investments-easy-approach/import/lloyds/lloyds.rules @@ -5,4 +5,4 @@ date-format %d/%m/%Y currency1 £ account2 expenses:unknown -include generated.rules +include rules.psv diff --git a/07-investments-easy-approach/import/lloyds/rules.psv b/07-investments-easy-approach/import/lloyds/rules.psv index e5f17ed..03aa18b 100644 --- a/07-investments-easy-approach/import/lloyds/rules.psv +++ b/07-investments-easy-approach/import/lloyds/rules.psv @@ -1,6 +1,7 @@ -INTEREST|income:interest -EMPLOYER INC|income:employer -TRANSFER|assets:Lloyds:transfers -WAITROSE|expenses:groceries -OASIS COFFEE|expenses:coffee -AVIVA|assets:pension:aviva +if|account2|comment +INTEREST|income:interest| +EMPLOYER INC|income:employer| +TRANSFER|assets:Lloyds:transfers| +WAITROSE|expenses:groceries| +OASIS COFFEE|expenses:coffee| +AVIVA|assets:pension:aviva| diff --git a/07-investments-easy-approach/import/psv-to-rules.awk b/07-investments-easy-approach/import/psv-to-rules.awk deleted file mode 100644 index 0dd24ec..0000000 --- a/07-investments-easy-approach/import/psv-to-rules.awk +++ /dev/null @@ -1,30 +0,0 @@ -# Read pipe-separated file of "regex|account|comment" lines, -# collate regexps together by (account,comment) and print result -# as a file of hledger rules: -# -# if -# regex1 -# regex2 -# ... -# regexN -# account2 -# comment -# -function add_regex(account,comment,rex){ - if(regexs[account,comment]=="") { - regexs[account,comment]=rex - } else { - regexs[account,comment]=regexs[account,comment] "\n" rex - } -} -/^[^# ]/{add_regex($2,$3,$1)} -END { - for(key in regexs) { - split(key,parts,/\034/); - account=parts[1]; - comment=parts[2]; - print "\nif\n" regexs[key]; - if (account!="") {print " account2 " account} - if (comment!="") {print " comment " comment} - } -} diff --git a/08-mortgage/export/export.hs b/08-mortgage/export/export.hs index 2a243ae..50ea4d3 100755 --- a/08-mortgage/export/export.hs +++ b/08-mortgage/export/export.hs @@ -71,7 +71,7 @@ reports first current = -- Extra dependencies of the import files ----------------------------------------- extraDeps file - | "//lloyds//*.journal" ?== file = ["lloyds.rules", "generated.rules"] + | "//lloyds//*.journal" ?== file = ["lloyds.rules", "rules.psv"] | otherwise = [] ----------------------------------------------- @@ -142,9 +142,6 @@ export_all flags targets = return $ Just $ do -- Enumerate directories with auto-generated journals [ "//import/lloyds/journal/*.journal" ] |%> csv2journal - -- Whenever we need generated.rules, produce them from rules.psv - "//import//generated.rules" %> generated_rules - ("//" ++ investments) %> generate_investments_report current year_inputs -- Mortgage interest transactions @@ -205,12 +202,9 @@ csv2journal out = do (Stdout output) <- cmd (Cwd source_dir) Shell "./csv2journal" [makeRelative source_dir input] writeFileChanged out output -generated_rules out = do - let (dir, file) = splitFileName out - need [ dir "rules.psv", dir ".." "psv-to-rules.awk" ] - (Stdout output) <- cmd (Cwd dir) "awk" ["-F", "|", "-f", "../psv-to-rules.awk", "rules.psv"] - writeFileChanged out output - +------------------- +-- Helper functions +------------------- generate_investments_report current year_inputs out = do deps <- mapM (year_inputs . show) (investment_years current) need (concat deps) diff --git a/08-mortgage/import/lloyds/generated.rules b/08-mortgage/import/lloyds/generated.rules deleted file mode 100644 index 252adb6..0000000 --- a/08-mortgage/import/lloyds/generated.rules +++ /dev/null @@ -1,28 +0,0 @@ - -if -INTEREST - account2 income:interest - -if -HSBC - account2 liabilities:mortgage - -if -EMPLOYER INC - account2 income:employer - -if -WAITROSE - account2 expenses:groceries - -if -AVIVA - account2 assets:pension:aviva - -if -TRANSFER - account2 assets:Lloyds:transfers - -if -OASIS COFFEE - account2 expenses:coffee diff --git a/08-mortgage/import/lloyds/lloyds.rules b/08-mortgage/import/lloyds/lloyds.rules index b10e874..b752d98 100644 --- a/08-mortgage/import/lloyds/lloyds.rules +++ b/08-mortgage/import/lloyds/lloyds.rules @@ -5,4 +5,4 @@ date-format %d/%m/%Y currency1 £ account2 expenses:unknown -include generated.rules +include rules.psv diff --git a/08-mortgage/import/lloyds/rules.psv b/08-mortgage/import/lloyds/rules.psv index 792135b..5269ff6 100644 --- a/08-mortgage/import/lloyds/rules.psv +++ b/08-mortgage/import/lloyds/rules.psv @@ -1,7 +1,8 @@ -INTEREST|income:interest -EMPLOYER INC|income:employer -TRANSFER|assets:Lloyds:transfers -WAITROSE|expenses:groceries -OASIS COFFEE|expenses:coffee -AVIVA|assets:pension:aviva -HSBC|liabilities:mortgage +if|account2|comment +INTEREST|income:interest| +EMPLOYER INC|income:employer| +TRANSFER|assets:Lloyds:transfers| +WAITROSE|expenses:groceries| +OASIS COFFEE|expenses:coffee| +AVIVA|assets:pension:aviva| +HSBC|liabilities:mortgage| diff --git a/08-mortgage/import/psv-to-rules.awk b/08-mortgage/import/psv-to-rules.awk deleted file mode 100644 index 0dd24ec..0000000 --- a/08-mortgage/import/psv-to-rules.awk +++ /dev/null @@ -1,30 +0,0 @@ -# Read pipe-separated file of "regex|account|comment" lines, -# collate regexps together by (account,comment) and print result -# as a file of hledger rules: -# -# if -# regex1 -# regex2 -# ... -# regexN -# account2 -# comment -# -function add_regex(account,comment,rex){ - if(regexs[account,comment]=="") { - regexs[account,comment]=rex - } else { - regexs[account,comment]=regexs[account,comment] "\n" rex - } -} -/^[^# ]/{add_regex($2,$3,$1)} -END { - for(key in regexs) { - split(key,parts,/\034/); - account=parts[1]; - comment=parts[2]; - print "\nif\n" regexs[key]; - if (account!="") {print " account2 " account} - if (comment!="") {print " comment " comment} - } -} diff --git a/09-remortgage/export/export.hs b/09-remortgage/export/export.hs index 2a243ae..50ea4d3 100755 --- a/09-remortgage/export/export.hs +++ b/09-remortgage/export/export.hs @@ -71,7 +71,7 @@ reports first current = -- Extra dependencies of the import files ----------------------------------------- extraDeps file - | "//lloyds//*.journal" ?== file = ["lloyds.rules", "generated.rules"] + | "//lloyds//*.journal" ?== file = ["lloyds.rules", "rules.psv"] | otherwise = [] ----------------------------------------------- @@ -142,9 +142,6 @@ export_all flags targets = return $ Just $ do -- Enumerate directories with auto-generated journals [ "//import/lloyds/journal/*.journal" ] |%> csv2journal - -- Whenever we need generated.rules, produce them from rules.psv - "//import//generated.rules" %> generated_rules - ("//" ++ investments) %> generate_investments_report current year_inputs -- Mortgage interest transactions @@ -205,12 +202,9 @@ csv2journal out = do (Stdout output) <- cmd (Cwd source_dir) Shell "./csv2journal" [makeRelative source_dir input] writeFileChanged out output -generated_rules out = do - let (dir, file) = splitFileName out - need [ dir "rules.psv", dir ".." "psv-to-rules.awk" ] - (Stdout output) <- cmd (Cwd dir) "awk" ["-F", "|", "-f", "../psv-to-rules.awk", "rules.psv"] - writeFileChanged out output - +------------------- +-- Helper functions +------------------- generate_investments_report current year_inputs out = do deps <- mapM (year_inputs . show) (investment_years current) need (concat deps) diff --git a/09-remortgage/import/lloyds/generated.rules b/09-remortgage/import/lloyds/generated.rules deleted file mode 100644 index 252adb6..0000000 --- a/09-remortgage/import/lloyds/generated.rules +++ /dev/null @@ -1,28 +0,0 @@ - -if -INTEREST - account2 income:interest - -if -HSBC - account2 liabilities:mortgage - -if -EMPLOYER INC - account2 income:employer - -if -WAITROSE - account2 expenses:groceries - -if -AVIVA - account2 assets:pension:aviva - -if -TRANSFER - account2 assets:Lloyds:transfers - -if -OASIS COFFEE - account2 expenses:coffee diff --git a/09-remortgage/import/lloyds/lloyds.rules b/09-remortgage/import/lloyds/lloyds.rules index b10e874..b752d98 100644 --- a/09-remortgage/import/lloyds/lloyds.rules +++ b/09-remortgage/import/lloyds/lloyds.rules @@ -5,4 +5,4 @@ date-format %d/%m/%Y currency1 £ account2 expenses:unknown -include generated.rules +include rules.psv diff --git a/09-remortgage/import/lloyds/rules.psv b/09-remortgage/import/lloyds/rules.psv index 792135b..5269ff6 100644 --- a/09-remortgage/import/lloyds/rules.psv +++ b/09-remortgage/import/lloyds/rules.psv @@ -1,7 +1,8 @@ -INTEREST|income:interest -EMPLOYER INC|income:employer -TRANSFER|assets:Lloyds:transfers -WAITROSE|expenses:groceries -OASIS COFFEE|expenses:coffee -AVIVA|assets:pension:aviva -HSBC|liabilities:mortgage +if|account2|comment +INTEREST|income:interest| +EMPLOYER INC|income:employer| +TRANSFER|assets:Lloyds:transfers| +WAITROSE|expenses:groceries| +OASIS COFFEE|expenses:coffee| +AVIVA|assets:pension:aviva| +HSBC|liabilities:mortgage| diff --git a/09-remortgage/import/psv-to-rules.awk b/09-remortgage/import/psv-to-rules.awk deleted file mode 100644 index 0dd24ec..0000000 --- a/09-remortgage/import/psv-to-rules.awk +++ /dev/null @@ -1,30 +0,0 @@ -# Read pipe-separated file of "regex|account|comment" lines, -# collate regexps together by (account,comment) and print result -# as a file of hledger rules: -# -# if -# regex1 -# regex2 -# ... -# regexN -# account2 -# comment -# -function add_regex(account,comment,rex){ - if(regexs[account,comment]=="") { - regexs[account,comment]=rex - } else { - regexs[account,comment]=regexs[account,comment] "\n" rex - } -} -/^[^# ]/{add_regex($2,$3,$1)} -END { - for(key in regexs) { - split(key,parts,/\034/); - account=parts[1]; - comment=parts[2]; - print "\nif\n" regexs[key]; - if (account!="") {print " account2 " account} - if (comment!="") {print " comment " comment} - } -} diff --git a/10-foreign-currency/export/export.hs b/10-foreign-currency/export/export.hs index c57d428..70223bc 100755 --- a/10-foreign-currency/export/export.hs +++ b/10-foreign-currency/export/export.hs @@ -71,7 +71,7 @@ reports first current = -- Extra dependencies of the import files ----------------------------------------- extraDeps file - | "//lloyds//*.journal" ?== file = ["lloyds.rules", "generated.rules"] + | "//lloyds//*.journal" ?== file = ["lloyds.rules", "rules.psv"] | otherwise = [] ----------------------------------------------- @@ -142,9 +142,6 @@ export_all flags targets = return $ Just $ do -- Enumerate directories with auto-generated journals [ "//import/lloyds/journal/*.journal" ] |%> csv2journal - -- Whenever we need generated.rules, produce them from rules.psv - "//import//generated.rules" %> generated_rules - ("//" ++ investments) %> generate_investments_report current year_inputs -- Mortgage interest transactions @@ -205,12 +202,9 @@ csv2journal out = do (Stdout output) <- cmd (Cwd source_dir) Shell "./csv2journal" [makeRelative source_dir input] writeFileChanged out output -generated_rules out = do - let (dir, file) = splitFileName out - need [ dir "rules.psv", dir ".." "psv-to-rules.awk" ] - (Stdout output) <- cmd (Cwd dir) "awk" ["-F", "|", "-f", "../psv-to-rules.awk", "rules.psv"] - writeFileChanged out output - +------------------- +-- Helper functions +------------------- generate_investments_report current year_inputs out = do deps <- mapM (year_inputs . show) (investment_years current) need (concat deps) diff --git a/10-foreign-currency/import/lloyds/generated.rules b/10-foreign-currency/import/lloyds/generated.rules deleted file mode 100644 index e8c1364..0000000 --- a/10-foreign-currency/import/lloyds/generated.rules +++ /dev/null @@ -1,33 +0,0 @@ - -if -INTEREST - account2 income:interest - -if -HSBC - account2 liabilities:mortgage - -if -WIKIMEDIA -HLEDGER - account2 expenses:donations - -if -EMPLOYER INC - account2 income:employer - -if -WAITROSE - account2 expenses:groceries - -if -AVIVA - account2 assets:pension:aviva - -if -TRANSFER - account2 assets:Lloyds:transfers - -if -OASIS COFFEE - account2 expenses:coffee diff --git a/10-foreign-currency/import/lloyds/lloyds.rules b/10-foreign-currency/import/lloyds/lloyds.rules index 1d3de78..9c0e674 100644 --- a/10-foreign-currency/import/lloyds/lloyds.rules +++ b/10-foreign-currency/import/lloyds/lloyds.rules @@ -9,4 +9,4 @@ if FOREIGN CCY amount2 %sortcode @@ £%amount1-out -include generated.rules +include rules.psv diff --git a/10-foreign-currency/import/lloyds/rules.psv b/10-foreign-currency/import/lloyds/rules.psv index 0204010..0732a6a 100644 --- a/10-foreign-currency/import/lloyds/rules.psv +++ b/10-foreign-currency/import/lloyds/rules.psv @@ -1,9 +1,10 @@ -INTEREST|income:interest -EMPLOYER INC|income:employer -TRANSFER|assets:Lloyds:transfers -WAITROSE|expenses:groceries -OASIS COFFEE|expenses:coffee -AVIVA|assets:pension:aviva -HSBC|liabilities:mortgage -WIKIMEDIA|expenses:donations -HLEDGER|expenses:donations +if|account2|comment +INTEREST|income:interest| +EMPLOYER INC|income:employer| +TRANSFER|assets:Lloyds:transfers| +WAITROSE|expenses:groceries| +OASIS COFFEE|expenses:coffee| +AVIVA|assets:pension:aviva| +HSBC|liabilities:mortgage| +WIKIMEDIA|expenses:donations| +HLEDGER|expenses:donations| diff --git a/10-foreign-currency/import/psv-to-rules.awk b/10-foreign-currency/import/psv-to-rules.awk deleted file mode 100644 index 0dd24ec..0000000 --- a/10-foreign-currency/import/psv-to-rules.awk +++ /dev/null @@ -1,30 +0,0 @@ -# Read pipe-separated file of "regex|account|comment" lines, -# collate regexps together by (account,comment) and print result -# as a file of hledger rules: -# -# if -# regex1 -# regex2 -# ... -# regexN -# account2 -# comment -# -function add_regex(account,comment,rex){ - if(regexs[account,comment]=="") { - regexs[account,comment]=rex - } else { - regexs[account,comment]=regexs[account,comment] "\n" rex - } -} -/^[^# ]/{add_regex($2,$3,$1)} -END { - for(key in regexs) { - split(key,parts,/\034/); - account=parts[1]; - comment=parts[2]; - print "\nif\n" regexs[key]; - if (account!="") {print " account2 " account} - if (comment!="") {print " comment " comment} - } -} diff --git a/11-sorting-unknowns/export/export.hs b/11-sorting-unknowns/export/export.hs index c57d428..70223bc 100755 --- a/11-sorting-unknowns/export/export.hs +++ b/11-sorting-unknowns/export/export.hs @@ -71,7 +71,7 @@ reports first current = -- Extra dependencies of the import files ----------------------------------------- extraDeps file - | "//lloyds//*.journal" ?== file = ["lloyds.rules", "generated.rules"] + | "//lloyds//*.journal" ?== file = ["lloyds.rules", "rules.psv"] | otherwise = [] ----------------------------------------------- @@ -142,9 +142,6 @@ export_all flags targets = return $ Just $ do -- Enumerate directories with auto-generated journals [ "//import/lloyds/journal/*.journal" ] |%> csv2journal - -- Whenever we need generated.rules, produce them from rules.psv - "//import//generated.rules" %> generated_rules - ("//" ++ investments) %> generate_investments_report current year_inputs -- Mortgage interest transactions @@ -205,12 +202,9 @@ csv2journal out = do (Stdout output) <- cmd (Cwd source_dir) Shell "./csv2journal" [makeRelative source_dir input] writeFileChanged out output -generated_rules out = do - let (dir, file) = splitFileName out - need [ dir "rules.psv", dir ".." "psv-to-rules.awk" ] - (Stdout output) <- cmd (Cwd dir) "awk" ["-F", "|", "-f", "../psv-to-rules.awk", "rules.psv"] - writeFileChanged out output - +------------------- +-- Helper functions +------------------- generate_investments_report current year_inputs out = do deps <- mapM (year_inputs . show) (investment_years current) need (concat deps) diff --git a/11-sorting-unknowns/import/lloyds/generated.rules b/11-sorting-unknowns/import/lloyds/generated.rules deleted file mode 100644 index 6319583..0000000 --- a/11-sorting-unknowns/import/lloyds/generated.rules +++ /dev/null @@ -1,39 +0,0 @@ - -if -INTEREST - account2 income:interest - -if -HSBC - account2 liabilities:mortgage - -if -WIKIMEDIA -HLEDGER - account2 expenses:donations - -if -COSTA COFFEE - account2 expenses:coffee - comment Regular place was closed - -if -EMPLOYER INC - account2 income:employer - -if -WAITROSE -TESCO GROCERIES - account2 expenses:groceries - -if -AVIVA - account2 assets:pension:aviva - -if -TRANSFER - account2 assets:Lloyds:transfers - -if -OASIS COFFEE - account2 expenses:coffee diff --git a/11-sorting-unknowns/import/lloyds/lloyds.rules b/11-sorting-unknowns/import/lloyds/lloyds.rules index 1d3de78..9c0e674 100644 --- a/11-sorting-unknowns/import/lloyds/lloyds.rules +++ b/11-sorting-unknowns/import/lloyds/lloyds.rules @@ -9,4 +9,4 @@ if FOREIGN CCY amount2 %sortcode @@ £%amount1-out -include generated.rules +include rules.psv diff --git a/11-sorting-unknowns/import/lloyds/rules.psv b/11-sorting-unknowns/import/lloyds/rules.psv index 46db4a3..bb2288d 100644 --- a/11-sorting-unknowns/import/lloyds/rules.psv +++ b/11-sorting-unknowns/import/lloyds/rules.psv @@ -1,11 +1,12 @@ -INTEREST|income:interest -EMPLOYER INC|income:employer -TRANSFER|assets:Lloyds:transfers -WAITROSE|expenses:groceries -OASIS COFFEE|expenses:coffee -AVIVA|assets:pension:aviva -HSBC|liabilities:mortgage -WIKIMEDIA|expenses:donations -HLEDGER|expenses:donations +if|account2|comment +INTEREST|income:interest| +EMPLOYER INC|income:employer| +TRANSFER|assets:Lloyds:transfers| +WAITROSE|expenses:groceries| +OASIS COFFEE|expenses:coffee| +AVIVA|assets:pension:aviva| +HSBC|liabilities:mortgage| +WIKIMEDIA|expenses:donations| +HLEDGER|expenses:donations| COSTA COFFEE|expenses:coffee|Regular place was closed TESCO GROCERIES|expenses:groceries| diff --git a/11-sorting-unknowns/import/psv-to-rules.awk b/11-sorting-unknowns/import/psv-to-rules.awk deleted file mode 100644 index 0dd24ec..0000000 --- a/11-sorting-unknowns/import/psv-to-rules.awk +++ /dev/null @@ -1,30 +0,0 @@ -# Read pipe-separated file of "regex|account|comment" lines, -# collate regexps together by (account,comment) and print result -# as a file of hledger rules: -# -# if -# regex1 -# regex2 -# ... -# regexN -# account2 -# comment -# -function add_regex(account,comment,rex){ - if(regexs[account,comment]=="") { - regexs[account,comment]=rex - } else { - regexs[account,comment]=regexs[account,comment] "\n" rex - } -} -/^[^# ]/{add_regex($2,$3,$1)} -END { - for(key in regexs) { - split(key,parts,/\034/); - account=parts[1]; - comment=parts[2]; - print "\nif\n" regexs[key]; - if (account!="") {print " account2 " account} - if (comment!="") {print " comment " comment} - } -} diff --git a/11-sorting-unknowns/resolve.sh b/11-sorting-unknowns/resolve.sh index 438d2a6..cb00c18 100755 --- a/11-sorting-unknowns/resolve.sh +++ b/11-sorting-unknowns/resolve.sh @@ -35,7 +35,7 @@ while true ; do regexp=$(sk --header="Fine-tune regexp. Searching in ${dir}/*.rules and ${dir}/csv" \ --cmd-query="${description}" --print-cmd --ansi -i \ --bind 'ctrl-d:delete-char' \ - -c "rg -i --color=always --line-number \"{}\" $(ls ${dir}/*.rules | grep -v generated.rules | paste -s -d' ') ${dir}/rules.psv ${dir}/csv" | head -n1) + -c "rg -i --color=always --line-number \"{}\" $(ls ${dir}/*.rules | paste -s -d' ') ${dir}/rules.psv ${dir}/csv" | head -n1) # Now lets choose account account=$(cat /tmp/accounts.txt | sort -u | sk --header="Choose account") diff --git a/12-file-specific-rules/export/export.hs b/12-file-specific-rules/export/export.hs index c50c2cb..f9f92b8 100755 --- a/12-file-specific-rules/export/export.hs +++ b/12-file-specific-rules/export/export.hs @@ -74,7 +74,7 @@ extraDeps file | "//lloyds//*.journal" ?== file = let basename = takeBaseName file in - ["./rules/" ++ basename ++ ".rules", "lloyds.rules", "generated.rules"] + ["./rules/" ++ basename ++ ".rules", "lloyds.rules", "rules.psv"] | otherwise = [] ----------------------------------------------- @@ -145,9 +145,6 @@ export_all flags targets = return $ Just $ do -- Enumerate directories with auto-generated journals [ "//import/lloyds/journal/*.journal" ] |%> csv2journal - -- Whenever we need generated.rules, produce them from rules.psv - "//import//generated.rules" %> generated_rules - ("//" ++ investments) %> generate_investments_report current year_inputs -- Mortgage interest transactions @@ -208,12 +205,9 @@ csv2journal out = do (Stdout output) <- cmd (Cwd source_dir) Shell "./csv2journal" [makeRelative source_dir input] writeFileChanged out output -generated_rules out = do - let (dir, file) = splitFileName out - need [ dir "rules.psv", dir ".." "psv-to-rules.awk" ] - (Stdout output) <- cmd (Cwd dir) "awk" ["-F", "|", "-f", "../psv-to-rules.awk", "rules.psv"] - writeFileChanged out output - +------------------- +-- Helper functions +------------------- generate_investments_report current year_inputs out = do deps <- mapM (year_inputs . show) (investment_years current) need (concat deps) diff --git a/12-file-specific-rules/import/lloyds/generated.rules b/12-file-specific-rules/import/lloyds/generated.rules deleted file mode 100644 index 6319583..0000000 --- a/12-file-specific-rules/import/lloyds/generated.rules +++ /dev/null @@ -1,39 +0,0 @@ - -if -INTEREST - account2 income:interest - -if -HSBC - account2 liabilities:mortgage - -if -WIKIMEDIA -HLEDGER - account2 expenses:donations - -if -COSTA COFFEE - account2 expenses:coffee - comment Regular place was closed - -if -EMPLOYER INC - account2 income:employer - -if -WAITROSE -TESCO GROCERIES - account2 expenses:groceries - -if -AVIVA - account2 assets:pension:aviva - -if -TRANSFER - account2 assets:Lloyds:transfers - -if -OASIS COFFEE - account2 expenses:coffee diff --git a/12-file-specific-rules/import/lloyds/lloyds.rules b/12-file-specific-rules/import/lloyds/lloyds.rules index 1d3de78..9c0e674 100644 --- a/12-file-specific-rules/import/lloyds/lloyds.rules +++ b/12-file-specific-rules/import/lloyds/lloyds.rules @@ -9,4 +9,4 @@ if FOREIGN CCY amount2 %sortcode @@ £%amount1-out -include generated.rules +include rules.psv diff --git a/12-file-specific-rules/import/lloyds/rules.psv b/12-file-specific-rules/import/lloyds/rules.psv index 46db4a3..bb2288d 100644 --- a/12-file-specific-rules/import/lloyds/rules.psv +++ b/12-file-specific-rules/import/lloyds/rules.psv @@ -1,11 +1,12 @@ -INTEREST|income:interest -EMPLOYER INC|income:employer -TRANSFER|assets:Lloyds:transfers -WAITROSE|expenses:groceries -OASIS COFFEE|expenses:coffee -AVIVA|assets:pension:aviva -HSBC|liabilities:mortgage -WIKIMEDIA|expenses:donations -HLEDGER|expenses:donations +if|account2|comment +INTEREST|income:interest| +EMPLOYER INC|income:employer| +TRANSFER|assets:Lloyds:transfers| +WAITROSE|expenses:groceries| +OASIS COFFEE|expenses:coffee| +AVIVA|assets:pension:aviva| +HSBC|liabilities:mortgage| +WIKIMEDIA|expenses:donations| +HLEDGER|expenses:donations| COSTA COFFEE|expenses:coffee|Regular place was closed TESCO GROCERIES|expenses:groceries| diff --git a/12-file-specific-rules/import/psv-to-rules.awk b/12-file-specific-rules/import/psv-to-rules.awk deleted file mode 100644 index 0dd24ec..0000000 --- a/12-file-specific-rules/import/psv-to-rules.awk +++ /dev/null @@ -1,30 +0,0 @@ -# Read pipe-separated file of "regex|account|comment" lines, -# collate regexps together by (account,comment) and print result -# as a file of hledger rules: -# -# if -# regex1 -# regex2 -# ... -# regexN -# account2 -# comment -# -function add_regex(account,comment,rex){ - if(regexs[account,comment]=="") { - regexs[account,comment]=rex - } else { - regexs[account,comment]=regexs[account,comment] "\n" rex - } -} -/^[^# ]/{add_regex($2,$3,$1)} -END { - for(key in regexs) { - split(key,parts,/\034/); - account=parts[1]; - comment=parts[2]; - print "\nif\n" regexs[key]; - if (account!="") {print " account2 " account} - if (comment!="") {print " comment " comment} - } -} diff --git a/12-file-specific-rules/resolve.sh b/12-file-specific-rules/resolve.sh index 438d2a6..cb00c18 100755 --- a/12-file-specific-rules/resolve.sh +++ b/12-file-specific-rules/resolve.sh @@ -35,7 +35,7 @@ while true ; do regexp=$(sk --header="Fine-tune regexp. Searching in ${dir}/*.rules and ${dir}/csv" \ --cmd-query="${description}" --print-cmd --ansi -i \ --bind 'ctrl-d:delete-char' \ - -c "rg -i --color=always --line-number \"{}\" $(ls ${dir}/*.rules | grep -v generated.rules | paste -s -d' ') ${dir}/rules.psv ${dir}/csv" | head -n1) + -c "rg -i --color=always --line-number \"{}\" $(ls ${dir}/*.rules | paste -s -d' ') ${dir}/rules.psv ${dir}/csv" | head -n1) # Now lets choose account account=$(cat /tmp/accounts.txt | sort -u | sk --header="Choose account") diff --git a/diffs/05-to-06.diff b/diffs/05-to-06.diff index 8c916aa..02fedb8 100644 --- a/diffs/05-to-06.diff +++ b/diffs/05-to-06.diff @@ -18,33 +18,10 @@ diff -X .gitignore -Naurb ././05-creating-csv-import-rules/export/export.hs ././ ----------------------------------------- extraDeps file - | "//lloyds//*.journal" ?== file = ["lloyds.rules"] -+ | "//lloyds//*.journal" ?== file = ["lloyds.rules", "generated.rules"] ++ | "//lloyds//*.journal" ?== file = ["lloyds.rules", "rules.psv"] | otherwise = [] ----------------------------------------------- -@@ -133,6 +133,9 @@ - -- Enumerate directories with auto-generated journals - [ "//import/lloyds/journal/*.journal" ] |%> csv2journal - -+ -- Whenever we need generated.rules, produce them from rules.psv -+ "//import//generated.rules" %> generated_rules -+ - ------------------------------------- - -- Implementations of the build rules - ------------------------------------- -@@ -188,6 +191,12 @@ - (Stdout output) <- cmd (Cwd source_dir) Shell "./csv2journal" [makeRelative source_dir input] - writeFileChanged out output - -+generated_rules out = do -+ let (dir, file) = splitFileName out -+ need [ dir "rules.psv", dir ".." "psv-to-rules.awk" ] -+ (Stdout output) <- cmd (Cwd dir) "awk" ["-F", "|", "-f", "../psv-to-rules.awk", "rules.psv"] -+ writeFileChanged out output -+ - ------------------- - -- Helper functions - ------------------- diff -X .gitignore -Naurb ././05-creating-csv-import-rules/import/lloyds/lloyds.rules ././06-maintaining-lots-of-csv-rules/import/lloyds/lloyds.rules --- ././05-creating-csv-import-rules/import/lloyds/lloyds.rules +++ ././06-maintaining-lots-of-csv-rules/import/lloyds/lloyds.rules @@ -75,48 +52,15 @@ diff -X .gitignore -Naurb ././05-creating-csv-import-rules/import/lloyds/lloyds. -if -AVIVA - account2 assets:pension:aviva -+include generated.rules ++include rules.psv diff -X .gitignore -Naurb ././05-creating-csv-import-rules/import/lloyds/rules.psv ././06-maintaining-lots-of-csv-rules/import/lloyds/rules.psv --- ././05-creating-csv-import-rules/import/lloyds/rules.psv +++ ././06-maintaining-lots-of-csv-rules/import/lloyds/rules.psv -@@ -0,0 +1,6 @@ -+INTEREST|income:interest -+EMPLOYER INC|income:employer -+TRANSFER|assets:Lloyds:transfers -+WAITROSE|expenses:groceries -+OASIS COFFEE|expenses:coffee -+AVIVA|assets:pension:aviva -diff -X .gitignore -Naurb ././05-creating-csv-import-rules/import/psv-to-rules.awk ././06-maintaining-lots-of-csv-rules/import/psv-to-rules.awk ---- ././05-creating-csv-import-rules/import/psv-to-rules.awk -+++ ././06-maintaining-lots-of-csv-rules/import/psv-to-rules.awk -@@ -0,0 +1,30 @@ -+# Read pipe-separated file of "regex|account|comment" lines, -+# collate regexps together by (account,comment) and print result -+# as a file of hledger rules: -+# -+# if -+# regex1 -+# regex2 -+# ... -+# regexN -+# account2 -+# comment -+# -+function add_regex(account,comment,rex){ -+ if(regexs[account,comment]=="") { -+ regexs[account,comment]=rex -+ } else { -+ regexs[account,comment]=regexs[account,comment] "\n" rex -+ } -+} -+/^[^# ]/{add_regex($2,$3,$1)} -+END { -+ for(key in regexs) { -+ split(key,parts,/\034/); -+ account=parts[1]; -+ comment=parts[2]; -+ print "\nif\n" regexs[key]; -+ if (account!="") {print " account2 " account} -+ if (comment!="") {print " comment " comment} -+ } -+} +@@ -0,0 +1,7 @@ ++if|account2|comment ++INTEREST|income:interest| ++EMPLOYER INC|income:employer| ++TRANSFER|assets:Lloyds:transfers| ++WAITROSE|expenses:groceries| ++OASIS COFFEE|expenses:coffee| ++AVIVA|assets:pension:aviva| diff --git a/diffs/06-to-07.diff b/diffs/06-to-07.diff index 4ff534c..cd867ad 100644 --- a/diffs/06-to-07.diff +++ b/diffs/06-to-07.diff @@ -80,19 +80,21 @@ diff -X .gitignore -Naurb ././06-maintaining-lots-of-csv-rules/export/export.hs ] where all_years=[first..current] -@@ -136,6 +143,8 @@ - -- Whenever we need generated.rules, produce them from rules.psv - "//import//generated.rules" %> generated_rules +@@ -133,6 +140,8 @@ + -- Enumerate directories with auto-generated journals + [ "//import/lloyds/journal/*.journal" ] |%> csv2journal + ("//" ++ investments) %> generate_investments_report current year_inputs + ------------------------------------- -- Implementations of the build rules ------------------------------------- -@@ -197,6 +206,13 @@ - (Stdout output) <- cmd (Cwd dir) "awk" ["-F", "|", "-f", "../psv-to-rules.awk", "rules.psv"] +@@ -189,6 +198,16 @@ writeFileChanged out output + ------------------- ++-- Helper functions ++------------------- +generate_investments_report current year_inputs out = do + deps <- mapM (year_inputs . show) (investment_years current) + need (concat deps) @@ -100,9 +102,10 @@ diff -X .gitignore -Naurb ././06-maintaining-lots-of-csv-rules/export/export.hs + (Stdout output) <- cmd "./investments.sh" + writeFileChanged out output + - ------------------- ++------------------- -- Helper functions ------------------- + diff -X .gitignore -Naurb ././06-maintaining-lots-of-csv-rules/export/investments.sh ././07-investments-easy-approach/export/investments.sh --- ././06-maintaining-lots-of-csv-rules/export/investments.sh +++ ././07-investments-easy-approach/export/investments.sh diff --git a/diffs/07-to-08.diff b/diffs/07-to-08.diff index 005a60a..5864814 100644 --- a/diffs/07-to-08.diff +++ b/diffs/07-to-08.diff @@ -72,7 +72,7 @@ diff -X .gitignore -Naurb ././07-investments-easy-approach/export/export.hs ././ ] where all_years=[first..current] -@@ -145,6 +147,9 @@ +@@ -142,6 +144,9 @@ ("//" ++ investments) %> generate_investments_report current year_inputs @@ -82,7 +82,7 @@ diff -X .gitignore -Naurb ././07-investments-easy-approach/export/export.hs ././ ------------------------------------- -- Implementations of the build rules ------------------------------------- -@@ -213,6 +218,20 @@ +@@ -207,6 +212,20 @@ (Stdout output) <- cmd "./investments.sh" writeFileChanged out output @@ -119,8 +119,8 @@ diff -X .gitignore -Naurb ././07-investments-easy-approach/export/mortgage_inter diff -X .gitignore -Naurb ././07-investments-easy-approach/import/lloyds/rules.psv ././08-mortgage/import/lloyds/rules.psv --- ././07-investments-easy-approach/import/lloyds/rules.psv +++ ././08-mortgage/import/lloyds/rules.psv -@@ -4,3 +4,4 @@ - WAITROSE|expenses:groceries - OASIS COFFEE|expenses:coffee - AVIVA|assets:pension:aviva -+HSBC|liabilities:mortgage +@@ -5,3 +5,4 @@ + WAITROSE|expenses:groceries| + OASIS COFFEE|expenses:coffee| + AVIVA|assets:pension:aviva| ++HSBC|liabilities:mortgage| diff --git a/diffs/09-to-10.diff b/diffs/09-to-10.diff index e054421..c54f3d6 100644 --- a/diffs/09-to-10.diff +++ b/diffs/09-to-10.diff @@ -53,13 +53,13 @@ diff -X .gitignore -Naurb ././09-remortgage/import/lloyds/lloyds.rules ././10-fo +FOREIGN CCY + amount2 %sortcode @@ £%amount1-out + - include generated.rules + include rules.psv diff -X .gitignore -Naurb ././09-remortgage/import/lloyds/rules.psv ././10-foreign-currency/import/lloyds/rules.psv --- ././09-remortgage/import/lloyds/rules.psv +++ ././10-foreign-currency/import/lloyds/rules.psv -@@ -5,3 +5,5 @@ - OASIS COFFEE|expenses:coffee - AVIVA|assets:pension:aviva - HSBC|liabilities:mortgage -+WIKIMEDIA|expenses:donations -+HLEDGER|expenses:donations +@@ -6,3 +6,5 @@ + OASIS COFFEE|expenses:coffee| + AVIVA|assets:pension:aviva| + HSBC|liabilities:mortgage| ++WIKIMEDIA|expenses:donations| ++HLEDGER|expenses:donations| diff --git a/diffs/10-to-11.diff b/diffs/10-to-11.diff index 61fb84e..a3aee13 100644 --- a/diffs/10-to-11.diff +++ b/diffs/10-to-11.diff @@ -20,10 +20,10 @@ diff -X .gitignore -Naurb ././10-foreign-currency/import/lloyds/in/99966633_2017 diff -X .gitignore -Naurb ././10-foreign-currency/import/lloyds/rules.psv ././11-sorting-unknowns/import/lloyds/rules.psv --- ././10-foreign-currency/import/lloyds/rules.psv +++ ././11-sorting-unknowns/import/lloyds/rules.psv -@@ -7,3 +7,5 @@ - HSBC|liabilities:mortgage - WIKIMEDIA|expenses:donations - HLEDGER|expenses:donations +@@ -8,3 +8,5 @@ + HSBC|liabilities:mortgage| + WIKIMEDIA|expenses:donations| + HLEDGER|expenses:donations| +COSTA COFFEE|expenses:coffee|Regular place was closed +TESCO GROCERIES|expenses:groceries| diff -X .gitignore -Naurb ././10-foreign-currency/resolve.sh ././11-sorting-unknowns/resolve.sh @@ -67,7 +67,7 @@ diff -X .gitignore -Naurb ././10-foreign-currency/resolve.sh ././11-sorting-unkn + regexp=$(sk --header="Fine-tune regexp. Searching in ${dir}/*.rules and ${dir}/csv" \ + --cmd-query="${description}" --print-cmd --ansi -i \ + --bind 'ctrl-d:delete-char' \ -+ -c "rg -i --color=always --line-number \"{}\" $(ls ${dir}/*.rules | grep -v generated.rules | paste -s -d' ') ${dir}/rules.psv ${dir}/csv" | head -n1) ++ -c "rg -i --color=always --line-number \"{}\" $(ls ${dir}/*.rules | paste -s -d' ') ${dir}/rules.psv ${dir}/csv" | head -n1) + + # Now lets choose account + account=$(cat /tmp/accounts.txt | sort -u | sk --header="Choose account") diff --git a/diffs/11-to-12.diff b/diffs/11-to-12.diff index 65f27ae..e05b0d6 100644 --- a/diffs/11-to-12.diff +++ b/diffs/11-to-12.diff @@ -14,11 +14,11 @@ diff -X .gitignore -Naurb ././11-sorting-unknowns/export/export.hs ././12-file-s -- Extra dependencies of the import files ----------------------------------------- extraDeps file -- | "//lloyds//*.journal" ?== file = ["lloyds.rules", "generated.rules"] +- | "//lloyds//*.journal" ?== file = ["lloyds.rules", "rules.psv"] + | "//lloyds//*.journal" ?== file = + let basename = takeBaseName file + in -+ ["./rules/" ++ basename ++ ".rules", "lloyds.rules", "generated.rules"] ++ ["./rules/" ++ basename ++ ".rules", "lloyds.rules", "rules.psv"] | otherwise = [] ----------------------------------------------- diff --git a/filterdiff.sh b/filterdiff.sh index c8d4340..850575a 100755 --- a/filterdiff.sh +++ b/filterdiff.sh @@ -1,6 +1,5 @@ #!/bin/bash filterdiff -x '*/export/*.txt' -x '*/export/*.journal' \ -x '*/import/*/csv/*' -x '*/import/*/journal/*.journal' \ - -x '*/import/*/generated.rules' \ -x '*/export/export' \ --remove-timestamps