Skip to content
Permalink
Browse files

;journal: in generated-transaction:/posting: tags, add a space before…

… the value
  • Loading branch information...
simonmichael committed Oct 2, 2019
1 parent 40c089d commit 6dcddadd9f0534df89ef2fdd9e5ccf8e18901799
@@ -87,107 +87,107 @@ instance Show PeriodicTransaction where
--
-- >>> _ptgen "monthly from 2017/1 to 2017/4"
-- 2017/01/01
-- ; generated-transaction:~ monthly from 2017/1 to 2017/4
-- ; generated-transaction: ~ monthly from 2017/1 to 2017/4
-- a $1.00
-- <BLANKLINE>
-- 2017/02/01
-- ; generated-transaction:~ monthly from 2017/1 to 2017/4
-- ; generated-transaction: ~ monthly from 2017/1 to 2017/4
-- a $1.00
-- <BLANKLINE>
-- 2017/03/01
-- ; generated-transaction:~ monthly from 2017/1 to 2017/4
-- ; generated-transaction: ~ monthly from 2017/1 to 2017/4
-- a $1.00
-- <BLANKLINE>
--
-- >>> _ptgen "monthly from 2017/1 to 2017/5"
-- 2017/01/01
-- ; generated-transaction:~ monthly from 2017/1 to 2017/5
-- ; generated-transaction: ~ monthly from 2017/1 to 2017/5
-- a $1.00
-- <BLANKLINE>
-- 2017/02/01
-- ; generated-transaction:~ monthly from 2017/1 to 2017/5
-- ; generated-transaction: ~ monthly from 2017/1 to 2017/5
-- a $1.00
-- <BLANKLINE>
-- 2017/03/01
-- ; generated-transaction:~ monthly from 2017/1 to 2017/5
-- ; generated-transaction: ~ monthly from 2017/1 to 2017/5
-- a $1.00
-- <BLANKLINE>
-- 2017/04/01
-- ; generated-transaction:~ monthly from 2017/1 to 2017/5
-- ; generated-transaction: ~ monthly from 2017/1 to 2017/5
-- a $1.00
-- <BLANKLINE>
--
-- >>> _ptgen "every 2nd day of month from 2017/02 to 2017/04"
-- 2017/01/02
-- ; generated-transaction:~ every 2nd day of month from 2017/02 to 2017/04
-- ; generated-transaction: ~ every 2nd day of month from 2017/02 to 2017/04
-- a $1.00
-- <BLANKLINE>
-- 2017/02/02
-- ; generated-transaction:~ every 2nd day of month from 2017/02 to 2017/04
-- ; generated-transaction: ~ every 2nd day of month from 2017/02 to 2017/04
-- a $1.00
-- <BLANKLINE>
-- 2017/03/02
-- ; generated-transaction:~ every 2nd day of month from 2017/02 to 2017/04
-- ; generated-transaction: ~ every 2nd day of month from 2017/02 to 2017/04
-- a $1.00
-- <BLANKLINE>
--
-- >>> _ptgen "every 30th day of month from 2017/1 to 2017/5"
-- 2016/12/30
-- ; generated-transaction:~ every 30th day of month from 2017/1 to 2017/5
-- ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5
-- a $1.00
-- <BLANKLINE>
-- 2017/01/30
-- ; generated-transaction:~ every 30th day of month from 2017/1 to 2017/5
-- ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5
-- a $1.00
-- <BLANKLINE>
-- 2017/02/28
-- ; generated-transaction:~ every 30th day of month from 2017/1 to 2017/5
-- ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5
-- a $1.00
-- <BLANKLINE>
-- 2017/03/30
-- ; generated-transaction:~ every 30th day of month from 2017/1 to 2017/5
-- ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5
-- a $1.00
-- <BLANKLINE>
-- 2017/04/30
-- ; generated-transaction:~ every 30th day of month from 2017/1 to 2017/5
-- ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5
-- a $1.00
-- <BLANKLINE>
--
-- >>> _ptgen "every 2nd Thursday of month from 2017/1 to 2017/4"
-- 2016/12/08
-- ; generated-transaction:~ every 2nd Thursday of month from 2017/1 to 2017/4
-- ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4
-- a $1.00
-- <BLANKLINE>
-- 2017/01/12
-- ; generated-transaction:~ every 2nd Thursday of month from 2017/1 to 2017/4
-- ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4
-- a $1.00
-- <BLANKLINE>
-- 2017/02/09
-- ; generated-transaction:~ every 2nd Thursday of month from 2017/1 to 2017/4
-- ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4
-- a $1.00
-- <BLANKLINE>
-- 2017/03/09
-- ; generated-transaction:~ every 2nd Thursday of month from 2017/1 to 2017/4
-- ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4
-- a $1.00
-- <BLANKLINE>
--
-- >>> _ptgen "every nov 29th from 2017 to 2019"
-- 2016/11/29
-- ; generated-transaction:~ every nov 29th from 2017 to 2019
-- ; generated-transaction: ~ every nov 29th from 2017 to 2019
-- a $1.00
-- <BLANKLINE>
-- 2017/11/29
-- ; generated-transaction:~ every nov 29th from 2017 to 2019
-- ; generated-transaction: ~ every nov 29th from 2017 to 2019
-- a $1.00
-- <BLANKLINE>
-- 2018/11/29
-- ; generated-transaction:~ every nov 29th from 2017 to 2019
-- ; generated-transaction: ~ every nov 29th from 2017 to 2019
-- a $1.00
-- <BLANKLINE>
--
-- >>> _ptgen "2017/1"
-- 2017/01/01
-- ; generated-transaction:~ 2017/1
-- ; generated-transaction: ~ 2017/1
-- a $1.00
-- <BLANKLINE>
--
@@ -214,21 +214,21 @@ instance Show PeriodicTransaction where
--
-- >>> _ptgenspan "every 3 months from 2019-05" (mkdatespan "2020-02-01" "2020-03-01")
-- 2020/02/01
-- ; generated-transaction:~ every 3 months from 2019-05
-- ; generated-transaction: ~ every 3 months from 2019-05
-- a $1.00
-- <BLANKLINE>
-- >>> _ptgenspan "every 3 days from 2018" (mkdatespan "2018-01-01" "2018-01-05")
-- 2018/01/01
-- ; generated-transaction:~ every 3 days from 2018
-- ; generated-transaction: ~ every 3 days from 2018
-- a $1.00
-- <BLANKLINE>
-- 2018/01/04
-- ; generated-transaction:~ every 3 days from 2018
-- ; generated-transaction: ~ every 3 days from 2018
-- a $1.00
-- <BLANKLINE>
-- >>> _ptgenspan "every 3 days from 2018" (mkdatespan "2018-01-02" "2018-01-05")
-- 2018/01/04
-- ; generated-transaction:~ every 3 days from 2018
-- ; generated-transaction: ~ every 3 days from 2018
-- a $1.00
-- <BLANKLINE>

