mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-18 17:57:11 +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 <$>
|
||||
transpose ([totalline | not (no_total_ opts)] ++ ls)
|
||||
overline = Cell TopLeft . pure . wbFromText . flip T.replicate "-" . fromMaybe 0 $ headMay sizes
|
||||
singleColumnTableOuterBorder = False
|
||||
singleColumnTableInterColumnBorder = NoLine
|
||||
singleColumnTableOuterBorder = pretty_ opts
|
||||
singleColumnTableInterColumnBorder = if pretty_ opts then SingleLine else NoLine
|
||||
|
||||
{-
|
||||
: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)
|
||||
| otherwise = id
|
||||
multiColumnTableInterRowBorder = NoLine
|
||||
multiColumnTableInterColumnBorder = NoLine
|
||||
multiColumnTableInterColumnBorder = if pretty_ opts then SingleLine else NoLine
|
||||
|
||||
multiBalanceRowAsWbs :: AmountFormat -> ReportOpts -> [DateSpan] -> PeriodicReportRow a MixedAmount -> [[WideBuilder]]
|
||||
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
|
||||
where
|
||||
tableopts = def{tableBorders=multiColumnTableOuterBorder, prettyTable=pretty_}
|
||||
multiColumnTableOuterBorder = False
|
||||
multiColumnTableOuterBorder = pretty_
|
||||
|
||||
renderCh :: [Text] -> [Cell]
|
||||
renderCh
|
||||
@ -868,10 +868,13 @@ budgetReportAsTable ReportOpts{..} (PeriodicReport spans items totrow) =
|
||||
maybetransposetable $
|
||||
addtotalrow $
|
||||
Table
|
||||
(Group NoLine $ map Header accts)
|
||||
(Group NoLine $ map Header colheadings)
|
||||
(Group budgetTableInterRowBorder $ map Header accts)
|
||||
(Group budgetTableInterColumnBorder $ map Header colheadings)
|
||||
rows
|
||||
where
|
||||
budgetTableInterRowBorder = NoLine
|
||||
budgetTableInterColumnBorder = if pretty_ then SingleLine else NoLine
|
||||
|
||||
maybetransposetable
|
||||
| transpose_ = \(Table rh ch vals) -> Table ch rh (transpose vals)
|
||||
| otherwise = id
|
||||
|
@ -1,29 +1,59 @@
|
||||
# * --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
|
||||
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
|
||||
┌─────────────────╥─────────┬─────────┬─────────┬─────────┐
|
||||
│ ║ 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 │
|
||||
└─────────────────╨─────────┴─────────┴─────────┴─────────┘
|
||||
|
||||
# ** 2. Uses Unicode tables when given --pretty
|
||||
# ** 2. --pretty with no argument does the same.
|
||||
$ hledger -f balance-multicol.journal balance --pretty -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
|
||||
┌─────────────────╥─────────┬─────────┬─────────┬─────────┐
|
||||
│ ║ 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 │
|
||||
└─────────────────╨─────────┴─────────┴─────────┴─────────┘
|
||||
|
||||
# ** 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
|
||||
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
|
||||
|
||||
# ** 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
|
||||
|
||||
# ** 9. --pretty=yes uses unicode chars for borders
|
||||
# ** 9. With --pretty, tables use box-drawing characters and more borders.
|
||||
<
|
||||
2016/1/1
|
||||
assets 1
|
||||
b
|
||||
$ hledger -f - balancesheet -M --pretty=yes
|
||||
|
||||
$ hledger -f - balancesheet -M --pretty
|
||||
Balance Sheet 2016-01-31
|
||||
|
||||
║ 2016-01-31
|
||||
═════════════╬════════════
|
||||
Assets ║
|
||||
─────────────╫────────────
|
||||
assets ║ 1
|
||||
─────────────╫────────────
|
||||
║ 1
|
||||
═════════════╬════════════
|
||||
Liabilities ║
|
||||
─────────────╫────────────
|
||||
─────────────╫────────────
|
||||
║ 0
|
||||
═════════════╬════════════
|
||||
Net: ║ 1
|
||||
┌─────────────╥────────────┐
|
||||
│ ║ 2016-01-31 │
|
||||
╞═════════════╬════════════╡
|
||||
│ Assets ║ │
|
||||
├─────────────╫────────────┤
|
||||
│ assets ║ 1 │
|
||||
├─────────────╫────────────┤
|
||||
│ ║ 1 │
|
||||
╞═════════════╬════════════╡
|
||||
│ Liabilities ║ │
|
||||
├─────────────╫────────────┤
|
||||
├─────────────╫────────────┤
|
||||
│ ║ 0 │
|
||||
╞═════════════╬════════════╡
|
||||
│ Net: ║ 1 │
|
||||
└─────────────╨────────────┘
|
||||
|
||||
# ** 10. Check that accounts brought to zero by subaccount balances
|
||||
# are not erased from balancesheet
|
||||
|
Loading…
Reference in New Issue
Block a user