lib: Write.Spreadsheet.integerCell: for transaction indices

This commit is contained in:
Henning Thielemann 2024-10-19 12:39:24 +02:00 committed by Simon Michael
parent 7dc3715865
commit 4c189dde32
4 changed files with 9 additions and 5 deletions

View File

@ -25,6 +25,7 @@ module Hledger.Write.Spreadsheet (
cellFromMixedAmount,
cellsFromMixedAmount,
cellFromAmount,
integerCell,
) where
import qualified Hledger.Data.Amount as Amt
@ -251,3 +252,7 @@ amountType bopts amt =
if Amt.displayCommodity bopts
then amt
else amt {acommodity = Text.empty}
integerCell :: (Lines border) => Integer -> Cell border Text
integerCell k = (defaultCell $ Text.pack $ show k) {cellType = TypeInteger}

View File

@ -147,7 +147,7 @@ accountTransactionsReportItemAsRecord ::
accountTransactionsReportItemAsRecord
fmt wd reportq thisacctq
(t@Transaction{tindex,tcode,tdescription}, _, _issplit, otheracctsstr, change, balance)
= [idx,
= [Spr.integerCell tindex,
date,
cell tcode,
cell tdescription,
@ -156,7 +156,6 @@ accountTransactionsReportItemAsRecord
amountCell balance]
where
cell = Spr.defaultCell
idx = (cell $ T.pack $ show tindex) {Spr.cellType = Spr.TypeInteger}
date =
(Spr.defaultCell $ showDate $
transactionRegisterDate wd reportq thisacctq t)

View File

@ -244,7 +244,7 @@ transactionToSpreadsheet fmt baseUrl query t =
(postingToSpreadsheet fmt baseUrl query =<< tpostings t)
where
cell = Spr.defaultCell
idx = (cell $ T.pack $ show $ tindex t) {Spr.cellType = Spr.TypeInteger}
idx = Spr.integerCell $ tindex t
description = cell $ tdescription t
dateCell date =
(Spr.defaultCell $ showDate date) {Spr.cellType = Spr.TypeDate}

View File

@ -138,7 +138,7 @@ postingsReportItemAsRecord ::
AmountFormat -> Maybe Text -> [Text] ->
PostingsReportItem -> [Spr.Cell border T.Text]
postingsReportItemAsRecord fmt base query (_, _, _, p, b) =
[(cell idx) {Spr.cellType = Spr.TypeInteger},
[idx,
(dateCell base query (paccount p) date) {Spr.cellType = Spr.TypeDate},
cell code, cell desc,
setAccountAnchor base query (paccount p) $ cell acct,
@ -146,7 +146,7 @@ postingsReportItemAsRecord fmt base query (_, _, _, p, b) =
amountCell b]
where
cell = Spr.defaultCell
idx = T.pack . show . maybe 0 tindex $ ptransaction p
idx = Spr.integerCell . maybe 0 tindex $ ptransaction p
date = postingDate p -- XXX csv should show date2 with --date2
code = maybe "" tcode $ ptransaction p
desc = maybe "" tdescription $ ptransaction p