@@ -372,18 +372,20 @@ commentJoin c1 c2
| otherwise = c1 <> ", " <> c2

-- | Add a tag to a comment, comma-separated from any prior content.
-- A space is inserted following the colon, before the value.
commentAddTag :: Text -> Tag -> Text
commentAddTag c (t,v)
| T.null c' = tag
| otherwise = c' `commentJoin` tag
where
c' = textchomp c
tag = t <> ":" <> v
tag = t <> ": " <> v

-- | Add a tag on its own line to a comment, preserving any prior content.
-- A space is inserted following the colon, before the value.
commentAddTagNextLine :: Text -> Tag -> Text
commentAddTagNextLine cmt (t,v) =
cmt <> if "\n" `T.isSuffixOf` cmt then "" else "\n" <> t <> ":" <> v
cmt <> if "\n" `T.isSuffixOf` cmt then "" else "\n" <> t <> ": " <> v


-- tests
@@ -417,13 +419,13 @@ tests_Posting = tests "Posting" [
]

,tests "commentAddTag" [
commentAddTag "" ("a","") `is` "a:"
,commentAddTag "[1/2]" ("a","") `is` "[1/2], a:"
commentAddTag "" ("a","") `is` "a: "
,commentAddTag "[1/2]" ("a","") `is` "[1/2], a: "
]

,tests "commentAddTagNextLine" [
commentAddTagNextLine "" ("a","") `is` "\na:"
,commentAddTagNextLine "[1/2]" ("a","") `is` "[1/2]\na:"
commentAddTagNextLine "" ("a","") `is` "\na: "
,commentAddTagNextLine "[1/2]" ("a","") `is` "[1/2]\na: "
]
]

