From d3855b1df362d27f637161323ab44968681edf44 Mon Sep 17 00:00:00 2001 From: Julien Moutinho <julm+hcompta@autogeree.net> Date: Wed, 29 Apr 2015 04:15:41 +0200 Subject: [PATCH] Correction : calcul de la largeur des montants. --- lib/Hcompta/Format/Ledger/Write.hs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/Hcompta/Format/Ledger/Write.hs b/lib/Hcompta/Format/Ledger/Write.hs index 8f6cc4f..1aa3708 100644 --- a/lib/Hcompta/Format/Ledger/Write.hs +++ b/lib/Hcompta/Format/Ledger/Write.hs @@ -213,7 +213,7 @@ amounts_length amts = else Data.Map.foldr (\n -> (3 +) . (+) (amount_length n)) - 0 amts + (-3) amts quantity_length :: Style -> Quantity -> Int quantity_length Style.Style @@ -363,18 +363,18 @@ posting } = W.char '\t' <> do status status_ <> do - (case Data.Map.null amounts of - True -> account type_ acct - False -> - W.fill (max_account_length + 2) - (account type_ acct) <> do - W.fill (max 0 (max_amount_length - amounts_length amounts)) W.empty <> do - -- NOTE: AFAICS Text.PrettyPrint.Leijen gives no way - -- to get the column size of a Doc - -- before printing it, hence the call to amounts_length here again. - map_concat - (W.space <> (W.bold $ W.yellow $ W.char Read.amount_sep) <> W.space) - amount amounts) + case Data.Map.null amounts of + True -> account type_ acct + False -> + W.fill (max_account_length + 2) + (account type_ acct) <> do + let amounts_ = + W.displayT $ W.renderPretty False 1.0 maxBound $ + map_concat + (W.space <> (W.bold $ W.yellow $ W.char Read.amount_sep) <> W.space) + amount amounts + W.fill (max 0 (max_amount_length - (fromIntegral $ TL.length amounts_))) W.empty <> do + W.text amounts_ <> (case cmts of [] -> W.empty [c] -> W.space <> comment c -- 2.47.0