mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
lib,cli: Export Text.Tabular from Text.Tabular.AsciiWide, clean up import lists.
This commit is contained in:
parent
fc7df75f43
commit
0e59fee251
@ -84,7 +84,6 @@ import Hledger.Data.Dates
|
||||
import Hledger.Data.Posting
|
||||
import Hledger.Data.Amount
|
||||
import Hledger.Data.Valuation
|
||||
import Text.Tabular
|
||||
import Text.Tabular.AsciiWide
|
||||
|
||||
sourceFilePath :: GenericSourcePos -> FilePath
|
||||
|
@ -46,8 +46,7 @@ import qualified Data.Text.Lazy as TL
|
||||
import qualified Data.Text.Lazy.Builder as TB
|
||||
--import System.Console.CmdArgs.Explicit as C
|
||||
--import Lucid as L
|
||||
import Text.Tabular as T
|
||||
import Text.Tabular.AsciiWide as T
|
||||
import Text.Tabular.AsciiWide as Tab
|
||||
|
||||
import Hledger.Data
|
||||
import Hledger.Utils
|
||||
@ -293,8 +292,8 @@ budgetReportAsTable
|
||||
(PeriodicReport spans rows (PeriodicReportRow _ coltots grandtot grandavg)) =
|
||||
addtotalrow $
|
||||
Table
|
||||
(T.Group NoLine $ map Header accts)
|
||||
(T.Group NoLine $ map Header colheadings)
|
||||
(Tab.Group NoLine $ map Header accts)
|
||||
(Tab.Group NoLine $ map Header colheadings)
|
||||
(map rowvals rows)
|
||||
where
|
||||
colheadings = map (reportPeriodName balancetype_ spans) spans
|
||||
|
@ -61,8 +61,8 @@ import Text.Printf (printf)
|
||||
|
||||
import Hledger.Utils.Parse
|
||||
import Hledger.Utils.Regex (toRegex', regexReplace)
|
||||
import Text.Tabular (Header(..), Properties(..))
|
||||
import Text.Tabular.AsciiWide (Align(..), TableOpts(..), textCell, renderRow)
|
||||
import Text.Tabular.AsciiWide
|
||||
(Align(..), Header(..), Properties(..), TableOpts(..), textCell, renderRow)
|
||||
import Text.WideString (charWidth, strWidth)
|
||||
|
||||
|
||||
|
@ -76,8 +76,8 @@ import qualified Data.Text.Lazy as TL
|
||||
import qualified Data.Text.Lazy.Builder as TB
|
||||
|
||||
import Hledger.Utils.Test ((@?=), test, tests)
|
||||
import Text.Tabular (Header(..), Properties(..))
|
||||
import Text.Tabular.AsciiWide (Align(..), TableOpts(..), textCell, renderRow)
|
||||
import Text.Tabular.AsciiWide
|
||||
(Align(..), Header(..), Properties(..), TableOpts(..), renderRow, textCell)
|
||||
import Text.WideString (WideBuilder(..), wbToText, wbUnpack, charWidth, textWidth)
|
||||
|
||||
|
||||
|
@ -4,7 +4,22 @@
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Text.Tabular.AsciiWide where
|
||||
module Text.Tabular.AsciiWide
|
||||
( module Text.Tabular
|
||||
|
||||
, TableOpts(..)
|
||||
, render
|
||||
, renderTable
|
||||
, renderTableB
|
||||
, renderRow
|
||||
, renderRowB
|
||||
|
||||
, Cell(..)
|
||||
, Align(..)
|
||||
, emptyCell
|
||||
, textCell
|
||||
, cellWidth
|
||||
) where
|
||||
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Data.Default (Default(..))
|
||||
|
@ -268,7 +268,6 @@ import qualified Data.Text.Lazy.Builder as TB
|
||||
import Data.Time (fromGregorian)
|
||||
import System.Console.CmdArgs.Explicit as C
|
||||
import Lucid as L
|
||||
import Text.Tabular as Tab
|
||||
import Text.Tabular.AsciiWide as Tab
|
||||
|
||||
import Hledger
|
||||
|
@ -34,7 +34,6 @@ import Hledger
|
||||
import Hledger.Read.CsvReader (CSV, CsvRecord, printCSV)
|
||||
import Hledger.Cli.CliOptions
|
||||
import Hledger.Cli.Utils
|
||||
import Text.Tabular (Header(..), Properties(..))
|
||||
import Text.Tabular.AsciiWide
|
||||
|
||||
registermode = hledgerCommandMode
|
||||
|
@ -25,8 +25,7 @@ import qualified Data.Text as T
|
||||
import qualified Data.Text.Lazy.IO as TL
|
||||
import System.Console.CmdArgs.Explicit as CmdArgs
|
||||
|
||||
import Text.Tabular as Tbl
|
||||
import Text.Tabular.AsciiWide as Ascii
|
||||
import Text.Tabular.AsciiWide as Tab
|
||||
|
||||
import Hledger
|
||||
import Hledger.Cli.CliOptions
|
||||
@ -145,14 +144,14 @@ roi CliOpts{rawopts_=rawopts, reportspec_=rspec@ReportSpec{rsOpts=ReportOpts{..}
|
||||
, T.pack $ printf "%0.2f%%" $ smallIsZero twr ]
|
||||
|
||||
let table = Table
|
||||
(Tbl.Group NoLine (map (Header . T.pack . show) (take (length tableBody) [1..])))
|
||||
(Tbl.Group DoubleLine
|
||||
[ Tbl.Group SingleLine [Header "Begin", Header "End"]
|
||||
, Tbl.Group SingleLine [Header "Value (begin)", Header "Cashflow", Header "Value (end)", Header "PnL"]
|
||||
, Tbl.Group SingleLine [Header "IRR", Header "TWR"]])
|
||||
(Tab.Group NoLine (map (Header . T.pack . show) (take (length tableBody) [1..])))
|
||||
(Tab.Group DoubleLine
|
||||
[ Tab.Group SingleLine [Header "Begin", Header "End"]
|
||||
, Tab.Group SingleLine [Header "Value (begin)", Header "Cashflow", Header "Value (end)", Header "PnL"]
|
||||
, Tab.Group SingleLine [Header "IRR", Header "TWR"]])
|
||||
tableBody
|
||||
|
||||
TL.putStrLn $ Ascii.render prettyTables id id id table
|
||||
TL.putStrLn $ Tab.render prettyTables id id id table
|
||||
|
||||
timeWeightedReturn showCashFlow prettyTables investmentsQuery trans mixedAmountValue (OneSpan spanBegin spanEnd valueBeforeAmt valueAfter cashFlow pnl) = do
|
||||
let valueBefore = unMix valueBeforeAmt
|
||||
@ -213,12 +212,12 @@ timeWeightedReturn showCashFlow prettyTables investmentsQuery trans mixedAmountV
|
||||
unitPrices = add initialUnitPrice unitPrices'
|
||||
unitBalances = add initialUnits unitBalances'
|
||||
|
||||
TL.putStr $ Ascii.render prettyTables id id T.pack
|
||||
TL.putStr $ Tab.render prettyTables id id T.pack
|
||||
(Table
|
||||
(Tbl.Group NoLine (map (Header . showDate) dates))
|
||||
(Tbl.Group DoubleLine [ Tbl.Group SingleLine [Header "Portfolio value", Header "Unit balance"]
|
||||
, Tbl.Group SingleLine [Header "Pnl", Header "Cashflow", Header "Unit price", Header "Units"]
|
||||
, Tbl.Group SingleLine [Header "New Unit Balance"]])
|
||||
(Tab.Group NoLine (map (Header . showDate) dates))
|
||||
(Tab.Group DoubleLine [ Tab.Group SingleLine [Header "Portfolio value", Header "Unit balance"]
|
||||
, Tab.Group SingleLine [Header "Pnl", Header "Cashflow", Header "Unit price", Header "Units"]
|
||||
, Tab.Group SingleLine [Header "New Unit Balance"]])
|
||||
[ [value, oldBalance, pnl, cashflow, prc, udelta, balance]
|
||||
| value <- map showDecimal valuesOnDate
|
||||
| oldBalance <- map showDecimal (0:unitBalances)
|
||||
@ -243,10 +242,10 @@ internalRateOfReturn showCashFlow prettyTables (OneSpan spanBegin spanEnd valueB
|
||||
when showCashFlow $ do
|
||||
printf "\nIRR cash flow for %s - %s\n" (showDate spanBegin) (showDate (addDays (-1) spanEnd))
|
||||
let (dates, amounts) = unzip totalCF
|
||||
TL.putStrLn $ Ascii.render prettyTables id id id
|
||||
TL.putStrLn $ Tab.render prettyTables id id id
|
||||
(Table
|
||||
(Tbl.Group NoLine (map (Header . showDate) dates))
|
||||
(Tbl.Group SingleLine [Header "Amount"])
|
||||
(Tab.Group NoLine (map (Header . showDate) dates))
|
||||
(Tab.Group SingleLine [Header "Amount"])
|
||||
(map ((:[]) . T.pack . showMixedAmount) amounts))
|
||||
|
||||
-- 0% is always a solution, so require at least something here
|
||||
|
@ -27,7 +27,7 @@ import Data.Time.Calendar (Day, addDays)
|
||||
import System.Console.CmdArgs.Explicit as C
|
||||
import Hledger.Read.CsvReader (CSV, printCSV)
|
||||
import Lucid as L hiding (value_)
|
||||
import Text.Tabular as Tab
|
||||
import Text.Tabular.AsciiWide as Tab
|
||||
|
||||
import Hledger
|
||||
import Hledger.Cli.Commands.Balance
|
||||
|
Loading…
Reference in New Issue
Block a user