@@ -57,7 +57,7 @@ modifyTransactions tmods = map applymods
-- >>> putStr $ showTransaction $ transactionModifierToFunction (TransactionModifier "" ["pong" `post` usd 2]) nulltransaction{tpostings=["ping" `post` usd 1]}
-- 0000/01/01
-- ping $1.00
-- pong $2.00 ; generated-posting:=
-- pong $2.00 ; generated-posting: =
-- <BLANKLINE>
-- >>> putStr $ showTransaction $ transactionModifierToFunction (TransactionModifier "miss" ["pong" `post` usd 2]) nulltransaction{tpostings=["ping" `post` usd 1]}
-- 0000/01/01
@@ -66,7 +66,7 @@ modifyTransactions tmods = map applymods
-- >>> putStr $ showTransaction $ transactionModifierToFunction (TransactionModifier "ping" ["pong" `post` amount{aismultiplier=True, aquantity=3}]) nulltransaction{tpostings=["ping" `post` usd 2]}
-- 0000/01/01
-- ping $2.00
-- pong $6.00 ; generated-posting:= ping
-- pong $6.00 ; generated-posting: = ping
-- <BLANKLINE>
--
transactionModifierToFunction :: TransactionModifier -> (Transaction -> Transaction)
@@ -51,7 +51,7 @@ hledger print -b 2016-11 -e 2017-02 -f - --forecast
assets:cash

2017/01/01 * marked cleared, and with a description
; generated-transaction:~ monthly from 2016/1
; generated-transaction: ~ monthly from 2016/1
income $-1000
expenses:food $20
expenses:leisure $15
@@ -118,7 +118,7 @@ Y 2000

>>>
2000/02/01 forecast
; generated-transaction:~ 2/1
; generated-transaction: ~ 2/1

>>>2
>>>=0
@@ -135,7 +135,7 @@ Y 2000

>>>
2000/01/15 forecast
; generated-transaction:~ 15
; generated-transaction: ~ 15

>>>2
>>>=0
@@ -152,7 +152,7 @@ Y 2000

>>>
2000/02/01 forecast
; generated-transaction:~ next month
; generated-transaction: ~ next month

>>>2
>>>=0
@@ -17,9 +17,9 @@
$ hledger print -f- --auto
2016/01/01 paycheck ; modified:
income:remuneration $-100
(liabilities:tax) $-33 ; income tax, generated-posting:= ^income
(liabilities:tax) $-33 ; income tax, generated-posting: = ^income
income:donations $-15
(liabilities:tax) $-5 ; income tax, generated-posting:= ^income
(liabilities:tax) $-5 ; income tax, generated-posting: = ^income
assets:bank

2016/01/01 withdraw
@@ -82,8 +82,8 @@ $ hledger register -f- --auto
$ hledger print -f- --auto
2018/10/07 * MARKET ; modified:
expenses:groceries:food
[budget:groceries] $-20 ; generated-posting:= ^expenses:groceries
[assets:bank:checking] $20 ; generated-posting:= ^expenses:groceries
[budget:groceries] $-20 ; generated-posting: = ^expenses:groceries
[assets:bank:checking] $20 ; generated-posting: = ^expenses:groceries
assets:bank:checking $-20

>=
@@ -101,8 +101,8 @@ $ hledger print -f- --auto
$ hledger -f- print --auto -x
2018/01/01 ; modified:
(assets:billable:client1) 0.50h @ $90
assets:receivable:client1 50.00h @ $90 ; generated-posting:= assets:billable:client1
revenues:client1 $-4500 ; generated-posting:= assets:billable:client1
assets:receivable:client1 50.00h @ $90 ; generated-posting: = assets:billable:client1
revenues:client1 $-4500 ; generated-posting: = assets:billable:client1

>=

@@ -119,8 +119,8 @@ $ hledger -f- print --auto -x
$ hledger -f- print --auto -x
2018/01/01 ; modified:
(assets:billable:client1) 0.50h
assets:receivable:client1 $50 ; generated-posting:= assets:billable:client1
revenues:client1 $-50 ; generated-posting:= assets:billable:client1
assets:receivable:client1 $50 ; generated-posting: = assets:billable:client1
revenues:client1 $-50 ; generated-posting: = assets:billable:client1

>=

