Skip to content

Commit

Permalink
cli: Commands.Print.transactionToSpreadsheet: vertically merge common…
Browse files Browse the repository at this point in the history
… index, date, description and other cells
  • Loading branch information
thielema committed Oct 18, 2024
1 parent 46f481e commit 3b8be54
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions hledger/Hledger/Cli/Commands/Print.hs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,7 @@ transactionToSpreadsheet ::
AmountFormat -> Maybe Text -> [Text] ->
Transaction -> [[Spr.Cell Spr.NumLines Text]]
transactionToSpreadsheet fmt baseUrl query t =
map
(\p -> idx:d:d2:status:code:description:comment:p)
addRowSpanHeader (idx:d:d2:status:code:description:comment:[])
(postingToSpreadsheet fmt baseUrl query =<< tpostings t)
where
cell = Spr.defaultCell
Expand All @@ -255,6 +254,20 @@ transactionToSpreadsheet fmt baseUrl query t =
code = cell $ tcode t
comment = cell $ T.strip $ tcomment t

addRowSpanHeader ::
[Spr.Cell border text] ->
[[Spr.Cell border text]] -> [[Spr.Cell border text]]
addRowSpanHeader common rows =
case rows of
[] -> []
[row] -> [common++row]
_ ->
let setSpan spn cell = cell{Spr.cellSpan = spn} in
zipWith (++)
(map (setSpan $ Spr.SpanVertical $ length rows) common :
repeat (map (setSpan Spr.Covered) common))
rows

postingToSpreadsheet ::
(Spr.Lines border) =>
AmountFormat -> Maybe Text -> [Text] ->
Expand Down

0 comments on commit 3b8be54

Please sign in to comment.