1 {-# LANGUAGE TupleSections #-}
2 {-# LANGUAGE OverloadedStrings #-}
6 import Test.Framework.Providers.HUnit (hUnitTestToTests)
7 import Test.Framework.Runners.Console (defaultMain)
9 import Control.Applicative ((<*))
10 import Control.Arrow ((***))
11 import Control.Monad.IO.Class (liftIO)
12 import Data.Decimal (DecimalRaw(..))
13 import qualified Data.Either
14 import qualified Data.List
15 import Data.List.NonEmpty (NonEmpty(..))
16 import qualified Data.Map.Strict as Data.Map
17 import Data.Text (Text)
18 import qualified Data.Time.Calendar as Time
19 import qualified Data.Time.LocalTime as Time
20 import qualified Text.Parsec as P hiding (char, string)
21 import qualified Text.Parsec.Pos as P
22 -- import qualified Text.PrettyPrint.Leijen.Text as PP
24 import qualified Hcompta.Model.Account as Account
25 import qualified Hcompta.Model.Amount as Amount
26 import Hcompta.Model.Amount (Amount)
27 import qualified Hcompta.Model.Amount.Style as Amount.Style
28 import qualified Hcompta.Model.Date as Date
29 import qualified Hcompta.Calc.Balance as Calc.Balance
30 import qualified Hcompta.Format.Ledger as Format.Ledger
31 import qualified Hcompta.Format.Ledger.Read as Format.Ledger.Read
32 import qualified Hcompta.Format.Ledger.Write as Format.Ledger.Write
33 import qualified Hcompta.Lib.TreeMap as Lib.TreeMap
34 import qualified Hcompta.Lib.Parsec as P
35 import qualified Hcompta.Lib.Foldable as Lib.Foldable
37 --instance Eq Text.Parsec.ParseError where
38 -- (==) = const (const False)
41 main = defaultMain $ hUnitTestToTests test_Hcompta
47 [ "TreeMap" ~: TestList
48 [ "insert" ~: TestList
50 (Lib.TreeMap.insert const ((0::Int):|[]) () Lib.TreeMap.empty)
52 (Lib.TreeMap.TreeMap $
54 [ ((0::Int), Lib.TreeMap.leaf ())
57 (Lib.TreeMap.insert const ((0::Int):|1:[]) () Lib.TreeMap.empty)
59 (Lib.TreeMap.TreeMap $
61 [ ((0::Int), Lib.TreeMap.Node
62 { Lib.TreeMap.node_value = Nothing
63 , Lib.TreeMap.node_size = 1
64 , Lib.TreeMap.node_descendants =
65 Lib.TreeMap.singleton ((1::Int):|[]) ()
72 , "map_by_depth_first" ~: TestList
75 , "flatten" ~: TestList
76 [ "[0, 0/1, 0/1/2]" ~:
77 (Lib.TreeMap.flatten id $
78 Lib.TreeMap.from_List const
79 [ (((0::Integer):|[]), ())
90 , "[1, 1/2, 1/22, 1/2/3, 1/2/33, 11, 11/2, 11/2/3, 11/2/33]" ~:
91 (Lib.TreeMap.flatten id $
92 Lib.TreeMap.from_List const
101 , ((11:|2:33:[]), ())
106 [ (((1::Integer):|[]), ())
114 , ((11:|2:33:[]), ())
118 , "Foldable" ~: TestList
119 [ "accumLeftsAndFoldrRights" ~: TestList
121 (Lib.Foldable.accumLeftsAndFoldrRights (++) [""] $
124 (([(0::Integer)], [(""::String)]))
126 ((take 1 *** take 0) $
127 Lib.Foldable.accumLeftsAndFoldrRights (++) [""] $
128 ( repeat (Left [0]) ))
130 ([(0::Integer)], ([]::[String]))
131 , "Right:Left:Right:Left" ~:
132 (Lib.Foldable.accumLeftsAndFoldrRights (++) ["0"] $
133 ( Right ["2"]:Left [1]:Right ["1"]:Left [0]:[] ))
135 (([1, 0]::[Integer]), (["2", "1", "0"]::[String]))
136 , "Right:Left:Right:repeat Left" ~:
137 ((take 1 *** take 2) $
138 Lib.Foldable.accumLeftsAndFoldrRights (++) ["0"] $
139 ( Right ["2"]:Left [1]:Right ["1"]:repeat (Left [0]) ))
141 (([1]::[Integer]), (["2", "1"]::[String]))
145 , "Model" ~: TestList
146 [ "Account" ~: TestList
147 [ "foldr" ~: TestList
149 (reverse $ Account.foldr ("A":|[]) (:) []) ~?= ["A":|[]]
151 (reverse $ Account.foldr ("A":|["B"]) (:) []) ~?= ["A":|[], "A":|["B"]]
153 (reverse $ Account.foldr ("A":|["B", "C"]) (:) []) ~?= ["A":|[], "A":|["B"], "A":|["B", "C"]]
155 , "ascending" ~: TestList
157 Account.ascending ("A":|[]) ~?= Nothing
159 Account.ascending ("A":|["B"]) ~?= Just ("A":|[])
161 Account.ascending ("A":|["B", "C"]) ~?= Just ("A":|["B"])
164 , "Amount" ~: TestList
169 { Amount.quantity = Decimal 0 1
170 , Amount.style = Amount.Style.nil
171 { Amount.Style.unit_side = Just $ Amount.Style.Side_Left
176 { Amount.quantity = Decimal 0 1
177 , Amount.style = Amount.Style.nil
178 { Amount.Style.unit_side = Just $ Amount.Style.Side_Right
184 { Amount.quantity = Decimal 0 2
185 , Amount.style = Amount.Style.nil
186 { Amount.Style.unit_side = Just $ Amount.Style.Side_Left
191 , "from_List" ~: TestList
192 [ "from_List [$1, 1$] = $2" ~:
195 { Amount.quantity = Decimal 0 1
196 , Amount.style = Amount.Style.nil
197 { Amount.Style.unit_side = Just $ Amount.Style.Side_Left
202 { Amount.quantity = Decimal 0 1
203 , Amount.style = Amount.Style.nil
204 { Amount.Style.unit_side = Just $ Amount.Style.Side_Right
212 { Amount.quantity = Decimal 0 2
213 , Amount.style = Amount.Style.nil
214 { Amount.Style.unit_side = Just $ Amount.Style.Side_Left
223 [ "Balance" ~: TestList
224 [ "posting" ~: TestList
225 [ "[A+$1] = A+$1 & $+1" ~:
226 (Calc.Balance.posting
227 (Format.Ledger.posting ("A":|[]))
228 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1 ]
230 Calc.Balance.balance)
233 { Calc.Balance.balance_by_account =
234 Lib.TreeMap.from_List const
235 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ]) ]
236 , Calc.Balance.balance_by_unit =
238 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
239 [ Calc.Balance.Unit_Sum
240 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 1
241 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
246 , "[A+$1, A-$1] = {A+$0, $+0}" ~:
248 (flip Calc.Balance.posting)
250 [ (Format.Ledger.posting ("A":|[]))
251 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1 ]
253 , (Format.Ledger.posting ("A":|[]))
254 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ -1 ]
259 { Calc.Balance.balance_by_account =
260 Lib.TreeMap.from_List const
261 [ ("A":|[], Amount.from_List [ Amount.usd $ 0 ]) ]
262 , Calc.Balance.balance_by_unit =
264 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
265 [ Calc.Balance.Unit_Sum
266 { Calc.Balance.unit_sum_amount = Calc.Balance.Amount_Sum
267 { Calc.Balance.amount_sum_negative = Data.Map.singleton () $ Amount.usd $ -1
268 , Calc.Balance.amount_sum_positive = Data.Map.singleton () $ Amount.usd $ 1
269 , Calc.Balance.amount_sum_balance = Data.Map.singleton () $ Amount.usd $ 0
271 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
276 , "[A+$1, A-€1] = {A+$1-€1, $+1 €-1}" ~:
278 (flip Calc.Balance.posting)
280 [ (Format.Ledger.posting ("A":|[]))
281 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1 ]
283 , (Format.Ledger.posting ("A":|[]))
284 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.eur $ -1 ]
289 { Calc.Balance.balance_by_account =
290 Lib.TreeMap.from_List const
291 [ ("A":|[], Amount.from_List [ Amount.usd $ 1, Amount.eur $ -1 ]) ]
292 , Calc.Balance.balance_by_unit =
294 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
295 [ Calc.Balance.Unit_Sum
296 { Calc.Balance.unit_sum_amount = Calc.Balance.Amount_Sum
297 { Calc.Balance.amount_sum_negative = Data.Map.empty
298 , Calc.Balance.amount_sum_positive = Data.Map.singleton () $ Amount.usd $ 1
299 , Calc.Balance.amount_sum_balance = Data.Map.singleton () $ Amount.usd $ 1
301 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
304 , Calc.Balance.Unit_Sum
305 { Calc.Balance.unit_sum_amount = Calc.Balance.Amount_Sum
306 { Calc.Balance.amount_sum_negative = Data.Map.singleton () $ Amount.eur $ -1
307 , Calc.Balance.amount_sum_positive = Data.Map.empty
308 , Calc.Balance.amount_sum_balance = Data.Map.singleton () $ Amount.eur $ -1
310 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
315 , "[A+$1, B-$1] = {A+$1 B-$1, $+0}" ~:
317 (flip Calc.Balance.posting)
319 [ (Format.Ledger.posting ("A":|[]))
320 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1 ]
322 , (Format.Ledger.posting ("B":|[]))
323 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ -1 ]
328 { Calc.Balance.balance_by_account =
329 Lib.TreeMap.from_List const
330 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
331 , ("B":|[], Amount.from_List [ Amount.usd $ -1 ])
333 , Calc.Balance.balance_by_unit =
335 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
336 [ Calc.Balance.Unit_Sum
337 { Calc.Balance.unit_sum_amount = Calc.Balance.Amount_Sum
338 { Calc.Balance.amount_sum_negative = Data.Map.singleton () $ Amount.usd $ -1
339 , Calc.Balance.amount_sum_positive = Data.Map.singleton () $ Amount.usd $ 1
340 , Calc.Balance.amount_sum_balance = Data.Map.singleton () $ Amount.usd $ 0
342 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
349 (flip Calc.Balance.posting)
351 [ (Format.Ledger.posting ("A":|[]))
352 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1 ]
354 , (Format.Ledger.posting ("B":|[]))
355 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1 ]
360 { Calc.Balance.balance_by_account =
361 Lib.TreeMap.from_List const
362 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
363 , ("B":|[], Amount.from_List [ Amount.usd $ 1 ])
365 , Calc.Balance.balance_by_unit =
367 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
368 [ Calc.Balance.Unit_Sum
369 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 2
370 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
375 , "[A+$1+€2, A-$1-€2] = {A+$0+€0, $+0 €+0}" ~:
377 (flip Calc.Balance.posting)
379 [ (Format.Ledger.posting ("A":|[]))
380 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1, Amount.eur $ 2 ]
382 , (Format.Ledger.posting ("A":|[]))
383 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ -1, Amount.eur $ -2 ]
388 { Calc.Balance.balance_by_account =
389 Lib.TreeMap.from_List const
390 [ ("A":|[], Amount.from_List [ Amount.usd $ 0, Amount.eur $ 0 ])
392 , Calc.Balance.balance_by_unit =
394 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
395 [ Calc.Balance.Unit_Sum
396 { Calc.Balance.unit_sum_amount = Calc.Balance.Amount_Sum
397 { Calc.Balance.amount_sum_negative = Data.Map.singleton () $ Amount.usd $ -1
398 , Calc.Balance.amount_sum_positive = Data.Map.singleton () $ Amount.usd $ 1
399 , Calc.Balance.amount_sum_balance = Data.Map.singleton () $ Amount.usd $ 0
401 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
404 , Calc.Balance.Unit_Sum
405 { Calc.Balance.unit_sum_amount = Calc.Balance.Amount_Sum
406 { Calc.Balance.amount_sum_negative = Data.Map.singleton () $ Amount.eur $ -2
407 , Calc.Balance.amount_sum_positive = Data.Map.singleton () $ Amount.eur $ 2
408 , Calc.Balance.amount_sum_balance = Data.Map.singleton () $ Amount.eur $ 0
410 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
415 , "[A+$1+€2+£3, B-$1-2€-£3] = {A+$1+€2+£3 B-$1-€2-£3, $+0 €+0 £+0}" ~:
417 (flip Calc.Balance.posting)
419 [ (Format.Ledger.posting ("A":|[]))
420 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1, Amount.eur $ 2, Amount.gbp $ 3 ]
422 , (Format.Ledger.posting ("B":|[]))
423 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ -1, Amount.eur $ -2, Amount.gbp $ -3 ]
428 { Calc.Balance.balance_by_account =
429 Lib.TreeMap.from_List const
430 [ ("A":|[], Amount.from_List [ Amount.usd $ 1, Amount.eur $ 2, Amount.gbp $ 3 ])
431 , ("B":|[], Amount.from_List [ Amount.usd $ -1, Amount.eur $ -2, Amount.gbp $ -3 ])
433 , Calc.Balance.balance_by_unit =
435 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
436 [ Calc.Balance.Unit_Sum
437 { Calc.Balance.unit_sum_amount = Calc.Balance.Amount_Sum
438 { Calc.Balance.amount_sum_negative = Data.Map.singleton () $ Amount.usd $ -1
439 , Calc.Balance.amount_sum_positive = Data.Map.singleton () $ Amount.usd $ 1
440 , Calc.Balance.amount_sum_balance = Data.Map.singleton () $ Amount.usd $ 0
442 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
445 , Calc.Balance.Unit_Sum
446 { Calc.Balance.unit_sum_amount = Calc.Balance.Amount_Sum
447 { Calc.Balance.amount_sum_negative = Data.Map.singleton () $ Amount.eur $ -2
448 , Calc.Balance.amount_sum_positive = Data.Map.singleton () $ Amount.eur $ 2
449 , Calc.Balance.amount_sum_balance = Data.Map.singleton () $ Amount.eur $ 0
451 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
454 , Calc.Balance.Unit_Sum
455 { Calc.Balance.unit_sum_amount = Calc.Balance.Amount_Sum
456 { Calc.Balance.amount_sum_negative = Data.Map.singleton () $ Amount.gbp $ -3
457 , Calc.Balance.amount_sum_positive = Data.Map.singleton () $ Amount.gbp $ 3
458 , Calc.Balance.amount_sum_balance = Data.Map.singleton () $ Amount.gbp $ 0
460 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
466 , "union" ~: TestList
472 (Calc.Balance.balance::Calc.Balance.Balance Amount String)
473 , "{A+$1, $+1} {A+$1, $+1} = {A+$2, $+2}" ~:
475 (Calc.Balance.Balance
476 { Calc.Balance.balance_by_account =
477 Lib.TreeMap.from_List const
478 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ]) ]
479 , Calc.Balance.balance_by_unit =
481 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
482 [ Calc.Balance.Unit_Sum
483 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 1
484 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
489 (Calc.Balance.Balance
490 { Calc.Balance.balance_by_account =
491 Lib.TreeMap.from_List const
492 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ]) ]
493 , Calc.Balance.balance_by_unit =
495 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
496 [ Calc.Balance.Unit_Sum
497 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 1
498 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
505 { Calc.Balance.balance_by_account =
506 Lib.TreeMap.from_List const
507 [ ("A":|[], Amount.from_List [ Amount.usd $ 2 ]) ]
508 , Calc.Balance.balance_by_unit =
510 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
511 [ Calc.Balance.Unit_Sum
512 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 2
513 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
518 , "{A+$1, $+1} {B+$1, $+1} = {A+$1 B+$1, $+2}" ~:
520 (Calc.Balance.Balance
521 { Calc.Balance.balance_by_account =
522 Lib.TreeMap.from_List const
523 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ]) ]
524 , Calc.Balance.balance_by_unit =
526 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
527 [ Calc.Balance.Unit_Sum
528 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 1
529 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
534 (Calc.Balance.Balance
535 { Calc.Balance.balance_by_account =
536 Lib.TreeMap.from_List const
537 [ ("B":|[], Amount.from_List [ Amount.usd $ 1 ]) ]
538 , Calc.Balance.balance_by_unit =
540 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
541 [ Calc.Balance.Unit_Sum
542 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 1
543 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
550 { Calc.Balance.balance_by_account =
551 Lib.TreeMap.from_List const
552 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
553 , ("B":|[], Amount.from_List [ Amount.usd $ 1 ]) ]
554 , Calc.Balance.balance_by_unit =
556 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
557 [ Calc.Balance.Unit_Sum
558 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 2
559 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
564 , "{A+$1, $+1} {B+€1, €+1} = {A+$1 B+€1, $+1 €+1}" ~:
566 (Calc.Balance.Balance
567 { Calc.Balance.balance_by_account =
568 Lib.TreeMap.from_List const
569 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ]) ]
570 , Calc.Balance.balance_by_unit =
572 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
573 [ Calc.Balance.Unit_Sum
574 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 1
575 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
580 (Calc.Balance.Balance
581 { Calc.Balance.balance_by_account =
582 Lib.TreeMap.from_List const
583 [ ("B":|[], Amount.from_List [ Amount.eur $ 1 ]) ]
584 , Calc.Balance.balance_by_unit =
586 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
587 [ Calc.Balance.Unit_Sum
588 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.eur $ 1
589 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
596 { Calc.Balance.balance_by_account =
597 Lib.TreeMap.from_List const
598 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
599 , ("B":|[], Amount.from_List [ Amount.eur $ 1 ]) ]
600 , Calc.Balance.balance_by_unit =
602 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
603 [ Calc.Balance.Unit_Sum
604 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 1
605 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
608 , Calc.Balance.Unit_Sum
609 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.eur $ 1
610 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
616 , "expanded" ~: TestList
617 [ "nil_By_Account" ~:
618 Calc.Balance.expanded
621 (Lib.TreeMap.empty::Calc.Balance.Expanded Amount String)
623 Calc.Balance.expanded
624 (Lib.TreeMap.from_List const
625 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ]) ])
627 (Lib.TreeMap.from_List const
628 [ ("A":|[], Calc.Balance.Account_Sum_Expanded
629 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
630 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
633 , "A/A+$1 = A+$1 A/A+$1" ~:
634 Calc.Balance.expanded
635 (Lib.TreeMap.from_List const
636 [ ("A":|["A"], Amount.from_List [ Amount.usd $ 1 ]) ])
638 (Lib.TreeMap.from_List const
639 [ ("A":|[], Calc.Balance.Account_Sum_Expanded
640 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
641 , Calc.Balance.exclusive = Amount.from_List []
643 , ("A":|["A"], Calc.Balance.Account_Sum_Expanded
644 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
645 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
648 , "A/B+$1 = A+$1 A/B+$1" ~:
649 Calc.Balance.expanded
650 (Lib.TreeMap.from_List const
651 [ ("A":|["B"], Amount.from_List [ Amount.usd $ 1 ]) ])
653 (Lib.TreeMap.from_List const
654 [ ("A":|[], Calc.Balance.Account_Sum_Expanded
655 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
656 , Calc.Balance.exclusive = Amount.from_List []
658 , ("A":|["B"], Calc.Balance.Account_Sum_Expanded
659 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
660 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
663 , "A/B/C+$1 = A+$1 A/B+$1 A/B/C+$1" ~:
664 Calc.Balance.expanded
665 (Lib.TreeMap.from_List const
666 [ ("A":|["B", "C"], Amount.from_List [ Amount.usd $ 1 ]) ])
668 (Lib.TreeMap.from_List const
669 [ ("A":|[], Calc.Balance.Account_Sum_Expanded
670 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
671 , Calc.Balance.exclusive = Amount.from_List []
673 , ("A":|["B"], Calc.Balance.Account_Sum_Expanded
674 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
675 , Calc.Balance.exclusive = Amount.from_List []
677 , ("A":|["B", "C"], Calc.Balance.Account_Sum_Expanded
678 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
679 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
682 , "A+$1 A/B+$1 = A+$2 A/B+$1" ~:
683 Calc.Balance.expanded
684 (Lib.TreeMap.from_List const
685 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
686 , ("A":|["B"], Amount.from_List [ Amount.usd $ 1 ])
689 (Lib.TreeMap.from_List const
690 [ ("A":|[], Calc.Balance.Account_Sum_Expanded
691 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 2 ]
692 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
694 , ("A":|["B"], Calc.Balance.Account_Sum_Expanded
695 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
696 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
699 , "A+$1 A/B+$1 A/B/C+$1 = A+$3 A/B+$2 A/B/C+$1" ~:
700 Calc.Balance.expanded
701 (Lib.TreeMap.from_List const
702 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
703 , ("A":|["B"], Amount.from_List [ Amount.usd $ 1 ])
704 , ("A":|["B", "C"], Amount.from_List [ Amount.usd $ 1 ])
707 (Lib.TreeMap.from_List const
708 [ ("A":|[], Calc.Balance.Account_Sum_Expanded
709 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 3 ]
710 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
712 , ("A":|["B"], Calc.Balance.Account_Sum_Expanded
713 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 2 ]
714 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
716 , ("A":|["B", "C"], Calc.Balance.Account_Sum_Expanded
717 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
718 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
721 , "A+$1 A/B+$1 A/B/C+$1 A/B/C/D+$1 = A+$4 A/B+$3 A/B/C+$2 A/B/C/D+$1" ~:
722 Calc.Balance.expanded
723 (Lib.TreeMap.from_List const
724 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
725 , ("A":|["B"], Amount.from_List [ Amount.usd $ 1 ])
726 , ("A":|["B", "C"], Amount.from_List [ Amount.usd $ 1 ])
727 , ("A":|["B", "C", "D"], Amount.from_List [ Amount.usd $ 1 ])
730 (Lib.TreeMap.from_List const
731 [ ("A":|[], Calc.Balance.Account_Sum_Expanded
732 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 4 ]
733 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
735 , ("A":|["B"], Calc.Balance.Account_Sum_Expanded
736 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 3 ]
737 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
739 , ("A":|["B", "C"], Calc.Balance.Account_Sum_Expanded
740 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 2 ]
741 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
743 , ("A":|["B", "C", "D"], Calc.Balance.Account_Sum_Expanded
744 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
745 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
748 , "A+$1 A/B+$1 A/BB+$1 AA/B+$1 = A+$3 A/B+$1 A/BB+$1 AA+$1 AA/B+$1" ~:
749 Calc.Balance.expanded
750 (Lib.TreeMap.from_List const
751 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
752 , ("A":|["B"], Amount.from_List [ Amount.usd $ 1 ])
753 , ("A":|["BB"], Amount.from_List [ Amount.usd $ 1 ])
754 , ("AA":|["B"], Amount.from_List [ Amount.usd $ 1 ])
757 (Lib.TreeMap.from_List const
758 [ ("A":|[], Calc.Balance.Account_Sum_Expanded
759 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 3 ]
760 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
762 , ("A":|["B"], Calc.Balance.Account_Sum_Expanded
763 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
764 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
766 , ("A":|["BB"], Calc.Balance.Account_Sum_Expanded
767 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
768 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
770 , ("AA":|[], Calc.Balance.Account_Sum_Expanded
771 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
772 , Calc.Balance.exclusive = Amount.from_List []
774 , ("AA":|["B"], Calc.Balance.Account_Sum_Expanded
775 { Calc.Balance.inclusive = Calc.Balance.amount_sum $ Amount.from_List [ Amount.usd $ 1 ]
776 , Calc.Balance.exclusive = Amount.from_List [ Amount.usd $ 1 ]
780 , "deviation" ~: TestList
782 (Calc.Balance.deviation $
784 { Calc.Balance.balance_by_account =
785 Lib.TreeMap.from_List const
786 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
787 , ("B":|[], Amount.from_List [])
789 , Calc.Balance.balance_by_unit =
791 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
792 [ Calc.Balance.Unit_Sum
793 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 1
794 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
800 (Calc.Balance.Deviation $
802 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
803 [ Calc.Balance.Unit_Sum
804 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 1
805 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
809 , "{A+$1 B+$1, $2}" ~:
810 (Calc.Balance.deviation $
812 { Calc.Balance.balance_by_account =
813 Lib.TreeMap.from_List const
814 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
815 , ("B":|[], Amount.from_List [ Amount.usd $ 1 ])
817 , Calc.Balance.balance_by_unit =
819 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
820 [ Calc.Balance.Unit_Sum
821 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 2
822 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
830 (Calc.Balance.Deviation $
832 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
833 [ Calc.Balance.Unit_Sum
834 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 2
835 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
841 , "is_equilibrium_inferrable" ~: TestList
842 [ "nil" ~: TestCase $
844 Calc.Balance.is_equilibrium_inferrable $
845 Calc.Balance.deviation $
846 (Calc.Balance.balance::Calc.Balance.Balance Amount.Amount Amount.Unit)
847 , "{A+$0, $+0}" ~: TestCase $
849 Calc.Balance.is_equilibrium_inferrable $
850 Calc.Balance.deviation $
852 { Calc.Balance.balance_by_account =
853 Lib.TreeMap.from_List const
854 [ ("A":|[], Amount.from_List [ Amount.usd $ 0 ])
856 , Calc.Balance.balance_by_unit =
858 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
859 [ Calc.Balance.Unit_Sum
860 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 0
861 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
866 , "{A+$1, $+1}" ~: TestCase $
868 Calc.Balance.is_equilibrium_inferrable $
869 Calc.Balance.deviation $
871 { Calc.Balance.balance_by_account =
872 Lib.TreeMap.from_List const
873 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
875 , Calc.Balance.balance_by_unit =
877 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
878 [ Calc.Balance.Unit_Sum
879 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 1
880 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
885 , "{A+$0+€0, $0 €+0}" ~: TestCase $
887 Calc.Balance.is_equilibrium_inferrable $
888 Calc.Balance.deviation $
890 { Calc.Balance.balance_by_account =
891 Lib.TreeMap.from_List const
892 [ ("A":|[], Amount.from_List [ Amount.usd $ 0, Amount.eur $ 0 ])
894 , Calc.Balance.balance_by_unit =
896 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
897 [ Calc.Balance.Unit_Sum
898 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 0
899 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
902 , Calc.Balance.Unit_Sum
903 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.eur $ 0
904 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
909 , "{A+$1, B-$1, $+0}" ~: TestCase $
911 Calc.Balance.is_equilibrium_inferrable $
912 Calc.Balance.deviation $
914 { Calc.Balance.balance_by_account =
915 Lib.TreeMap.from_List const
916 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
917 , ("B":|[], Amount.from_List [ Amount.usd $ -1 ])
919 , Calc.Balance.balance_by_unit =
921 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
922 [ Calc.Balance.Unit_Sum
923 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 0
924 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
929 , "{A+$1 B, $+1}" ~: TestCase $
931 Calc.Balance.is_equilibrium_inferrable $
932 Calc.Balance.deviation $
934 { Calc.Balance.balance_by_account =
935 Lib.TreeMap.from_List const
936 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
937 , ("B":|[], Amount.from_List [])
939 , Calc.Balance.balance_by_unit =
941 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
942 [ Calc.Balance.Unit_Sum
943 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 1
944 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
949 , "{A+$1 B+€1, $+1 €+1}" ~: TestCase $
951 Calc.Balance.is_equilibrium_inferrable $
952 Calc.Balance.deviation $
954 { Calc.Balance.balance_by_account =
955 Lib.TreeMap.from_List const
956 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
957 , ("B":|[], Amount.from_List [ Amount.eur $ 1 ])
959 , Calc.Balance.balance_by_unit =
961 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
962 [ Calc.Balance.Unit_Sum
963 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 1
964 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
967 , Calc.Balance.Unit_Sum
968 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.eur $ 1
969 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
974 , "{A+$1 B-$1+€1, $+0 €+1}" ~: TestCase $
976 Calc.Balance.is_equilibrium_inferrable $
977 Calc.Balance.deviation $
979 { Calc.Balance.balance_by_account =
980 Lib.TreeMap.from_List const
981 [ ("A":|[], Amount.from_List [ Amount.usd $ 1 ])
982 , ("B":|[], Amount.from_List [ Amount.usd $ -1, Amount.eur $ 1 ])
984 , Calc.Balance.balance_by_unit =
986 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
987 [ Calc.Balance.Unit_Sum
988 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 0
989 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
992 , Calc.Balance.Unit_Sum
993 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.eur $ 1
994 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
999 , "{A+$1+€2+£3 B-$1-€2-£3, $+0 €+0 £+0}" ~: TestCase $
1001 Calc.Balance.is_equilibrium_inferrable $
1002 Calc.Balance.deviation $
1003 Calc.Balance.Balance
1004 { Calc.Balance.balance_by_account =
1005 Lib.TreeMap.from_List const
1006 [ ("A":|[], Amount.from_List [ Amount.usd $ 1, Amount.eur $ 2, Amount.gbp $ 3 ])
1007 , ("B":|[], Amount.from_List [ Amount.usd $ -1, Amount.eur $ -2, Amount.gbp $ -3 ])
1009 , Calc.Balance.balance_by_unit =
1011 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
1012 [ Calc.Balance.Unit_Sum
1013 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 0
1014 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
1017 , Calc.Balance.Unit_Sum
1018 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.eur $ 0
1019 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
1022 , Calc.Balance.Unit_Sum
1023 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.gbp $ 0
1024 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
1030 , "infer_equilibrium" ~: TestList
1032 (snd $ Calc.Balance.infer_equilibrium $
1033 Format.Ledger.posting_by_Account
1034 [ (Format.Ledger.posting ("A":|[]))
1035 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1 ] }
1036 , (Format.Ledger.posting ("B":|[]))
1037 { Format.Ledger.posting_amounts=Amount.from_List [] }
1041 Format.Ledger.posting_by_Account
1042 [ (Format.Ledger.posting ("A":|[]))
1043 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1 ] }
1044 , (Format.Ledger.posting ("B":|[]))
1045 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ -1 ] }
1048 (snd $ Calc.Balance.infer_equilibrium $
1049 Format.Ledger.posting_by_Account
1050 [ (Format.Ledger.posting ("A":|[]))
1051 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1 ] }
1052 , (Format.Ledger.posting ("B":|[]))
1053 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.eur $ -1 ] }
1057 Format.Ledger.posting_by_Account
1058 [ (Format.Ledger.posting ("A":|[]))
1059 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1, Amount.eur $ 1] }
1060 , (Format.Ledger.posting ("B":|[]))
1061 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.eur $ -1, Amount.usd $ -1 ] }
1064 (snd $ Calc.Balance.infer_equilibrium $
1065 Format.Ledger.posting_by_Account
1066 [ (Format.Ledger.posting ("A":|[]))
1067 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1 ] }
1068 , (Format.Ledger.posting ("B":|[]))
1069 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1 ] }
1073 [ Calc.Balance.Unit_Sum
1074 { Calc.Balance.unit_sum_amount = Calc.Balance.amount_sum $ Data.Map.singleton () $ Amount.usd $ 2
1075 , Calc.Balance.unit_sum_accounts = Data.Map.fromList []}
1077 , "{A+$1 B-$1 B-1€}" ~:
1078 (snd $ Calc.Balance.infer_equilibrium $
1079 Format.Ledger.posting_by_Account
1080 [ (Format.Ledger.posting ("A":|[]))
1081 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1 ] }
1082 , (Format.Ledger.posting ("B":|[]))
1083 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ -1, Amount.eur $ -1 ] }
1087 Format.Ledger.posting_by_Account
1088 [ (Format.Ledger.posting ("A":|[]))
1089 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ 1, Amount.eur $ 1 ] }
1090 , (Format.Ledger.posting ("B":|[]))
1091 { Format.Ledger.posting_amounts=Amount.from_List [ Amount.usd $ -1, Amount.eur $ -1 ] }
1096 , "Format" ~: TestList
1097 [ "Ledger" ~: TestList
1098 [ "Read" ~: TestList
1099 [ "account_name" ~: TestList
1101 (Data.Either.rights $
1103 (Format.Ledger.Read.account_name <* P.eof)
1108 (Data.Either.rights $
1110 (Format.Ledger.Read.account_name <* P.eof)
1115 (Data.Either.rights $
1117 (Format.Ledger.Read.account_name <* P.eof)
1118 () "" ("AA"::Text)])
1122 (Data.Either.rights $
1124 (Format.Ledger.Read.account_name <* P.eof)
1129 (Data.Either.rights $
1131 (Format.Ledger.Read.account_name <* P.eof)
1136 (Data.Either.rights $
1138 (Format.Ledger.Read.account_name <* P.eof)
1139 () "" ("A:"::Text)])
1143 (Data.Either.rights $
1145 (Format.Ledger.Read.account_name <* P.eof)
1146 () "" (":A"::Text)])
1150 (Data.Either.rights $
1152 (Format.Ledger.Read.account_name <* P.eof)
1153 () "" ("A "::Text)])
1157 (Data.Either.rights $
1159 (Format.Ledger.Read.account_name)
1160 () "" ("A "::Text)])
1164 (Data.Either.rights $
1166 (Format.Ledger.Read.account_name <* P.eof)
1167 () "" ("A A"::Text)])
1171 (Data.Either.rights $
1173 (Format.Ledger.Read.account_name <* P.eof)
1174 () "" ("A "::Text)])
1178 (Data.Either.rights $
1180 (Format.Ledger.Read.account_name <* P.eof)
1181 () "" ("A \n"::Text)])
1185 (Data.Either.rights $
1187 (Format.Ledger.Read.account_name <* P.eof)
1188 () "" ("(A)A"::Text)])
1192 (Data.Either.rights $
1194 (Format.Ledger.Read.account_name <* P.eof)
1195 () "" ("( )A"::Text)])
1199 (Data.Either.rights $
1201 (Format.Ledger.Read.account_name <* P.eof)
1202 () "" ("(A) A"::Text)])
1206 (Data.Either.rights $
1208 (Format.Ledger.Read.account_name <* P.eof)
1209 () "" ("[ ]A"::Text)])
1213 (Data.Either.rights $
1215 (Format.Ledger.Read.account_name <* P.eof)
1216 () "" ("(A) "::Text)])
1220 (Data.Either.rights $
1222 (Format.Ledger.Read.account_name <* P.eof)
1223 () "" ("(A)"::Text)])
1227 (Data.Either.rights $
1229 (Format.Ledger.Read.account_name <* P.eof)
1230 () "" ("A(A)"::Text)])
1234 (Data.Either.rights $
1236 (Format.Ledger.Read.account_name <* P.eof)
1237 () "" ("[A]A"::Text)])
1241 (Data.Either.rights $
1243 (Format.Ledger.Read.account_name <* P.eof)
1244 () "" ("[A] A"::Text)])
1248 (Data.Either.rights $
1250 (Format.Ledger.Read.account_name <* P.eof)
1251 () "" ("[A] "::Text)])
1255 (Data.Either.rights $
1257 (Format.Ledger.Read.account_name <* P.eof)
1258 () "" ("[A]"::Text)])
1262 , "account" ~: TestList
1264 (Data.Either.rights $
1266 (Format.Ledger.Read.account <* P.eof)
1271 (Data.Either.rights $
1273 (Format.Ledger.Read.account <* P.eof)
1278 (Data.Either.rights $
1280 (Format.Ledger.Read.account <* P.eof)
1281 () "" ("A:"::Text)])
1285 (Data.Either.rights $
1287 (Format.Ledger.Read.account <* P.eof)
1288 () "" (":A"::Text)])
1292 (Data.Either.rights $
1294 (Format.Ledger.Read.account <* P.eof)
1295 () "" ("A "::Text)])
1299 (Data.Either.rights $
1301 (Format.Ledger.Read.account <* P.eof)
1302 () "" (" A"::Text)])
1306 (Data.Either.rights $
1308 (Format.Ledger.Read.account <* P.eof)
1309 () "" ("A:B"::Text)])
1313 (Data.Either.rights $
1315 (Format.Ledger.Read.account <* P.eof)
1316 () "" ("A:B:C"::Text)])
1319 , "\"Aa:Bbb:Cccc\"" ~:
1320 (Data.Either.rights $
1322 (Format.Ledger.Read.account <* P.eof)
1323 () "" ("Aa:Bbb:Cccc"::Text)])
1325 ["Aa":|["Bbb", "Cccc"]]
1326 , "\"A a : B b b : C c c c\"" ~:
1327 (Data.Either.rights $
1329 (Format.Ledger.Read.account <* P.eof)
1330 () "" ("A a : B b b : C c c c"::Text)])
1332 ["A a ":|[" B b b ", " C c c c"]]
1334 (Data.Either.rights $
1336 (Format.Ledger.Read.account <* P.eof)
1337 () "" ("A: :C"::Text)])
1341 (Data.Either.rights $
1343 (Format.Ledger.Read.account <* P.eof)
1344 () "" ("A::C"::Text)])
1348 (Data.Either.rights $
1350 (Format.Ledger.Read.account <* P.eof)
1351 () "" ("A:B:(C)"::Text)])
1355 , "posting_type" ~: TestList
1357 Format.Ledger.Read.posting_type
1360 (Format.Ledger.Posting_Type_Regular, "A":|[])
1362 Format.Ledger.Read.posting_type
1365 (Format.Ledger.Posting_Type_Regular, "(":|[])
1367 Format.Ledger.Read.posting_type
1370 (Format.Ledger.Posting_Type_Regular, ")":|[])
1372 Format.Ledger.Read.posting_type
1375 (Format.Ledger.Posting_Type_Regular, "()":|[])
1377 Format.Ledger.Read.posting_type
1380 (Format.Ledger.Posting_Type_Regular, "( )":|[])
1382 Format.Ledger.Read.posting_type
1385 (Format.Ledger.Posting_Type_Virtual, "A":|[])
1387 Format.Ledger.Read.posting_type
1390 (Format.Ledger.Posting_Type_Virtual, "A":|["B", "C"])
1392 Format.Ledger.Read.posting_type
1395 (Format.Ledger.Posting_Type_Regular, "A":|["B", "C"])
1397 Format.Ledger.Read.posting_type
1400 (Format.Ledger.Posting_Type_Regular, "(A)":|["B", "C"])
1402 Format.Ledger.Read.posting_type
1405 (Format.Ledger.Posting_Type_Regular, "A":|["(B)", "C"])
1407 Format.Ledger.Read.posting_type
1410 (Format.Ledger.Posting_Type_Regular, "A":|["B", "(C)"])
1412 Format.Ledger.Read.posting_type
1415 (Format.Ledger.Posting_Type_Regular, "[":|[])
1417 Format.Ledger.Read.posting_type
1420 (Format.Ledger.Posting_Type_Regular, "]":|[])
1422 Format.Ledger.Read.posting_type
1425 (Format.Ledger.Posting_Type_Regular, "[]":|[])
1427 Format.Ledger.Read.posting_type
1430 (Format.Ledger.Posting_Type_Regular, "[ ]":|[])
1432 Format.Ledger.Read.posting_type
1435 (Format.Ledger.Posting_Type_Virtual_Balanced, "A":|[])
1437 Format.Ledger.Read.posting_type
1440 (Format.Ledger.Posting_Type_Virtual_Balanced, "A":|["B", "C"])
1442 Format.Ledger.Read.posting_type
1445 (Format.Ledger.Posting_Type_Regular, "A":|["B", "C"])
1447 Format.Ledger.Read.posting_type
1450 (Format.Ledger.Posting_Type_Regular, "[A]":|["B", "C"])
1452 Format.Ledger.Read.posting_type
1455 (Format.Ledger.Posting_Type_Regular, "A":|["[B]", "C"])
1457 Format.Ledger.Read.posting_type
1460 (Format.Ledger.Posting_Type_Regular, "A":|["B", "[C]"])
1462 , "amount" ~: TestList
1464 (Data.Either.rights $
1466 (Format.Ledger.Read.amount <* P.eof)
1470 , "\"0\" = Right 0" ~:
1471 (Data.Either.rights $
1473 (Format.Ledger.Read.amount <* P.eof)
1477 { Amount.quantity = Decimal 0 0
1479 , "\"00\" = Right 0" ~:
1480 (Data.Either.rights $
1482 (Format.Ledger.Read.amount <* P.eof)
1483 () "" ("00"::Text)])
1486 { Amount.quantity = Decimal 0 0
1488 , "\"0.\" = Right 0." ~:
1489 (Data.Either.rights $
1491 (Format.Ledger.Read.amount <* P.eof)
1492 () "" ("0."::Text)])
1495 { Amount.quantity = Decimal 0 0
1498 { Amount.Style.fractioning = Just '.'
1501 , "\".0\" = Right 0.0" ~:
1502 (Data.Either.rights $
1504 (Format.Ledger.Read.amount <* P.eof)
1505 () "" (".0"::Text)])
1508 { Amount.quantity = Decimal 0 0
1511 { Amount.Style.fractioning = Just '.'
1512 , Amount.Style.precision = 1
1515 , "\"0,\" = Right 0," ~:
1516 (Data.Either.rights $
1518 (Format.Ledger.Read.amount <* P.eof)
1519 () "" ("0,"::Text)])
1522 { Amount.quantity = Decimal 0 0
1525 { Amount.Style.fractioning = Just ','
1528 , "\",0\" = Right 0,0" ~:
1529 (Data.Either.rights $
1531 (Format.Ledger.Read.amount <* P.eof)
1532 () "" (",0"::Text)])
1535 { Amount.quantity = Decimal 0 0
1538 { Amount.Style.fractioning = Just ','
1539 , Amount.Style.precision = 1
1542 , "\"0_\" = Left" ~:
1543 (Data.Either.rights $
1545 (Format.Ledger.Read.amount <* P.eof)
1546 () "" ("0_"::Text)])
1549 , "\"_0\" = Left" ~:
1550 (Data.Either.rights $
1552 (Format.Ledger.Read.amount <* P.eof)
1553 () "" ("_0"::Text)])
1556 , "\"0.0\" = Right 0.0" ~:
1557 (Data.Either.rights $
1559 (Format.Ledger.Read.amount <* P.eof)
1560 () "" ("0.0"::Text)])
1563 { Amount.quantity = Decimal 0 0
1566 { Amount.Style.fractioning = Just '.'
1567 , Amount.Style.precision = 1
1570 , "\"00.00\" = Right 0.00" ~:
1571 (Data.Either.rights $
1573 (Format.Ledger.Read.amount <* P.eof)
1574 () "" ("00.00"::Text)])
1577 { Amount.quantity = Decimal 0 0
1580 { Amount.Style.fractioning = Just '.'
1581 , Amount.Style.precision = 2
1584 , "\"0,0\" = Right 0,0" ~:
1585 (Data.Either.rights $
1587 (Format.Ledger.Read.amount <* P.eof)
1588 () "" ("0,0"::Text)])
1591 { Amount.quantity = Decimal 0 0
1594 { Amount.Style.fractioning = Just ','
1595 , Amount.Style.precision = 1
1598 , "\"00,00\" = Right 0,00" ~:
1599 (Data.Either.rights $
1601 (Format.Ledger.Read.amount <* P.eof)
1602 () "" ("00,00"::Text)])
1605 { Amount.quantity = Decimal 0 0
1608 { Amount.Style.fractioning = Just ','
1609 , Amount.Style.precision = 2
1612 , "\"0_0\" = Right 0" ~:
1613 (Data.Either.rights $
1615 (Format.Ledger.Read.amount <* P.eof)
1616 () "" ("0_0"::Text)])
1619 { Amount.quantity = Decimal 0 0
1622 { Amount.Style.fractioning = Nothing
1623 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping '_' [1]
1624 , Amount.Style.precision = 0
1627 , "\"00_00\" = Right 0" ~:
1628 (Data.Either.rights $
1630 (Format.Ledger.Read.amount <* P.eof)
1631 () "" ("00_00"::Text)])
1634 { Amount.quantity = Decimal 0 0
1637 { Amount.Style.fractioning = Nothing
1638 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping '_' [2]
1639 , Amount.Style.precision = 0
1642 , "\"0,000.00\" = Right 0,000.00" ~:
1643 (Data.Either.rights $
1645 (Format.Ledger.Read.amount <* P.eof)
1646 () "" ("0,000.00"::Text)])
1649 { Amount.quantity = Decimal 0 0
1652 { Amount.Style.fractioning = Just '.'
1653 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping ',' [3]
1654 , Amount.Style.precision = 2
1657 , "\"0.000,00\" = Right 0.000,00" ~:
1658 (Data.Either.rights $
1660 (Format.Ledger.Read.amount)
1661 () "" ("0.000,00"::Text)])
1664 { Amount.quantity = Decimal 0 0
1667 { Amount.Style.fractioning = Just ','
1668 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping '.' [3]
1669 , Amount.Style.precision = 2
1672 , "\"1,000.00\" = Right 1,000.00" ~:
1673 (Data.Either.rights $
1675 (Format.Ledger.Read.amount <* P.eof)
1676 () "" ("1,000.00"::Text)])
1679 { Amount.quantity = Decimal 0 1000
1682 { Amount.Style.fractioning = Just '.'
1683 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping ',' [3]
1684 , Amount.Style.precision = 2
1687 , "\"1.000,00\" = Right 1.000,00" ~:
1688 (Data.Either.rights $
1690 (Format.Ledger.Read.amount)
1691 () "" ("1.000,00"::Text)])
1694 { Amount.quantity = Decimal 0 1000
1697 { Amount.Style.fractioning = Just ','
1698 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping '.' [3]
1699 , Amount.Style.precision = 2
1702 , "\"1,000.00.\" = Left" ~:
1703 (Data.Either.rights $
1705 (Format.Ledger.Read.amount)
1706 () "" ("1,000.00."::Text)])
1709 , "\"1.000,00,\" = Left" ~:
1710 (Data.Either.rights $
1712 (Format.Ledger.Read.amount)
1713 () "" ("1.000,00,"::Text)])
1716 , "\"1,000.00_\" = Left" ~:
1717 (Data.Either.rights $
1719 (Format.Ledger.Read.amount)
1720 () "" ("1,000.00_"::Text)])
1723 , "\"12\" = Right 12" ~:
1724 (Data.Either.rights $
1726 (Format.Ledger.Read.amount <* P.eof)
1727 () "" ("123"::Text)])
1730 { Amount.quantity = Decimal 0 123
1732 , "\"1.2\" = Right 1.2" ~:
1733 (Data.Either.rights $
1735 (Format.Ledger.Read.amount <* P.eof)
1736 () "" ("1.2"::Text)])
1739 { Amount.quantity = Decimal 1 12
1742 { Amount.Style.fractioning = Just '.'
1743 , Amount.Style.precision = 1
1746 , "\"1,2\" = Right 1,2" ~:
1747 (Data.Either.rights $
1749 (Format.Ledger.Read.amount <* P.eof)
1750 () "" ("1,2"::Text)])
1753 { Amount.quantity = Decimal 1 12
1756 { Amount.Style.fractioning = Just ','
1757 , Amount.Style.precision = 1
1760 , "\"12.23\" = Right 12.23" ~:
1761 (Data.Either.rights $
1763 (Format.Ledger.Read.amount <* P.eof)
1764 () "" ("12.34"::Text)])
1767 { Amount.quantity = Decimal 2 1234
1770 { Amount.Style.fractioning = Just '.'
1771 , Amount.Style.precision = 2
1774 , "\"12,23\" = Right 12,23" ~:
1775 (Data.Either.rights $
1777 (Format.Ledger.Read.amount <* P.eof)
1778 () "" ("12,34"::Text)])
1781 { Amount.quantity = Decimal 2 1234
1784 { Amount.Style.fractioning = Just ','
1785 , Amount.Style.precision = 2
1788 , "\"1_2\" = Right 1_2" ~:
1789 (Data.Either.rights $
1791 (Format.Ledger.Read.amount <* P.eof)
1792 () "" ("1_2"::Text)])
1795 { Amount.quantity = Decimal 0 12
1798 { Amount.Style.grouping_integral = Just $ Amount.Style.Grouping '_' [1]
1799 , Amount.Style.precision = 0
1802 , "\"1_23\" = Right 1_23" ~:
1803 (Data.Either.rights $
1805 (Format.Ledger.Read.amount <* P.eof)
1806 () "" ("1_23"::Text)])
1809 { Amount.quantity = Decimal 0 123
1812 { Amount.Style.grouping_integral = Just $ Amount.Style.Grouping '_' [2]
1813 , Amount.Style.precision = 0
1816 , "\"1_23_456\" = Right 1_23_456" ~:
1817 (Data.Either.rights $
1819 (Format.Ledger.Read.amount <* P.eof)
1820 () "" ("1_23_456"::Text)])
1823 { Amount.quantity = Decimal 0 123456
1826 { Amount.Style.grouping_integral = Just $ Amount.Style.Grouping '_' [3, 2]
1827 , Amount.Style.precision = 0
1830 , "\"1_23_456.7890_12345_678901\" = Right 1_23_456.7890_12345_678901" ~:
1831 (Data.Either.rights $
1833 (Format.Ledger.Read.amount <* P.eof)
1834 () "" ("1_23_456.7890_12345_678901"::Text)])
1837 { Amount.quantity = Decimal 15 123456789012345678901
1840 { Amount.Style.fractioning = Just '.'
1841 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping '_' [3, 2]
1842 , Amount.Style.grouping_fractional = Just $ Amount.Style.Grouping '_' [4, 5, 6]
1843 , Amount.Style.precision = 15
1846 , "\"123456_78901_2345.678_90_1\" = Right 123456_78901_2345.678_90_1" ~:
1847 (Data.Either.rights $
1849 (Format.Ledger.Read.amount <* P.eof)
1850 () "" ("123456_78901_2345.678_90_1"::Text)])
1853 { Amount.quantity = Decimal 6 123456789012345678901
1856 { Amount.Style.fractioning = Just '.'
1857 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping '_' [4, 5, 6]
1858 , Amount.Style.grouping_fractional = Just $ Amount.Style.Grouping '_' [3, 2]
1859 , Amount.Style.precision = 6
1862 , "\"$1\" = Right $1" ~:
1863 (Data.Either.rights $
1865 (Format.Ledger.Read.amount <* P.eof)
1866 () "" ("$1"::Text)])
1869 { Amount.quantity = Decimal 0 1
1872 { Amount.Style.fractioning = Nothing
1873 , Amount.Style.grouping_integral = Nothing
1874 , Amount.Style.grouping_fractional = Nothing
1875 , Amount.Style.precision = 0
1876 , Amount.Style.unit_side = Just Amount.Style.Side_Left
1877 , Amount.Style.unit_spaced = Just False
1881 , "\"1$\" = Right 1$" ~:
1882 (Data.Either.rights $
1884 (Format.Ledger.Read.amount <* P.eof)
1885 () "" ("1$"::Text)])
1888 { Amount.quantity = Decimal 0 1
1891 { Amount.Style.fractioning = Nothing
1892 , Amount.Style.grouping_integral = Nothing
1893 , Amount.Style.grouping_fractional = Nothing
1894 , Amount.Style.precision = 0
1895 , Amount.Style.unit_side = Just Amount.Style.Side_Right
1896 , Amount.Style.unit_spaced = Just False
1900 , "\"$ 1\" = Right $ 1" ~:
1901 (Data.Either.rights $
1903 (Format.Ledger.Read.amount <* P.eof)
1904 () "" ("$ 1"::Text)])
1907 { Amount.quantity = Decimal 0 1
1910 { Amount.Style.fractioning = Nothing
1911 , Amount.Style.grouping_integral = Nothing
1912 , Amount.Style.grouping_fractional = Nothing
1913 , Amount.Style.precision = 0
1914 , Amount.Style.unit_side = Just Amount.Style.Side_Left
1915 , Amount.Style.unit_spaced = Just True
1919 , "\"1 $\" = Right 1 $" ~:
1920 (Data.Either.rights $
1922 (Format.Ledger.Read.amount <* P.eof)
1923 () "" ("1 $"::Text)])
1926 { Amount.quantity = Decimal 0 1
1929 { Amount.Style.fractioning = Nothing
1930 , Amount.Style.grouping_integral = Nothing
1931 , Amount.Style.grouping_fractional = Nothing
1932 , Amount.Style.precision = 0
1933 , Amount.Style.unit_side = Just Amount.Style.Side_Right
1934 , Amount.Style.unit_spaced = Just True
1938 , "\"-$1\" = Right $-1" ~:
1939 (Data.Either.rights $
1941 (Format.Ledger.Read.amount <* P.eof)
1942 () "" ("-$1"::Text)])
1945 { Amount.quantity = Decimal 0 (-1)
1948 { Amount.Style.fractioning = Nothing
1949 , Amount.Style.grouping_integral = Nothing
1950 , Amount.Style.grouping_fractional = Nothing
1951 , Amount.Style.precision = 0
1952 , Amount.Style.unit_side = Just Amount.Style.Side_Left
1953 , Amount.Style.unit_spaced = Just False
1957 , "\"\\\"4 2\\\"1\" = Right \\\"4 2\\\"1" ~:
1958 (Data.Either.rights $
1960 (Format.Ledger.Read.amount <* P.eof)
1961 () "" ("\"4 2\"1"::Text)])
1964 { Amount.quantity = Decimal 0 1
1967 { Amount.Style.fractioning = Nothing
1968 , Amount.Style.grouping_integral = Nothing
1969 , Amount.Style.grouping_fractional = Nothing
1970 , Amount.Style.precision = 0
1971 , Amount.Style.unit_side = Just Amount.Style.Side_Left
1972 , Amount.Style.unit_spaced = Just False
1974 , Amount.unit = "4 2"
1976 , "\"1\\\"4 2\\\"\" = Right 1\\\"4 2\\\"" ~:
1977 (Data.Either.rights $
1979 (Format.Ledger.Read.amount <* P.eof)
1980 () "" ("1\"4 2\""::Text)])
1983 { Amount.quantity = Decimal 0 1
1986 { Amount.Style.fractioning = Nothing
1987 , Amount.Style.grouping_integral = Nothing
1988 , Amount.Style.grouping_fractional = Nothing
1989 , Amount.Style.precision = 0
1990 , Amount.Style.unit_side = Just Amount.Style.Side_Right
1991 , Amount.Style.unit_spaced = Just False
1993 , Amount.unit = "4 2"
1995 , "\"$1.000,00\" = Right $1.000,00" ~:
1996 (Data.Either.rights $
1998 (Format.Ledger.Read.amount <* P.eof)
1999 () "" ("$1.000,00"::Text)])
2002 { Amount.quantity = Decimal 0 1000
2005 { Amount.Style.fractioning = Just ','
2006 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping '.' [3]
2007 , Amount.Style.grouping_fractional = Nothing
2008 , Amount.Style.precision = 2
2009 , Amount.Style.unit_side = Just Amount.Style.Side_Left
2010 , Amount.Style.unit_spaced = Just False
2014 , "\"1.000,00$\" = Right 1.000,00$" ~:
2015 (Data.Either.rights $
2017 (Format.Ledger.Read.amount <* P.eof)
2018 () "" ("1.000,00$"::Text)])
2021 { Amount.quantity = Decimal 0 1000
2024 { Amount.Style.fractioning = Just ','
2025 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping '.' [3]
2026 , Amount.Style.grouping_fractional = Nothing
2027 , Amount.Style.precision = 2
2028 , Amount.Style.unit_side = Just Amount.Style.Side_Right
2029 , Amount.Style.unit_spaced = Just False
2034 , "comment" ~: TestList
2035 [ "; some comment = Right \" some comment\"" ~:
2036 (Data.Either.rights $
2038 (Format.Ledger.Read.comment <* P.eof)
2039 () "" ("; some comment"::Text)])
2042 , "; some comment \\n = Right \" some comment \"" ~:
2043 (Data.Either.rights $
2045 (Format.Ledger.Read.comment <* P.newline <* P.eof)
2046 () "" ("; some comment \n"::Text)])
2048 [ " some comment " ]
2049 , "; some comment \\r\\n = Right \" some comment \"" ~:
2050 (Data.Either.rights $
2052 (Format.Ledger.Read.comment <* P.string "\r\n" <* P.eof)
2053 () "" ("; some comment \r\n"::Text)])
2055 [ " some comment " ]
2057 , "comments" ~: TestList
2058 [ "; some comment\\n ; some other comment = Right [\" some comment\", \" some other comment\"]" ~:
2059 (Data.Either.rights $
2061 (Format.Ledger.Read.comments <* P.eof)
2062 () "" ("; some comment\n ; some other comment"::Text)])
2064 [ [" some comment", " some other comment"] ]
2065 , "; some comment \\n = Right \" some comment \"" ~:
2066 (Data.Either.rights $
2068 (Format.Ledger.Read.comments <* P.string "\n" <* P.eof)
2069 () "" ("; some comment \n"::Text)])
2071 [ [" some comment "] ]
2073 , "date" ~: TestList
2075 (Data.Either.rights $
2076 [P.runParser_with_Error
2077 (Format.Ledger.Read.date Nothing <* P.eof)
2078 () "" ("2000/01/01"::Text)])
2082 (Time.fromGregorian 2000 01 01)
2083 (Time.TimeOfDay 0 0 0))
2085 , "2000/01/01 some text" ~:
2086 (Data.Either.rights $
2087 [P.runParser_with_Error
2088 (Format.Ledger.Read.date Nothing)
2089 () "" ("2000/01/01 some text"::Text)])
2093 (Time.fromGregorian 2000 01 01)
2094 (Time.TimeOfDay 0 0 0))
2096 , "2000/01/01 12:34" ~:
2097 (Data.Either.rights $
2098 [P.runParser_with_Error
2099 (Format.Ledger.Read.date Nothing <* P.eof)
2100 () "" ("2000/01/01 12:34"::Text)])
2104 (Time.fromGregorian 2000 01 01)
2105 (Time.TimeOfDay 12 34 0))
2107 , "2000/01/01 12:34:56" ~:
2108 (Data.Either.rights $
2109 [P.runParser_with_Error
2110 (Format.Ledger.Read.date Nothing <* P.eof)
2111 () "" ("2000/01/01 12:34:56"::Text)])
2115 (Time.fromGregorian 2000 01 01)
2116 (Time.TimeOfDay 12 34 56))
2118 , "2000/01/01 12:34 CET" ~:
2119 (Data.Either.rights $
2120 [P.runParser_with_Error
2121 (Format.Ledger.Read.date Nothing <* P.eof)
2122 () "" ("2000/01/01 12:34 CET"::Text)])
2126 (Time.fromGregorian 2000 01 01)
2127 (Time.TimeOfDay 12 34 0))
2128 (Time.TimeZone 60 True "CET")]
2129 , "2000/01/01 12:34 +0130" ~:
2130 (Data.Either.rights $
2131 [P.runParser_with_Error
2132 (Format.Ledger.Read.date Nothing <* P.eof)
2133 () "" ("2000/01/01 12:34 +0130"::Text)])
2137 (Time.fromGregorian 2000 01 01)
2138 (Time.TimeOfDay 12 34 0))
2139 (Time.TimeZone 90 False "+0130")]
2140 , "2000/01/01 12:34:56 CET" ~:
2141 (Data.Either.rights $
2142 [P.runParser_with_Error
2143 (Format.Ledger.Read.date Nothing <* P.eof)
2144 () "" ("2000/01/01 12:34:56 CET"::Text)])
2148 (Time.fromGregorian 2000 01 01)
2149 (Time.TimeOfDay 12 34 56))
2150 (Time.TimeZone 60 True "CET")]
2152 (Data.Either.rights $
2153 [P.runParser_with_Error
2154 (Format.Ledger.Read.date Nothing <* P.eof)
2155 () "" ("2001/02/29"::Text)])
2159 (Data.Either.rights $
2160 [P.runParser_with_Error
2161 (Format.Ledger.Read.date (Just 2000) <* P.eof)
2162 () "" ("01/01"::Text)])
2166 (Time.fromGregorian 2000 01 01)
2167 (Time.TimeOfDay 0 0 0))
2170 , "tag_value" ~: TestList
2172 (Data.Either.rights $
2174 (Format.Ledger.Read.tag_value <* P.eof)
2179 (Data.Either.rights $
2181 (Format.Ledger.Read.tag_value <* P.char '\n' <* P.eof)
2182 () "" (",\n"::Text)])
2186 (Data.Either.rights $
2188 (Format.Ledger.Read.tag_value <* P.eof)
2189 () "" (",x"::Text)])
2193 (Data.Either.rights $
2195 (Format.Ledger.Read.tag_value <* P.string ",x:" <* P.eof)
2196 () "" (",x:"::Text)])
2200 (Data.Either.rights $
2202 (Format.Ledger.Read.tag_value <* P.string ", n:" <* P.eof)
2203 () "" ("v, v, n:"::Text)])
2209 (Data.Either.rights $
2211 (Format.Ledger.Read.tag <* P.eof)
2212 () "" ("Name:"::Text)])
2216 (Data.Either.rights $
2218 (Format.Ledger.Read.tag <* P.eof)
2219 () "" ("Name:Value"::Text)])
2222 , "Name:Value\\n" ~:
2223 (Data.Either.rights $
2225 (Format.Ledger.Read.tag <* P.string "\n" <* P.eof)
2226 () "" ("Name:Value\n"::Text)])
2230 (Data.Either.rights $
2232 (Format.Ledger.Read.tag <* P.eof)
2233 () "" ("Name:Val ue"::Text)])
2235 [("Name", "Val ue")]
2237 (Data.Either.rights $
2239 (Format.Ledger.Read.tag <* P.eof)
2240 () "" ("Name:,"::Text)])
2244 (Data.Either.rights $
2246 (Format.Ledger.Read.tag <* P.eof)
2247 () "" ("Name:Val,ue"::Text)])
2249 [("Name", "Val,ue")]
2251 (Data.Either.rights $
2253 (Format.Ledger.Read.tag <* P.string ",ue:" <* P.eof)
2254 () "" ("Name:Val,ue:"::Text)])
2258 , "tags" ~: TestList
2260 (Data.Either.rights $
2262 (Format.Ledger.Read.tags <* P.eof)
2263 () "" ("Name:"::Text)])
2270 (Data.Either.rights $
2272 (Format.Ledger.Read.tags <* P.eof)
2273 () "" ("Name:,"::Text)])
2280 (Data.Either.rights $
2282 (Format.Ledger.Read.tags <* P.eof)
2283 () "" ("Name:,Name:"::Text)])
2286 [ ("Name", ["", ""])
2290 (Data.Either.rights $
2292 (Format.Ledger.Read.tags <* P.eof)
2293 () "" ("Name:,Name2:"::Text)])
2300 , "Name: , Name2:" ~:
2301 (Data.Either.rights $
2303 (Format.Ledger.Read.tags <* P.eof)
2304 () "" ("Name: , Name2:"::Text)])
2311 , "Name:,Name2:,Name3:" ~:
2312 (Data.Either.rights $
2314 (Format.Ledger.Read.tags <* P.eof)
2315 () "" ("Name:,Name2:,Name3:"::Text)])
2323 , "Name:Val ue,Name2:V a l u e,Name3:V al ue" ~:
2324 (Data.Either.rights $
2326 (Format.Ledger.Read.tags <* P.eof)
2327 () "" ("Name:Val ue,Name2:V a l u e,Name3:V al ue"::Text)])
2330 [ ("Name", ["Val ue"])
2331 , ("Name2", ["V a l u e"])
2332 , ("Name3", ["V al ue"])
2336 , "posting" ~: TestList
2337 [ " A:B:C = Right A:B:C" ~:
2338 (Data.Either.rights $
2339 [P.runParser_with_Error
2340 (Format.Ledger.Read.posting <* P.eof)
2341 Format.Ledger.Read.nil_Context "" (" A:B:C"::Text)])
2343 [ ( (Format.Ledger.posting ("A":|["B", "C"]))
2344 { Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2346 , Format.Ledger.Posting_Type_Regular
2349 , " !A:B:C = Right !A:B:C" ~:
2350 (Data.List.map fst $
2351 Data.Either.rights $
2352 [P.runParser_with_Error
2353 (Format.Ledger.Read.posting <* P.eof)
2354 Format.Ledger.Read.nil_Context "" (" !A:B:C"::Text)])
2356 [ (Format.Ledger.posting ("A":|["B", "C"]))
2357 { Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2358 , Format.Ledger.posting_status = True
2361 , " *A:B:C = Right *A:B:C" ~:
2362 (Data.List.map fst $
2363 Data.Either.rights $
2364 [P.runParser_with_Error
2365 (Format.Ledger.Read.posting <* P.eof)
2366 Format.Ledger.Read.nil_Context "" (" *A:B:C"::Text)])
2368 [ (Format.Ledger.posting ("A":|["B", "C"]))
2369 { Format.Ledger.posting_amounts = Data.Map.fromList []
2370 , Format.Ledger.posting_comments = []
2371 , Format.Ledger.posting_dates = []
2372 , Format.Ledger.posting_status = True
2373 , Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2374 , Format.Ledger.posting_tags = Data.Map.fromList []
2377 , " A:B:C $1 = Right A:B:C $1" ~:
2378 (Data.List.map fst $
2379 Data.Either.rights $
2380 [P.runParser_with_Error
2381 (Format.Ledger.Read.posting <* P.eof)
2382 Format.Ledger.Read.nil_Context "" (" A:B:C $1"::Text)])
2384 [ (Format.Ledger.posting ("A":|["B","C $1"]))
2385 { Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2388 , " A:B:C $1 = Right A:B:C $1" ~:
2389 (Data.List.map fst $
2390 Data.Either.rights $
2391 [P.runParser_with_Error
2392 (Format.Ledger.Read.posting <* P.eof)
2393 Format.Ledger.Read.nil_Context "" (" A:B:C $1"::Text)])
2395 [ (Format.Ledger.posting ("A":|["B", "C"]))
2396 { Format.Ledger.posting_amounts = Data.Map.fromList
2398 { Amount.quantity = 1
2399 , Amount.style = Amount.Style.nil
2400 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2401 , Amount.Style.unit_spaced = Just False
2406 , Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2409 , " A:B:C $1 + 1€ = Right A:B:C $1 + 1€" ~:
2410 (Data.List.map fst $
2411 Data.Either.rights $
2412 [P.runParser_with_Error
2413 (Format.Ledger.Read.posting <* P.eof)
2414 Format.Ledger.Read.nil_Context "" (" A:B:C $1 + 1€"::Text)])
2416 [ (Format.Ledger.posting ("A":|["B", "C"]))
2417 { Format.Ledger.posting_amounts = Data.Map.fromList
2419 { Amount.quantity = 1
2420 , Amount.style = Amount.Style.nil
2421 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2422 , Amount.Style.unit_spaced = Just False
2427 { Amount.quantity = 1
2428 , Amount.style = Amount.Style.nil
2429 { Amount.Style.unit_side = Just Amount.Style.Side_Right
2430 , Amount.Style.unit_spaced = Just False
2435 , Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2438 , " A:B:C $1 + 1$ = Right A:B:C $2" ~:
2439 (Data.List.map fst $
2440 Data.Either.rights $
2441 [P.runParser_with_Error
2442 (Format.Ledger.Read.posting <* P.eof)
2443 Format.Ledger.Read.nil_Context "" (" A:B:C $1 + 1$"::Text)])
2445 [ (Format.Ledger.posting ("A":|["B", "C"]))
2446 { Format.Ledger.posting_amounts = Data.Map.fromList
2448 { Amount.quantity = 2
2449 , Amount.style = Amount.Style.nil
2450 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2451 , Amount.Style.unit_spaced = Just False
2456 , Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2459 , " A:B:C $1 + 1$ + 1$ = Right A:B:C $3" ~:
2460 (Data.List.map fst $
2461 Data.Either.rights $
2462 [P.runParser_with_Error
2463 (Format.Ledger.Read.posting <* P.eof)
2464 Format.Ledger.Read.nil_Context "" (" A:B:C $1 + 1$ + 1$"::Text)])
2466 [ (Format.Ledger.posting ("A":|["B", "C"]))
2467 { Format.Ledger.posting_amounts = Data.Map.fromList
2469 { Amount.quantity = 3
2470 , Amount.style = Amount.Style.nil
2471 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2472 , Amount.Style.unit_spaced = Just False
2477 , Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2480 , " A:B:C ; some comment = Right A:B:C ; some comment" ~:
2481 (Data.List.map fst $
2482 Data.Either.rights $
2483 [P.runParser_with_Error
2484 (Format.Ledger.Read.posting <* P.eof)
2485 Format.Ledger.Read.nil_Context "" (" A:B:C ; some comment"::Text)])
2487 [ (Format.Ledger.posting ("A":|["B", "C"]))
2488 { Format.Ledger.posting_amounts = Data.Map.fromList []
2489 , Format.Ledger.posting_comments = [" some comment"]
2490 , Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2493 , " A:B:C ; some comment\\n ; some other comment = Right A:B:C ; some comment\\n ; some other comment" ~:
2494 (Data.List.map fst $
2495 Data.Either.rights $
2496 [P.runParser_with_Error
2497 (Format.Ledger.Read.posting <* P.eof)
2498 Format.Ledger.Read.nil_Context "" (" A:B:C ; some comment\n ; some other comment"::Text)])
2500 [ (Format.Ledger.posting ("A":|["B", "C"]))
2501 { Format.Ledger.posting_amounts = Data.Map.fromList []
2502 , Format.Ledger.posting_comments = [" some comment", " some other comment"]
2503 , Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2506 , " A:B:C $1 ; some comment = Right A:B:C $1 ; some comment" ~:
2507 (Data.List.map fst $
2508 Data.Either.rights $
2509 [P.runParser_with_Error
2510 (Format.Ledger.Read.posting)
2511 Format.Ledger.Read.nil_Context "" (" A:B:C $1 ; some comment"::Text)])
2513 [ (Format.Ledger.posting ("A":|["B", "C"]))
2514 { Format.Ledger.posting_amounts = Data.Map.fromList
2516 { Amount.quantity = 1
2517 , Amount.style = Amount.Style.nil
2518 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2519 , Amount.Style.unit_spaced = Just False
2524 , Format.Ledger.posting_comments = [" some comment"]
2525 , Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2528 , " A:B:C ; N:V = Right A:B:C ; N:V" ~:
2529 (Data.List.map fst $
2530 Data.Either.rights $
2531 [P.runParser_with_Error
2532 (Format.Ledger.Read.posting <* P.eof)
2533 Format.Ledger.Read.nil_Context "" (" A:B:C ; N:V"::Text)])
2535 [ (Format.Ledger.posting ("A":|["B", "C"]))
2536 { Format.Ledger.posting_comments = [" N:V"]
2537 , Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2538 , Format.Ledger.posting_tags = Data.Map.fromList
2543 , " A:B:C ; some comment N:V = Right A:B:C ; some comment N:V" ~:
2544 (Data.List.map fst $
2545 Data.Either.rights $
2546 [P.runParser_with_Error
2547 (Format.Ledger.Read.posting <* P.eof)
2548 Format.Ledger.Read.nil_Context "" (" A:B:C ; some comment N:V"::Text)])
2550 [ (Format.Ledger.posting ("A":|["B", "C"]))
2551 { Format.Ledger.posting_comments = [" some comment N:V"]
2552 , Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2553 , Format.Ledger.posting_tags = Data.Map.fromList
2558 , " A:B:C ; some comment N:V v, N2:V2 v2 = Right A:B:C ; some comment N:V v, N2:V2 v2" ~:
2559 (Data.List.map fst $
2560 Data.Either.rights $
2561 [P.runParser_with_Error
2562 (Format.Ledger.Read.posting )
2563 Format.Ledger.Read.nil_Context "" (" A:B:C ; some comment N:V v, N2:V2 v2"::Text)])
2565 [ (Format.Ledger.posting ("A":|["B", "C"]))
2566 { Format.Ledger.posting_comments = [" some comment N:V v, N2:V2 v2"]
2567 , Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2568 , Format.Ledger.posting_tags = Data.Map.fromList
2574 , " A:B:C ; N:V\\n ; N:V2 = Right A:B:C ; N:V\\n ; N:V2" ~:
2575 (Data.List.map fst $
2576 Data.Either.rights $
2577 [P.runParser_with_Error
2578 (Format.Ledger.Read.posting <* P.eof)
2579 Format.Ledger.Read.nil_Context "" (" A:B:C ; N:V\n ; N:V2"::Text)])
2581 [ (Format.Ledger.posting ("A":|["B", "C"]))
2582 { Format.Ledger.posting_comments = [" N:V", " N:V2"]
2583 , Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2584 , Format.Ledger.posting_tags = Data.Map.fromList
2585 [ ("N", ["V", "V2"])
2589 , " A:B:C ; N:V\\n ; N2:V = Right A:B:C ; N:V\\n ; N2:V" ~:
2590 (Data.List.map fst $
2591 Data.Either.rights $
2592 [P.runParser_with_Error
2593 (Format.Ledger.Read.posting <* P.eof)
2594 Format.Ledger.Read.nil_Context "" (" A:B:C ; N:V\n ; N2:V"::Text)])
2596 [ (Format.Ledger.posting ("A":|["B", "C"]))
2597 { Format.Ledger.posting_comments = [" N:V", " N2:V"]
2598 , Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2599 , Format.Ledger.posting_tags = Data.Map.fromList
2605 , " A:B:C ; date:2001/01/01 = Right A:B:C ; date:2001/01/01" ~:
2606 (Data.List.map fst $
2607 Data.Either.rights $
2608 [P.runParser_with_Error
2609 (Format.Ledger.Read.posting <* P.eof)
2610 Format.Ledger.Read.nil_Context "" (" A:B:C ; date:2001/01/01"::Text)])
2612 [ (Format.Ledger.posting ("A":|["B", "C"]))
2613 { Format.Ledger.posting_comments = [" date:2001/01/01"]
2614 , Format.Ledger.posting_dates =
2617 (Time.fromGregorian 2001 01 01)
2618 (Time.TimeOfDay 0 0 0))
2621 , Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2622 , Format.Ledger.posting_tags = Data.Map.fromList
2623 [ ("date", ["2001/01/01"])
2627 , " (A:B:C) = Right (A:B:C)" ~:
2628 (Data.Either.rights $
2629 [P.runParser_with_Error
2630 (Format.Ledger.Read.posting <* P.eof)
2631 Format.Ledger.Read.nil_Context "" (" (A:B:C)"::Text)])
2633 [ ( (Format.Ledger.posting ("A":|["B", "C"]))
2634 { Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2636 , Format.Ledger.Posting_Type_Virtual
2639 , " [A:B:C] = Right [A:B:C]" ~:
2640 (Data.Either.rights $
2641 [P.runParser_with_Error
2642 (Format.Ledger.Read.posting <* P.eof)
2643 Format.Ledger.Read.nil_Context "" (" [A:B:C]"::Text)])
2645 [ ( (Format.Ledger.posting ("A":|["B", "C"]))
2646 { Format.Ledger.posting_sourcepos = P.newPos "" 1 1
2648 , Format.Ledger.Posting_Type_Virtual_Balanced
2652 , "transaction" ~: TestList
2653 [ "2000/01/01 some description\\n A:B:C $1\\n a:b:c" ~:
2654 (Data.Either.rights $
2655 [P.runParser_with_Error
2656 (Format.Ledger.Read.transaction <* P.eof)
2657 Format.Ledger.Read.nil_Context "" ("2000/01/01 some description\n A:B:C $1\n a:b:c"::Text)])
2659 [ Format.Ledger.transaction
2660 { Format.Ledger.transaction_dates=
2663 (Time.fromGregorian 2000 01 01)
2664 (Time.TimeOfDay 0 0 0))
2667 , Format.Ledger.transaction_description="some description"
2668 , Format.Ledger.transaction_postings = Format.Ledger.posting_by_Account
2669 [ (Format.Ledger.posting ("A":|["B", "C"]))
2670 { Format.Ledger.posting_amounts = Data.Map.fromList
2672 { Amount.quantity = 1
2673 , Amount.style = Amount.Style.nil
2674 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2675 , Amount.Style.unit_spaced = Just False
2680 , Format.Ledger.posting_sourcepos = P.newPos "" 2 1
2682 , (Format.Ledger.posting ("a":|["b", "c"]))
2683 { Format.Ledger.posting_amounts = Data.Map.fromList
2685 { Amount.quantity = -1
2686 , Amount.style = Amount.Style.nil
2687 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2688 , Amount.Style.unit_spaced = Just False
2693 , Format.Ledger.posting_sourcepos = P.newPos "" 3 1
2696 , Format.Ledger.transaction_postings_balance =
2697 Calc.Balance.Balance
2698 { Calc.Balance.balance_by_account =
2699 Lib.TreeMap.from_List const
2700 [ ("A":|["B", "C"], Amount.from_List [ Amount.usd $ 1 ])
2701 , ("a":|["b", "c"], Amount.from_List [ Amount.usd $ -1 ])
2703 , Calc.Balance.balance_by_unit =
2705 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
2706 [ Calc.Balance.Unit_Sum
2707 { Calc.Balance.unit_sum_amount = Calc.Balance.Amount_Sum
2708 { Calc.Balance.amount_sum_negative = Data.Map.singleton () $ Amount.usd $ -1
2709 , Calc.Balance.amount_sum_positive = Data.Map.singleton () $ Amount.usd $ 1
2710 , Calc.Balance.amount_sum_balance = Data.Map.singleton () $ Amount.usd $ 0
2712 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
2719 , Format.Ledger.transaction_sourcepos = P.newPos "" 1 1
2722 , "2000/01/01 some description\\n A:B:C $1\\n a:b:c\\n" ~:
2723 (Data.Either.rights $
2724 [P.runParser_with_Error
2725 (Format.Ledger.Read.transaction <* P.newline <* P.eof)
2726 Format.Ledger.Read.nil_Context "" ("2000/01/01 some description\n A:B:C $1\n a:b:c\n"::Text)])
2728 [ Format.Ledger.transaction
2729 { Format.Ledger.transaction_dates=
2732 (Time.fromGregorian 2000 01 01)
2733 (Time.TimeOfDay 0 0 0))
2736 , Format.Ledger.transaction_description="some description"
2737 , Format.Ledger.transaction_postings = Format.Ledger.posting_by_Account
2738 [ (Format.Ledger.posting ("A":|["B", "C"]))
2739 { Format.Ledger.posting_amounts = Data.Map.fromList
2741 { Amount.quantity = 1
2742 , Amount.style = Amount.Style.nil
2743 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2744 , Amount.Style.unit_spaced = Just False
2749 , Format.Ledger.posting_sourcepos = P.newPos "" 2 1
2751 , (Format.Ledger.posting ("a":|["b", "c"]))
2752 { Format.Ledger.posting_amounts = Data.Map.fromList
2754 { Amount.quantity = -1
2755 , Amount.style = Amount.Style.nil
2756 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2757 , Amount.Style.unit_spaced = Just False
2762 , Format.Ledger.posting_sourcepos = P.newPos "" 3 1
2765 , Format.Ledger.transaction_postings_balance =
2766 Calc.Balance.Balance
2767 { Calc.Balance.balance_by_account =
2768 Lib.TreeMap.from_List const
2769 [ ("A":|["B", "C"], Amount.from_List [ Amount.usd $ 1 ])
2770 , ("a":|["b", "c"], Amount.from_List [ Amount.usd $ -1 ])
2772 , Calc.Balance.balance_by_unit =
2774 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
2775 [ Calc.Balance.Unit_Sum
2776 { Calc.Balance.unit_sum_amount = Calc.Balance.Amount_Sum
2777 { Calc.Balance.amount_sum_negative = Data.Map.singleton () $ Amount.usd $ -1
2778 , Calc.Balance.amount_sum_positive = Data.Map.singleton () $ Amount.usd $ 1
2779 , Calc.Balance.amount_sum_balance = Data.Map.singleton () $ Amount.usd $ 0
2781 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
2788 , Format.Ledger.transaction_sourcepos = P.newPos "" 1 1
2791 , "2000/01/01 some description ; some comment\\n ; some other;comment\\n ; some Tag:\\n ; some last comment\\n A:B:C $1\\n a:b:c" ~:
2792 (Data.Either.rights $
2793 [P.runParser_with_Error
2794 (Format.Ledger.Read.transaction <* P.eof)
2795 Format.Ledger.Read.nil_Context "" ("2000/01/01 some description ; some comment\n ; some other;comment\n ; some Tag:\n ; some last comment\n A:B:C $1\n a:b:c"::Text)])
2797 [ Format.Ledger.transaction
2798 { Format.Ledger.transaction_comments_after =
2800 , " some other;comment"
2802 , " some last comment"
2804 , Format.Ledger.transaction_dates=
2807 (Time.fromGregorian 2000 01 01)
2808 (Time.TimeOfDay 0 0 0))
2811 , Format.Ledger.transaction_description="some description"
2812 , Format.Ledger.transaction_postings = Format.Ledger.posting_by_Account
2813 [ (Format.Ledger.posting ("A":|["B", "C"]))
2814 { Format.Ledger.posting_amounts = Data.Map.fromList
2816 { Amount.quantity = 1
2817 , Amount.style = Amount.Style.nil
2818 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2819 , Amount.Style.unit_spaced = Just False
2824 , Format.Ledger.posting_sourcepos = P.newPos "" 5 1
2826 , (Format.Ledger.posting ("a":|["b", "c"]))
2827 { Format.Ledger.posting_amounts = Data.Map.fromList
2829 { Amount.quantity = -1
2830 , Amount.style = Amount.Style.nil
2831 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2832 , Amount.Style.unit_spaced = Just False
2837 , Format.Ledger.posting_sourcepos = P.newPos "" 6 1
2840 , Format.Ledger.transaction_tags = Data.Map.fromList
2843 , Format.Ledger.transaction_postings_balance =
2844 Calc.Balance.Balance
2845 { Calc.Balance.balance_by_account =
2846 Lib.TreeMap.from_List const
2847 [ ("A":|["B", "C"], Amount.from_List [ Amount.usd $ 1 ])
2848 , ("a":|["b", "c"], Amount.from_List [ Amount.usd $ -1 ])
2850 , Calc.Balance.balance_by_unit =
2852 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
2853 [ Calc.Balance.Unit_Sum
2854 { Calc.Balance.unit_sum_amount = Calc.Balance.Amount_Sum
2855 { Calc.Balance.amount_sum_negative = Data.Map.singleton () $ Amount.usd $ -1
2856 , Calc.Balance.amount_sum_positive = Data.Map.singleton () $ Amount.usd $ 1
2857 , Calc.Balance.amount_sum_balance = Data.Map.singleton () $ Amount.usd $ 0
2859 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
2866 , Format.Ledger.transaction_sourcepos = P.newPos "" 1 1
2870 , "journal" ~: TestList
2871 [ "2000/01/01 1° description\\n A:B:C $1\\n a:b:c\\n2000/01/02 2° description\\n A:B:C $1\\n x:y:z" ~: TestCase $ do
2873 P.runParserT_with_Error
2874 (Format.Ledger.Read.journal "" {-<* P.eof-})
2875 Format.Ledger.Read.nil_Context "" ("2000/01/01 1° description\n A:B:C $1\n a:b:c\n2000/01/02 2° description\n A:B:C $1\n x:y:z"::Text)
2877 (\j -> j{Format.Ledger.journal_last_read_time=
2878 Format.Ledger.journal_last_read_time Format.Ledger.journal}) $
2879 Data.Either.rights [jnl])
2881 [ Format.Ledger.journal
2882 { Format.Ledger.journal_transactions =
2883 Format.Ledger.transaction_by_Date
2884 [ Format.Ledger.transaction
2885 { Format.Ledger.transaction_dates=
2888 (Time.fromGregorian 2000 01 01)
2889 (Time.TimeOfDay 0 0 0))
2892 , Format.Ledger.transaction_description="1° description"
2893 , Format.Ledger.transaction_postings = Format.Ledger.posting_by_Account
2894 [ (Format.Ledger.posting ("A":|["B", "C"]))
2895 { Format.Ledger.posting_amounts = Data.Map.fromList
2897 { Amount.quantity = 1
2898 , Amount.style = Amount.Style.nil
2899 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2900 , Amount.Style.unit_spaced = Just False
2905 , Format.Ledger.posting_sourcepos = P.newPos "" 2 1
2907 , (Format.Ledger.posting ("a":|["b", "c"]))
2908 { Format.Ledger.posting_amounts = Data.Map.fromList
2910 { Amount.quantity = -1
2911 , Amount.style = Amount.Style.nil
2912 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2913 , Amount.Style.unit_spaced = Just False
2918 , Format.Ledger.posting_sourcepos = P.newPos "" 3 1
2921 , Format.Ledger.transaction_postings_balance =
2922 Calc.Balance.Balance
2923 { Calc.Balance.balance_by_account =
2924 Lib.TreeMap.from_List const
2925 [ ("A":|["B", "C"], Amount.from_List [ Amount.usd $ 1 ])
2926 , ("a":|["b", "c"], Amount.from_List [ Amount.usd $ -1 ])
2928 , Calc.Balance.balance_by_unit =
2930 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
2931 [ Calc.Balance.Unit_Sum
2932 { Calc.Balance.unit_sum_amount = Calc.Balance.Amount_Sum
2933 { Calc.Balance.amount_sum_negative = Data.Map.singleton () $ Amount.usd $ -1
2934 , Calc.Balance.amount_sum_positive = Data.Map.singleton () $ Amount.usd $ 1
2935 , Calc.Balance.amount_sum_balance = Data.Map.singleton () $ Amount.usd $ 0
2937 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
2944 , Format.Ledger.transaction_sourcepos = P.newPos "" 1 1
2946 , Format.Ledger.transaction
2947 { Format.Ledger.transaction_dates=
2950 (Time.fromGregorian 2000 01 02)
2951 (Time.TimeOfDay 0 0 0))
2954 , Format.Ledger.transaction_description="2° description"
2955 , Format.Ledger.transaction_postings = Format.Ledger.posting_by_Account
2956 [ (Format.Ledger.posting ("A":|["B", "C"]))
2957 { Format.Ledger.posting_amounts = Data.Map.fromList
2959 { Amount.quantity = 1
2960 , Amount.style = Amount.Style.nil
2961 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2962 , Amount.Style.unit_spaced = Just False
2967 , Format.Ledger.posting_sourcepos = P.newPos "" 5 1
2969 , (Format.Ledger.posting ("x":|["y", "z"]))
2970 { Format.Ledger.posting_amounts = Data.Map.fromList
2972 { Amount.quantity = -1
2973 , Amount.style = Amount.Style.nil
2974 { Amount.Style.unit_side = Just Amount.Style.Side_Left
2975 , Amount.Style.unit_spaced = Just False
2980 , Format.Ledger.posting_sourcepos = P.newPos "" 6 1
2983 , Format.Ledger.transaction_postings_balance =
2984 Calc.Balance.Balance
2985 { Calc.Balance.balance_by_account =
2986 Lib.TreeMap.from_List const
2987 [ ("A":|["B", "C"], Amount.from_List [ Amount.usd $ 1 ])
2988 , ("x":|["y", "z"], Amount.from_List [ Amount.usd $ -1 ])
2990 , Calc.Balance.balance_by_unit =
2992 Data.List.map (\s -> (Amount.unit $ (Calc.Balance.amount_sum_balance $ Calc.Balance.unit_sum_amount s) Data.Map.! (), s))
2993 [ Calc.Balance.Unit_Sum
2994 { Calc.Balance.unit_sum_amount = Calc.Balance.Amount_Sum
2995 { Calc.Balance.amount_sum_negative = Data.Map.singleton () $ Amount.usd $ -1
2996 , Calc.Balance.amount_sum_positive = Data.Map.singleton () $ Amount.usd $ 1
2997 , Calc.Balance.amount_sum_balance = Data.Map.singleton () $ Amount.usd $ 0
2999 , Calc.Balance.unit_sum_accounts = Data.Map.fromList $ Data.List.map (,())
3006 , Format.Ledger.transaction_sourcepos = P.newPos "" 4 1
3013 , "Write" ~: TestList
3014 [ "account" ~: TestList
3016 ((Format.Ledger.Write.show
3017 Format.Ledger.Write.Style
3018 { Format.Ledger.Write.style_color=False
3019 , Format.Ledger.Write.style_align=True
3021 Format.Ledger.Write.account Format.Ledger.Posting_Type_Regular $
3026 ((Format.Ledger.Write.show
3027 Format.Ledger.Write.Style
3028 { Format.Ledger.Write.style_color=False
3029 , Format.Ledger.Write.style_align=True
3031 Format.Ledger.Write.account Format.Ledger.Posting_Type_Regular $
3036 ((Format.Ledger.Write.show
3037 Format.Ledger.Write.Style
3038 { Format.Ledger.Write.style_color=False
3039 , Format.Ledger.Write.style_align=True
3041 Format.Ledger.Write.account Format.Ledger.Posting_Type_Virtual $
3046 ((Format.Ledger.Write.show
3047 Format.Ledger.Write.Style
3048 { Format.Ledger.Write.style_color=False
3049 , Format.Ledger.Write.style_align=True
3051 Format.Ledger.Write.account Format.Ledger.Posting_Type_Virtual_Balanced $
3056 , "amount" ~: TestList
3058 ((Format.Ledger.Write.show
3059 Format.Ledger.Write.Style
3060 { Format.Ledger.Write.style_color=False
3061 , Format.Ledger.Write.style_align=True
3063 Format.Ledger.Write.amount
3068 ((Format.Ledger.Write.show
3069 Format.Ledger.Write.Style
3070 { Format.Ledger.Write.style_color=False
3071 , Format.Ledger.Write.style_align=True
3073 Format.Ledger.Write.amount
3075 { Amount.style = Amount.Style.nil
3076 { Amount.Style.precision = 2 }
3081 ((Format.Ledger.Write.show
3082 Format.Ledger.Write.Style
3083 { Format.Ledger.Write.style_color=False
3084 , Format.Ledger.Write.style_align=True
3086 Format.Ledger.Write.amount
3088 { Amount.quantity = Decimal 0 123
3093 ((Format.Ledger.Write.show
3094 Format.Ledger.Write.Style
3095 { Format.Ledger.Write.style_color=False
3096 , Format.Ledger.Write.style_align=True
3098 Format.Ledger.Write.amount
3100 { Amount.quantity = Decimal 0 (- 123)
3104 , "12.3 @ prec=0" ~:
3105 ((Format.Ledger.Write.show
3106 Format.Ledger.Write.Style
3107 { Format.Ledger.Write.style_color=False
3108 , Format.Ledger.Write.style_align=True
3110 Format.Ledger.Write.amount
3112 { Amount.quantity = Decimal 1 123
3113 , Amount.style = Amount.Style.nil
3114 { Amount.Style.fractioning = Just '.'
3119 , "12.5 @ prec=0" ~:
3120 ((Format.Ledger.Write.show
3121 Format.Ledger.Write.Style
3122 { Format.Ledger.Write.style_color=False
3123 , Format.Ledger.Write.style_align=True
3125 Format.Ledger.Write.amount
3127 { Amount.quantity = Decimal 1 125
3128 , Amount.style = Amount.Style.nil
3129 { Amount.Style.fractioning = Just '.'
3134 , "12.3 @ prec=1" ~:
3135 ((Format.Ledger.Write.show
3136 Format.Ledger.Write.Style
3137 { Format.Ledger.Write.style_color=False
3138 , Format.Ledger.Write.style_align=True
3140 Format.Ledger.Write.amount
3142 { Amount.quantity = Decimal 1 123
3143 , Amount.style = Amount.Style.nil
3144 { Amount.Style.fractioning = Just '.'
3145 , Amount.Style.precision = 1
3150 , "1,234.56 @ prec=2" ~:
3151 ((Format.Ledger.Write.show
3152 Format.Ledger.Write.Style
3153 { Format.Ledger.Write.style_color=False
3154 , Format.Ledger.Write.style_align=True
3156 Format.Ledger.Write.amount
3158 { Amount.quantity = Decimal 2 123456
3159 , Amount.style = Amount.Style.nil
3160 { Amount.Style.fractioning = Just '.'
3161 , Amount.Style.precision = 2
3162 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping ',' [3]
3167 , "123,456,789,01,2.3456789 @ prec=7" ~:
3168 ((Format.Ledger.Write.show
3169 Format.Ledger.Write.Style
3170 { Format.Ledger.Write.style_color=False
3171 , Format.Ledger.Write.style_align=True
3173 Format.Ledger.Write.amount
3175 { Amount.quantity = Decimal 7 1234567890123456789
3176 , Amount.style = Amount.Style.nil
3177 { Amount.Style.fractioning = Just '.'
3178 , Amount.Style.precision = 7
3179 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping ',' [1, 2, 3]
3183 "123,456,789,01,2.3456789")
3184 , "1234567.8,90,123,456,789 @ prec=12" ~:
3185 ((Format.Ledger.Write.show
3186 Format.Ledger.Write.Style
3187 { Format.Ledger.Write.style_color=False
3188 , Format.Ledger.Write.style_align=True
3190 Format.Ledger.Write.amount
3192 { Amount.quantity = Decimal 12 1234567890123456789
3193 , Amount.style = Amount.Style.nil
3194 { Amount.Style.fractioning = Just '.'
3195 , Amount.Style.precision = 12
3196 , Amount.Style.grouping_fractional = Just $ Amount.Style.Grouping ',' [1, 2, 3]
3200 "1234567.8,90,123,456,789")
3201 , "1,2,3,4,5,6,7,89,012.3456789 @ prec=7" ~:
3202 ((Format.Ledger.Write.show
3203 Format.Ledger.Write.Style
3204 { Format.Ledger.Write.style_color=False
3205 , Format.Ledger.Write.style_align=True
3207 Format.Ledger.Write.amount
3209 { Amount.quantity = Decimal 7 1234567890123456789
3210 , Amount.style = Amount.Style.nil
3211 { Amount.Style.fractioning = Just '.'
3212 , Amount.Style.precision = 7
3213 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping ',' [3, 2, 1]
3217 "1,2,3,4,5,6,7,89,012.3456789")
3218 , "1234567.890,12,3,4,5,6,7,8,9 @ prec=12" ~:
3219 ((Format.Ledger.Write.show
3220 Format.Ledger.Write.Style
3221 { Format.Ledger.Write.style_color=False
3222 , Format.Ledger.Write.style_align=True
3224 Format.Ledger.Write.amount
3226 { Amount.quantity = Decimal 12 1234567890123456789
3227 , Amount.style = Amount.Style.nil
3228 { Amount.Style.fractioning = Just '.'
3229 , Amount.Style.precision = 12
3230 , Amount.Style.grouping_fractional = Just $ Amount.Style.Grouping ',' [3, 2, 1]
3234 "1234567.890,12,3,4,5,6,7,8,9")
3236 , "amount_length" ~: TestList
3238 ((Format.Ledger.Write.amount_length
3243 ((Format.Ledger.Write.amount_length
3245 { Amount.style = Amount.Style.nil
3246 { Amount.Style.precision = 2 }
3251 ((Format.Ledger.Write.amount_length
3253 { Amount.quantity = Decimal 0 123
3258 ((Format.Ledger.Write.amount_length
3260 { Amount.quantity = Decimal 0 (- 123)
3264 , "12.3 @ prec=0" ~:
3265 ((Format.Ledger.Write.amount_length
3267 { Amount.quantity = Decimal 1 123
3268 , Amount.style = Amount.Style.nil
3269 { Amount.Style.fractioning = Just '.'
3274 , "12.5 @ prec=0" ~:
3275 ((Format.Ledger.Write.amount_length
3277 { Amount.quantity = Decimal 1 125
3278 , Amount.style = Amount.Style.nil
3279 { Amount.Style.fractioning = Just '.'
3284 , "12.3 @ prec=1" ~:
3285 ((Format.Ledger.Write.amount_length
3287 { Amount.quantity = Decimal 1 123
3288 , Amount.style = Amount.Style.nil
3289 { Amount.Style.fractioning = Just '.'
3290 , Amount.Style.precision = 1
3295 , "1,234.56 @ prec=2" ~:
3296 ((Format.Ledger.Write.amount_length
3298 { Amount.quantity = Decimal 2 123456
3299 , Amount.style = Amount.Style.nil
3300 { Amount.Style.fractioning = Just '.'
3301 , Amount.Style.precision = 2
3302 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping ',' [3]
3307 , "123,456,789,01,2.3456789 @ prec=7" ~:
3308 ((Format.Ledger.Write.amount_length
3310 { Amount.quantity = Decimal 7 1234567890123456789
3311 , Amount.style = Amount.Style.nil
3312 { Amount.Style.fractioning = Just '.'
3313 , Amount.Style.precision = 7
3314 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping ',' [1, 2, 3]
3319 , "1234567.8,90,123,456,789 @ prec=12" ~:
3320 ((Format.Ledger.Write.amount_length
3322 { Amount.quantity = Decimal 12 1234567890123456789
3323 , Amount.style = Amount.Style.nil
3324 { Amount.Style.fractioning = Just '.'
3325 , Amount.Style.precision = 12
3326 , Amount.Style.grouping_fractional = Just $ Amount.Style.Grouping ',' [1, 2, 3]
3331 , "1,2,3,4,5,6,7,89,012.3456789 @ prec=7" ~:
3332 ((Format.Ledger.Write.amount_length
3334 { Amount.quantity = Decimal 7 1234567890123456789
3335 , Amount.style = Amount.Style.nil
3336 { Amount.Style.fractioning = Just '.'
3337 , Amount.Style.precision = 7
3338 , Amount.Style.grouping_integral = Just $ Amount.Style.Grouping ',' [3, 2, 1]
3343 , "1234567.890,12,3,4,5,6,7,8,9 @ prec=12" ~:
3344 ((Format.Ledger.Write.amount_length
3346 { Amount.quantity = Decimal 12 1234567890123456789
3347 , Amount.style = Amount.Style.nil
3348 { Amount.Style.fractioning = Just '.'
3349 , Amount.Style.precision = 12
3350 , Amount.Style.grouping_fractional = Just $ Amount.Style.Grouping ',' [3, 2, 1]
3356 , "date" ~: TestList
3358 ((Format.Ledger.Write.show
3359 Format.Ledger.Write.Style
3360 { Format.Ledger.Write.style_color=False
3361 , Format.Ledger.Write.style_align=True
3363 Format.Ledger.Write.date
3367 , "2000/01/01 12:34:51 CET" ~:
3368 (Format.Ledger.Write.show
3369 Format.Ledger.Write.Style
3370 { Format.Ledger.Write.style_color=False
3371 , Format.Ledger.Write.style_align=True
3373 Format.Ledger.Write.date $
3376 (Time.fromGregorian 2000 01 01)
3377 (Time.TimeOfDay 12 34 51))
3378 (Time.TimeZone 60 False "CET"))
3380 "2000/01/01 12:34:51 CET"
3381 , "2000/01/01 12:34:51 +0100" ~:
3382 (Format.Ledger.Write.show
3383 Format.Ledger.Write.Style
3384 { Format.Ledger.Write.style_color=False
3385 , Format.Ledger.Write.style_align=True
3387 Format.Ledger.Write.date $
3390 (Time.fromGregorian 2000 01 01)
3391 (Time.TimeOfDay 12 34 51))
3392 (Time.TimeZone 60 False ""))
3394 "2000/01/01 12:34:51 +0100"
3395 , "2000/01/01 01:02:03" ~:
3396 (Format.Ledger.Write.show
3397 Format.Ledger.Write.Style
3398 { Format.Ledger.Write.style_color=False
3399 , Format.Ledger.Write.style_align=True
3401 Format.Ledger.Write.date $
3404 (Time.fromGregorian 2000 01 01)
3405 (Time.TimeOfDay 1 2 3))
3408 "2000/01/01 01:02:03"
3410 (Format.Ledger.Write.show
3411 Format.Ledger.Write.Style
3412 { Format.Ledger.Write.style_color=False
3413 , Format.Ledger.Write.style_align=True
3415 Format.Ledger.Write.date $
3418 (Time.fromGregorian 0 01 01)
3419 (Time.TimeOfDay 1 2 0))
3424 (Format.Ledger.Write.show
3425 Format.Ledger.Write.Style
3426 { Format.Ledger.Write.style_color=False
3427 , Format.Ledger.Write.style_align=True
3429 Format.Ledger.Write.date $
3432 (Time.fromGregorian 0 01 01)
3433 (Time.TimeOfDay 1 0 0))
3438 (Format.Ledger.Write.show
3439 Format.Ledger.Write.Style
3440 { Format.Ledger.Write.style_color=False
3441 , Format.Ledger.Write.style_align=True
3443 Format.Ledger.Write.date $
3446 (Time.fromGregorian 0 01 01)
3447 (Time.TimeOfDay 0 1 0))
3452 (Format.Ledger.Write.show
3453 Format.Ledger.Write.Style
3454 { Format.Ledger.Write.style_color=False
3455 , Format.Ledger.Write.style_align=True
3457 Format.Ledger.Write.date $
3460 (Time.fromGregorian 0 01 01)
3461 (Time.TimeOfDay 0 0 0))
3466 , "transaction" ~: TestList
3468 ((Format.Ledger.Write.show
3469 Format.Ledger.Write.Style
3470 { Format.Ledger.Write.style_color=False
3471 , Format.Ledger.Write.style_align=True
3473 Format.Ledger.Write.transaction
3474 Format.Ledger.transaction)
3477 , "2000/01/01 some description\\n\\ta:b:c\\n\\t ; first comment\\n\\t ; second comment\\n\\t ; third comment\\n\\tA:B:C $1" ~:
3478 ((Format.Ledger.Write.show
3479 Format.Ledger.Write.Style
3480 { Format.Ledger.Write.style_color=False
3481 , Format.Ledger.Write.style_align=True
3483 Format.Ledger.Write.transaction $
3484 Format.Ledger.transaction
3485 { Format.Ledger.transaction_dates=
3488 (Time.fromGregorian 2000 01 01)
3489 (Time.TimeOfDay 0 0 0))
3492 , Format.Ledger.transaction_description="some description"
3493 , Format.Ledger.transaction_postings = Format.Ledger.posting_by_Account
3494 [ (Format.Ledger.posting ("A":|["B", "C"]))
3495 { Format.Ledger.posting_amounts = Data.Map.fromList
3497 { Amount.quantity = 1
3498 , Amount.style = Amount.Style.nil
3499 { Amount.Style.unit_side = Just Amount.Style.Side_Left
3500 , Amount.Style.unit_spaced = Just False
3506 , (Format.Ledger.posting ("a":|["b", "c"]))
3507 { Format.Ledger.posting_comments = ["first comment","second comment","third comment"]
3512 "2000/01/01 some description\n\ta:b:c\n\t ; first comment\n\t ; second comment\n\t ; third comment\n\tA:B:C $1")
3513 , "2000/01/01 some description\\n\\tA:B:C $1\\n\\tAA:BB:CC $123" ~:
3514 ((Format.Ledger.Write.show
3515 Format.Ledger.Write.Style
3516 { Format.Ledger.Write.style_color=False
3517 , Format.Ledger.Write.style_align=True
3519 Format.Ledger.Write.transaction $
3520 Format.Ledger.transaction
3521 { Format.Ledger.transaction_dates=
3524 (Time.fromGregorian 2000 01 01)
3525 (Time.TimeOfDay 0 0 0))
3528 , Format.Ledger.transaction_description="some description"
3529 , Format.Ledger.transaction_postings = Format.Ledger.posting_by_Account
3530 [ (Format.Ledger.posting ("A":|["B", "C"]))
3531 { Format.Ledger.posting_amounts = Data.Map.fromList
3533 { Amount.quantity = 1
3534 , Amount.style = Amount.Style.nil
3535 { Amount.Style.unit_side = Just Amount.Style.Side_Left
3536 , Amount.Style.unit_spaced = Just False
3542 , (Format.Ledger.posting ("AA":|["BB", "CC"]))
3543 { Format.Ledger.posting_amounts = Data.Map.fromList
3545 { Amount.quantity = 123
3546 , Amount.style = Amount.Style.nil
3547 { Amount.Style.unit_side = Just Amount.Style.Side_Left
3548 , Amount.Style.unit_spaced = Just False
3557 "2000/01/01 some description\n\tA:B:C $1\n\tAA:BB:CC $123")