@@ -137,8 +137,8 @@ $ hledger -f- print --auto -x
$ hledger -f- print --auto -x
2018/01/01 ; modified:
(assets:billable:client1) 0.50h @ $90
assets:receivable:client1 0.50 "Client1 Hours" @ $100.00 ; generated-posting:= assets:billable:client1
revenues:client1 $-50.00 ; generated-posting:= assets:billable:client1
assets:receivable:client1 0.50 "Client1 Hours" @ $100.00 ; generated-posting: = assets:billable:client1
revenues:client1 $-50.00 ; generated-posting: = assets:billable:client1

>=

@@ -182,9 +182,9 @@ $ hledger print -f- --auto
$ hledger -f- print --auto
2018/01/01 ; modified:
Expenses:Joint:Widgets $100.00 @ £0.50
Expenses:Joint $-100.00 @ £0.50 ; generated-posting:= ^Expenses:Joint
Liabilities:Joint:Bob $50.00 @ £0.50 ; generated-posting:= ^Expenses:Joint
Liabilities:Joint:Bill $50.00 @ £0.50 ; generated-posting:= ^Expenses:Joint
Expenses:Joint $-100.00 @ £0.50 ; generated-posting: = ^Expenses:Joint
Liabilities:Joint:Bob $50.00 @ £0.50 ; generated-posting: = ^Expenses:Joint
Liabilities:Joint:Bill $50.00 @ £0.50 ; generated-posting: = ^Expenses:Joint
Assets:Joint:Bank £-50.00

>=0
@@ -204,9 +204,9 @@ $ hledger -f- print --auto
$ hledger -f- print --auto
2018/01/01 ; modified:
Expenses:Joint:Widgets $100.00 @@ £50
Expenses:Joint $-100.00 @@ £50 ; generated-posting:= ^Expenses:Joint
Liabilities:Joint:Bob $50.00 @@ £25 ; generated-posting:= ^Expenses:Joint
Liabilities:Joint:Bill $50.00 @@ £25 ; generated-posting:= ^Expenses:Joint
Expenses:Joint $-100.00 @@ £50 ; generated-posting: = ^Expenses:Joint
Liabilities:Joint:Bob $50.00 @@ £25 ; generated-posting: = ^Expenses:Joint
Liabilities:Joint:Bill $50.00 @@ £25 ; generated-posting: = ^Expenses:Joint
Assets:Joint:Bank £-50.00

>=0
@@ -233,9 +233,9 @@ $ hledger -f- print --auto
$ hledger -f- print --auto
2018/01/01 ; modified:
Expenses:Joint:Widgets $100.00
Expenses:Joint $-100.00 @@ £50 ; generated-posting:= ^Expenses:Joint
Liabilities:Joint:Bob $50.00 @@ £25 ; generated-posting:= ^Expenses:Joint
Liabilities:Joint:Bill $50.00 @@ £25 ; generated-posting:= ^Expenses:Joint
Expenses:Joint $-100.00 @@ £50 ; generated-posting: = ^Expenses:Joint
Liabilities:Joint:Bob $50.00 @@ £25 ; generated-posting: = ^Expenses:Joint
Liabilities:Joint:Bill $50.00 @@ £25 ; generated-posting: = ^Expenses:Joint
Assets:Joint:Bank £-50.00

>=0
@@ -264,11 +264,11 @@ $ hledger print -f- --auto --forecast -b 2016-01 -e 2016-03
assets:bank

2016/02/01 paycheck
; generated-transaction:~ monthly from 2016-01, modified:
; generated-transaction: ~ monthly from 2016-01, modified:
income:remuneration $-100
(liabilities:tax) $-33 ; income tax, generated-posting:= ^income
(liabilities:tax) $-33 ; income tax, generated-posting: = ^income
income:donations $-15
(liabilities:tax) $-5 ; income tax, generated-posting:= ^income
(liabilities:tax) $-5 ; income tax, generated-posting: = ^income
assets:bank

>=
@@ -280,7 +280,7 @@ $ hledger print -f- --forecast -b 2016-01 -e 2016-03
assets:bank

2016/02/01 paycheck
; generated-transaction:~ monthly from 2016-01
; generated-transaction: ~ monthly from 2016-01
income:remuneration $-100
income:donations $-15
assets:bank
@@ -87,7 +87,7 @@ D $1000.
>>>
2018/01/01 ; modified:
(a) €1
(b) €2 ; generated-posting:= a
(b) €2 ; generated-posting: = a

>>>=

0 comments on commit 6dcddad

Please sign in to comment.
You can’t perform that action at this time.