cli: Command.Balance: use Date format for dates in LayoutTidy
This commit is contained in:
parent
da61b64f94
commit
3af8eb3bc6
@ -30,6 +30,7 @@ formatCell cell =
|
|||||||
let align =
|
let align =
|
||||||
case cellType cell of
|
case cellType cell of
|
||||||
TypeString -> []
|
TypeString -> []
|
||||||
|
TypeDate -> []
|
||||||
_ -> [LucidBase.makeAttribute "align" "right"]
|
_ -> [LucidBase.makeAttribute "align" "right"]
|
||||||
withEmph =
|
withEmph =
|
||||||
case emph of
|
case emph of
|
||||||
|
|||||||
@ -71,6 +71,19 @@ printFods encoding tables =
|
|||||||
" <style:paragraph-properties fo:text-align='end'/>" :
|
" <style:paragraph-properties fo:text-align='end'/>" :
|
||||||
" <style:text-properties fo:font-weight='bold'/>" :
|
" <style:text-properties fo:font-weight='bold'/>" :
|
||||||
" </style:style>" :
|
" </style:style>" :
|
||||||
|
" <number:date-style style:name='iso-date'>" :
|
||||||
|
" <number:year number:style='long'/>" :
|
||||||
|
" <number:text>-</number:text>" :
|
||||||
|
" <number:month number:style='long'/>" :
|
||||||
|
" <number:text>-</number:text>" :
|
||||||
|
" <number:day number:style='long'/>" :
|
||||||
|
" </number:date-style>" :
|
||||||
|
" <style:style style:name='date' style:family='table-cell'" :
|
||||||
|
" style:data-style-name='iso-date'/>" :
|
||||||
|
" <style:style style:name='foot-date' style:family='table-cell'" :
|
||||||
|
" style:data-style-name='iso-date'>" :
|
||||||
|
" <style:text-properties fo:font-weight='bold'/>" :
|
||||||
|
" </style:style>" :
|
||||||
customStyles ++
|
customStyles ++
|
||||||
"</office:styles>" :
|
"</office:styles>" :
|
||||||
[]
|
[]
|
||||||
@ -201,23 +214,30 @@ formatCell cell =
|
|||||||
let style, valueType :: String
|
let style, valueType :: String
|
||||||
style =
|
style =
|
||||||
case (cellStyle cell, cellType cell) of
|
case (cellStyle cell, cellType cell) of
|
||||||
(Body emph, TypeAmount amt) -> numberStyle emph amt
|
(Body emph, TypeAmount amt) -> tableStyle $ numberStyle emph amt
|
||||||
(Body Item, TypeString) -> ""
|
(Body Item, TypeString) -> ""
|
||||||
(Body Item, TypeMixedAmount) -> " table:style-name='amount'"
|
(Body Item, TypeMixedAmount) -> tableStyle "amount"
|
||||||
(Body Total, TypeString) -> " table:style-name='foot'"
|
(Body Item, TypeDate) -> tableStyle "date"
|
||||||
(Body Total, TypeMixedAmount) -> " table:style-name='total-amount'"
|
(Body Total, TypeString) -> tableStyle "foot"
|
||||||
(Head, _) -> " table:style-name='head'"
|
(Body Total, TypeMixedAmount) -> tableStyle "total-amount"
|
||||||
|
(Body Total, TypeDate) -> tableStyle "foot-date"
|
||||||
|
(Head, _) -> tableStyle "head"
|
||||||
numberStyle emph amt =
|
numberStyle emph amt =
|
||||||
printf " table:style-name='%s-%s'"
|
printf "%s-%s"
|
||||||
(emphasisName emph)
|
(emphasisName emph)
|
||||||
(numberStyleName (acommodity amt, asprecision $ astyle amt))
|
(numberStyleName (acommodity amt, asprecision $ astyle amt))
|
||||||
|
tableStyle = printf " table:style-name='%s'"
|
||||||
|
|
||||||
valueType =
|
valueType =
|
||||||
case cellType cell of
|
case cellType cell of
|
||||||
TypeAmount amt ->
|
TypeAmount amt ->
|
||||||
printf
|
printf
|
||||||
"office:value-type='float' office:value='%s'"
|
"office:value-type='float' office:value='%s'"
|
||||||
(show $ aquantity amt)
|
(show $ aquantity amt)
|
||||||
|
TypeDate ->
|
||||||
|
printf
|
||||||
|
"office:value-type='date' office:date-value='%s'"
|
||||||
|
(cellContent cell)
|
||||||
_ -> "office:value-type='string'"
|
_ -> "office:value-type='string'"
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|||||||
@ -18,6 +18,7 @@ data Type =
|
|||||||
TypeString
|
TypeString
|
||||||
| TypeAmount !Amount
|
| TypeAmount !Amount
|
||||||
| TypeMixedAmount
|
| TypeMixedAmount
|
||||||
|
| TypeDate
|
||||||
deriving (Eq, Ord, Show)
|
deriving (Eq, Ord, Show)
|
||||||
|
|
||||||
data Style = Body Emphasis | Head
|
data Style = Body Emphasis | Head
|
||||||
|
|||||||
@ -900,14 +900,15 @@ multiBalanceRowAsCellBuilders bopts ReportOpts{..} colspans (PeriodicReportRow _
|
|||||||
-- complicates the data representation and can be easily calculated
|
-- complicates the data representation and can be easily calculated
|
||||||
where
|
where
|
||||||
wbCell = Ods.defaultCell . wbFromText
|
wbCell = Ods.defaultCell . wbFromText
|
||||||
|
wbDate content = (wbCell content) {Ods.cellType = Ods.TypeDate}
|
||||||
totalscolumn = row_total_ && balanceaccum_ `notElem` [Cumulative, Historical]
|
totalscolumn = row_total_ && balanceaccum_ `notElem` [Cumulative, Historical]
|
||||||
cs = if all mixedAmountLooksZero allamts then [""] else S.toList $ foldMap maCommodities allamts
|
cs = if all mixedAmountLooksZero allamts then [""] else S.toList $ foldMap maCommodities allamts
|
||||||
allamts = (if not summary_only_ then as else []) ++
|
allamts = (if not summary_only_ then as else []) ++
|
||||||
[rowtot | totalscolumn && not (null as)] ++
|
[rowtot | totalscolumn && not (null as)] ++
|
||||||
[rowavg | average_ && not (null as)]
|
[rowavg | average_ && not (null as)]
|
||||||
addDateColumns spn@(DateSpan s e) = (wbCell (showDateSpan spn) :)
|
addDateColumns spn@(DateSpan s e) = (wbCell (showDateSpan spn) :)
|
||||||
. (wbCell (maybe "" showEFDate s) :)
|
. (wbDate (maybe "" showEFDate s) :)
|
||||||
. (wbCell (maybe "" (showEFDate . modifyEFDay (addDays (-1))) e) :)
|
. (wbDate (maybe "" (showEFDate . modifyEFDay (addDays (-1))) e) :)
|
||||||
|
|
||||||
paddedTranspose :: a -> [[a]] -> [[a]]
|
paddedTranspose :: a -> [[a]] -> [[a]]
|
||||||
paddedTranspose _ [] = [[]]
|
paddedTranspose _ [] = [[]]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user