Skip to content

Commit

Permalink
Section 06 simplified using new tabular rules from hledger 1.19+
Browse files Browse the repository at this point in the history
  • Loading branch information
adept committed Sep 15, 2022
1 parent 9d1226d commit 2a9a6da
Show file tree
Hide file tree
Showing 44 changed files with 134 additions and 651 deletions.
11 changes: 1 addition & 10 deletions 06-maintaining-lots-of-csv-rules/export/export.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

-----------------------------------------------
Expand Down Expand Up @@ -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
-------------------------------------
Expand Down Expand Up @@ -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
-------------------
Expand Down
24 changes: 0 additions & 24 deletions 06-maintaining-lots-of-csv-rules/import/lloyds/generated.rules

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ date-format %d/%m/%Y
currency1 £
account2 expenses:unknown

include generated.rules
include rules.psv
13 changes: 7 additions & 6 deletions 06-maintaining-lots-of-csv-rules/import/lloyds/rules.psv
Original file line number Diff line number Diff line change
@@ -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|
30 changes: 0 additions & 30 deletions 06-maintaining-lots-of-csv-rules/import/psv-to-rules.awk

This file was deleted.

14 changes: 4 additions & 10 deletions 07-investments-easy-approach/export/export.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

-----------------------------------------------
Expand Down Expand Up @@ -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

-------------------------------------
Expand Down Expand Up @@ -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)
Expand Down
24 changes: 0 additions & 24 deletions 07-investments-easy-approach/import/lloyds/generated.rules

This file was deleted.

2 changes: 1 addition & 1 deletion 07-investments-easy-approach/import/lloyds/lloyds.rules
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ date-format %d/%m/%Y
currency1 £
account2 expenses:unknown

include generated.rules
include rules.psv
13 changes: 7 additions & 6 deletions 07-investments-easy-approach/import/lloyds/rules.psv
Original file line number Diff line number Diff line change
@@ -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|
30 changes: 0 additions & 30 deletions 07-investments-easy-approach/import/psv-to-rules.awk

This file was deleted.

14 changes: 4 additions & 10 deletions 08-mortgage/export/export.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

-----------------------------------------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
28 changes: 0 additions & 28 deletions 08-mortgage/import/lloyds/generated.rules

This file was deleted.

2 changes: 1 addition & 1 deletion 08-mortgage/import/lloyds/lloyds.rules
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ date-format %d/%m/%Y
currency1 £
account2 expenses:unknown

include generated.rules
include rules.psv
15 changes: 8 additions & 7 deletions 08-mortgage/import/lloyds/rules.psv
Original file line number Diff line number Diff line change
@@ -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|
30 changes: 0 additions & 30 deletions 08-mortgage/import/psv-to-rules.awk

This file was deleted.

14 changes: 4 additions & 10 deletions 09-remortgage/export/export.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

-----------------------------------------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
28 changes: 0 additions & 28 deletions 09-remortgage/import/lloyds/generated.rules

This file was deleted.

Loading

0 comments on commit 2a9a6da

Please sign in to comment.