mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-07 21:15:19 +03:00
imp: balcmds: with --pretty, show table and inter-column borders
This commit is contained in:
parent
574115e001
commit
1b4b079f4d
@ -485,8 +485,8 @@ bareLayoutBalanceReportAsText opts ((items, total)) =
|
|||||||
sizes = fromMaybe 0 . maximumMay . map cellWidth <$>
|
sizes = fromMaybe 0 . maximumMay . map cellWidth <$>
|
||||||
transpose ([totalline | not (no_total_ opts)] ++ ls)
|
transpose ([totalline | not (no_total_ opts)] ++ ls)
|
||||||
overline = Cell TopLeft . pure . wbFromText . flip T.replicate "-" . fromMaybe 0 $ headMay sizes
|
overline = Cell TopLeft . pure . wbFromText . flip T.replicate "-" . fromMaybe 0 $ headMay sizes
|
||||||
singleColumnTableOuterBorder = False
|
singleColumnTableOuterBorder = pretty_ opts
|
||||||
singleColumnTableInterColumnBorder = NoLine
|
singleColumnTableInterColumnBorder = if pretty_ opts then SingleLine else NoLine
|
||||||
|
|
||||||
{-
|
{-
|
||||||
:r
|
:r
|
||||||
@ -756,7 +756,7 @@ multiBalanceReportAsTable opts@ReportOpts{summary_only_, average_, row_total_, b
|
|||||||
maybetranspose | transpose_ opts = \(Table rh ch vals) -> Table ch rh (transpose vals)
|
maybetranspose | transpose_ opts = \(Table rh ch vals) -> Table ch rh (transpose vals)
|
||||||
| otherwise = id
|
| otherwise = id
|
||||||
multiColumnTableInterRowBorder = NoLine
|
multiColumnTableInterRowBorder = NoLine
|
||||||
multiColumnTableInterColumnBorder = NoLine
|
multiColumnTableInterColumnBorder = if pretty_ opts then SingleLine else NoLine
|
||||||
|
|
||||||
multiBalanceRowAsWbs :: AmountFormat -> ReportOpts -> [DateSpan] -> PeriodicReportRow a MixedAmount -> [[WideBuilder]]
|
multiBalanceRowAsWbs :: AmountFormat -> ReportOpts -> [DateSpan] -> PeriodicReportRow a MixedAmount -> [[WideBuilder]]
|
||||||
multiBalanceRowAsWbs bopts ReportOpts{..} colspans (PeriodicReportRow _ as rowtot rowavg) =
|
multiBalanceRowAsWbs bopts ReportOpts{..} colspans (PeriodicReportRow _ as rowtot rowavg) =
|
||||||
@ -816,7 +816,7 @@ multiBalanceReportTableAsText :: ReportOpts -> Table T.Text T.Text WideBuilder -
|
|||||||
multiBalanceReportTableAsText ReportOpts{..} = renderTableByRowsB tableopts renderCh renderRow
|
multiBalanceReportTableAsText ReportOpts{..} = renderTableByRowsB tableopts renderCh renderRow
|
||||||
where
|
where
|
||||||
tableopts = def{tableBorders=multiColumnTableOuterBorder, prettyTable=pretty_}
|
tableopts = def{tableBorders=multiColumnTableOuterBorder, prettyTable=pretty_}
|
||||||
multiColumnTableOuterBorder = False
|
multiColumnTableOuterBorder = pretty_
|
||||||
|
|
||||||
renderCh :: [Text] -> [Cell]
|
renderCh :: [Text] -> [Cell]
|
||||||
renderCh
|
renderCh
|
||||||
@ -868,10 +868,13 @@ budgetReportAsTable ReportOpts{..} (PeriodicReport spans items totrow) =
|
|||||||
maybetransposetable $
|
maybetransposetable $
|
||||||
addtotalrow $
|
addtotalrow $
|
||||||
Table
|
Table
|
||||||
(Group NoLine $ map Header accts)
|
(Group budgetTableInterRowBorder $ map Header accts)
|
||||||
(Group NoLine $ map Header colheadings)
|
(Group budgetTableInterColumnBorder $ map Header colheadings)
|
||||||
rows
|
rows
|
||||||
where
|
where
|
||||||
|
budgetTableInterRowBorder = NoLine
|
||||||
|
budgetTableInterColumnBorder = if pretty_ then SingleLine else NoLine
|
||||||
|
|
||||||
maybetransposetable
|
maybetransposetable
|
||||||
| transpose_ = \(Table rh ch vals) -> Table ch rh (transpose vals)
|
| transpose_ = \(Table rh ch vals) -> Table ch rh (transpose vals)
|
||||||
| otherwise = id
|
| otherwise = id
|
||||||
|
@ -1,29 +1,59 @@
|
|||||||
# * --pretty option and balance command
|
# * --pretty option and balance command
|
||||||
# ** 1. Uses Unicode tables when given --pretty=yes
|
# ** 1. With --pretty=yes, tables use box drawing characters and more borders.
|
||||||
$ hledger -f balance-multicol.journal balance --pretty=yes -M
|
$ hledger -f balance-multicol.journal balance --pretty=yes -M
|
||||||
Balance changes in 2012-12-01..2013-03-31:
|
Balance changes in 2012-12-01..2013-03-31:
|
||||||
|
|
||||||
║ 2012-12 2013-01 2013-02 2013-03
|
┌─────────────────╥─────────┬─────────┬─────────┬─────────┐
|
||||||
═════════════════╬════════════════════════════════════
|
│ ║ 2012-12 │ 2013-01 │ 2013-02 │ 2013-03 │
|
||||||
assets ║ 0 0 1 0
|
╞═════════════════╬═════════╪═════════╪═════════╪═════════╡
|
||||||
assets:cash ║ 0 0 1 0
|
│ assets ║ 0 │ 0 │ 1 │ 0 │
|
||||||
assets:checking ║ 10 0 0 1
|
│ assets:cash ║ 0 │ 0 │ 1 │ 0 │
|
||||||
─────────────────╫────────────────────────────────────
|
│ assets:checking ║ 10 │ 0 │ 0 │ 1 │
|
||||||
║ 10 0 2 1
|
├─────────────────╫─────────┼─────────┼─────────┼─────────┤
|
||||||
|
│ ║ 10 │ 0 │ 2 │ 1 │
|
||||||
|
└─────────────────╨─────────┴─────────┴─────────┴─────────┘
|
||||||
|
|
||||||
# ** 2. Uses Unicode tables when given --pretty
|
# ** 2. --pretty with no argument does the same.
|
||||||
$ hledger -f balance-multicol.journal balance --pretty -M
|
$ hledger -f balance-multicol.journal balance --pretty -M
|
||||||
Balance changes in 2012-12-01..2013-03-31:
|
Balance changes in 2012-12-01..2013-03-31:
|
||||||
|
|
||||||
║ 2012-12 2013-01 2013-02 2013-03
|
┌─────────────────╥─────────┬─────────┬─────────┬─────────┐
|
||||||
═════════════════╬════════════════════════════════════
|
│ ║ 2012-12 │ 2013-01 │ 2013-02 │ 2013-03 │
|
||||||
assets ║ 0 0 1 0
|
╞═════════════════╬═════════╪═════════╪═════════╪═════════╡
|
||||||
assets:cash ║ 0 0 1 0
|
│ assets ║ 0 │ 0 │ 1 │ 0 │
|
||||||
assets:checking ║ 10 0 0 1
|
│ assets:cash ║ 0 │ 0 │ 1 │ 0 │
|
||||||
─────────────────╫────────────────────────────────────
|
│ assets:checking ║ 10 │ 0 │ 0 │ 1 │
|
||||||
║ 10 0 2 1
|
├─────────────────╫─────────┼─────────┼─────────┼─────────┤
|
||||||
|
│ ║ 10 │ 0 │ 2 │ 1 │
|
||||||
|
└─────────────────╨─────────┴─────────┴─────────┴─────────┘
|
||||||
|
|
||||||
# ** 3. Uses ASCII tables when given --pretty=no
|
# ** 3. The legacy --pretty-tables flag does the same.
|
||||||
|
$ hledger -f balance-multicol.journal balance --pretty-tables -M
|
||||||
|
Balance changes in 2012-12-01..2013-03-31:
|
||||||
|
|
||||||
|
┌─────────────────╥─────────┬─────────┬─────────┬─────────┐
|
||||||
|
│ ║ 2012-12 │ 2013-01 │ 2013-02 │ 2013-03 │
|
||||||
|
╞═════════════════╬═════════╪═════════╪═════════╪═════════╡
|
||||||
|
│ assets ║ 0 │ 0 │ 1 │ 0 │
|
||||||
|
│ assets:cash ║ 0 │ 0 │ 1 │ 0 │
|
||||||
|
│ assets:checking ║ 10 │ 0 │ 0 │ 1 │
|
||||||
|
├─────────────────╫─────────┼─────────┼─────────┼─────────┤
|
||||||
|
│ ║ 10 │ 0 │ 2 │ 1 │
|
||||||
|
└─────────────────╨─────────┴─────────┴─────────┴─────────┘
|
||||||
|
|
||||||
|
# ** 4. With no --pretty option, tables use the original ASCII style.
|
||||||
|
$ hledger -f balance-multicol.journal balance -M
|
||||||
|
Balance changes in 2012-12-01..2013-03-31:
|
||||||
|
|
||||||
|
|| 2012-12 2013-01 2013-02 2013-03
|
||||||
|
=================++====================================
|
||||||
|
assets || 0 0 1 0
|
||||||
|
assets:cash || 0 0 1 0
|
||||||
|
assets:checking || 10 0 0 1
|
||||||
|
-----------------++------------------------------------
|
||||||
|
|| 10 0 2 1
|
||||||
|
|
||||||
|
# ** 5. --pretty=no does the same.
|
||||||
$ hledger -f balance-multicol.journal balance --pretty=no -M
|
$ hledger -f balance-multicol.journal balance --pretty=no -M
|
||||||
Balance changes in 2012-12-01..2013-03-31:
|
Balance changes in 2012-12-01..2013-03-31:
|
||||||
|
|
||||||
@ -35,14 +65,3 @@ Balance changes in 2012-12-01..2013-03-31:
|
|||||||
-----------------++------------------------------------
|
-----------------++------------------------------------
|
||||||
|| 10 0 2 1
|
|| 10 0 2 1
|
||||||
|
|
||||||
# ** 4. Still accepts the legacy --pretty-tables for now
|
|
||||||
$ hledger -f balance-multicol.journal balance --pretty-tables -M
|
|
||||||
Balance changes in 2012-12-01..2013-03-31:
|
|
||||||
|
|
||||||
║ 2012-12 2013-01 2013-02 2013-03
|
|
||||||
═════════════════╬════════════════════════════════════
|
|
||||||
assets ║ 0 0 1 0
|
|
||||||
assets:cash ║ 0 0 1 0
|
|
||||||
assets:checking ║ 10 0 0 1
|
|
||||||
─────────────────╫────────────────────────────────────
|
|
||||||
║ 10 0 2 1
|
|
||||||
|
@ -219,28 +219,31 @@ Balance Sheet 2017-12-31
|
|||||||
=============++=====================
|
=============++=====================
|
||||||
Net: || $1 $1
|
Net: || $1 $1
|
||||||
|
|
||||||
# ** 9. --pretty=yes uses unicode chars for borders
|
# ** 9. With --pretty, tables use box-drawing characters and more borders.
|
||||||
<
|
<
|
||||||
2016/1/1
|
2016/1/1
|
||||||
assets 1
|
assets 1
|
||||||
b
|
b
|
||||||
$ hledger -f - balancesheet -M --pretty=yes
|
|
||||||
|
$ hledger -f - balancesheet -M --pretty
|
||||||
Balance Sheet 2016-01-31
|
Balance Sheet 2016-01-31
|
||||||
|
|
||||||
║ 2016-01-31
|
┌─────────────╥────────────┐
|
||||||
═════════════╬════════════
|
│ ║ 2016-01-31 │
|
||||||
Assets ║
|
╞═════════════╬════════════╡
|
||||||
─────────────╫────────────
|
│ Assets ║ │
|
||||||
assets ║ 1
|
├─────────────╫────────────┤
|
||||||
─────────────╫────────────
|
│ assets ║ 1 │
|
||||||
║ 1
|
├─────────────╫────────────┤
|
||||||
═════════════╬════════════
|
│ ║ 1 │
|
||||||
Liabilities ║
|
╞═════════════╬════════════╡
|
||||||
─────────────╫────────────
|
│ Liabilities ║ │
|
||||||
─────────────╫────────────
|
├─────────────╫────────────┤
|
||||||
║ 0
|
├─────────────╫────────────┤
|
||||||
═════════════╬════════════
|
│ ║ 0 │
|
||||||
Net: ║ 1
|
╞═════════════╬════════════╡
|
||||||
|
│ Net: ║ 1 │
|
||||||
|
└─────────────╨────────────┘
|
||||||
|
|
||||||
# ** 10. Check that accounts brought to zero by subaccount balances
|
# ** 10. Check that accounts brought to zero by subaccount balances
|
||||||
# are not erased from balancesheet
|
# are not erased from balancesheet
|
||||||
|
Loading…
Reference in New Issue
Block a user