Merge branch 'master' of github.com:simonmichael/hledger
This commit is contained in:
commit
46f229316a
@ -57,13 +57,7 @@ initRegisterScreen d st@AppState{aopts=opts, ajournal=j, aScreen=s@RegisterScree
|
|||||||
q = filterQuery (not . queryIsDepth) $ queryFromOpts d ropts
|
q = filterQuery (not . queryIsDepth) $ queryFromOpts d ropts
|
||||||
|
|
||||||
-- run a transactions report, most recent last
|
-- run a transactions report, most recent last
|
||||||
q' =
|
(_label,items') = accountTransactionsReport ropts j q thisacctq
|
||||||
-- ltrace "q"
|
|
||||||
q
|
|
||||||
thisacctq' =
|
|
||||||
-- ltrace "thisacctq"
|
|
||||||
thisacctq
|
|
||||||
(_label,items') = accountTransactionsReport ropts j q' thisacctq'
|
|
||||||
items = reverse items'
|
items = reverse items'
|
||||||
|
|
||||||
-- pre-render all items; these will be the List elements. This helps calculate column widths.
|
-- pre-render all items; these will be the List elements. This helps calculate column widths.
|
||||||
|
|||||||
@ -71,7 +71,7 @@ drawTransactionScreen _ = error "draw function called with wrong screen type, sh
|
|||||||
handleTransactionScreen :: AppState -> Vty.Event -> EventM (Next AppState)
|
handleTransactionScreen :: AppState -> Vty.Event -> EventM (Next AppState)
|
||||||
handleTransactionScreen st@AppState{
|
handleTransactionScreen st@AppState{
|
||||||
aScreen=s@TransactionScreen{tsState=((i,t),nts,acct)}
|
aScreen=s@TransactionScreen{tsState=((i,t),nts,acct)}
|
||||||
,aopts=UIOpts{cliopts_=_copts}
|
,aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}
|
||||||
,ajournal=j
|
,ajournal=j
|
||||||
} e = do
|
} e = do
|
||||||
d <- liftIO getCurrentDay
|
d <- liftIO getCurrentDay
|
||||||
@ -86,7 +86,28 @@ handleTransactionScreen st@AppState{
|
|||||||
d <- liftIO getCurrentDay
|
d <- liftIO getCurrentDay
|
||||||
ej <- liftIO $ journalReload j -- (ej, changed) <- liftIO $ journalReloadIfChanged copts j
|
ej <- liftIO $ journalReload j -- (ej, changed) <- liftIO $ journalReloadIfChanged copts j
|
||||||
case ej of
|
case ej of
|
||||||
Right j' -> continue $ reload j' d st
|
Right j' -> do
|
||||||
|
-- got to redo the register screen's transactions report, to get the latest transactions list for this screen
|
||||||
|
-- XXX duplicates initRegisterScreen
|
||||||
|
let
|
||||||
|
ropts' = ropts {depth_=Nothing
|
||||||
|
,balancetype_=HistoricalBalance
|
||||||
|
}
|
||||||
|
q = filterQuery (not . queryIsDepth) $ queryFromOpts d ropts'
|
||||||
|
thisacctq = Acct $ accountNameToAccountRegex acct -- includes subs
|
||||||
|
items = reverse $ snd $ accountTransactionsReport ropts j' q thisacctq
|
||||||
|
ts = map first6 items
|
||||||
|
numberedts = zip [1..] ts
|
||||||
|
-- select the best current transaction from the new list
|
||||||
|
-- stay at the same index if possible, or if we are now past the end, select the last, otherwise select the first
|
||||||
|
(i',t') = case lookup i numberedts
|
||||||
|
of Just t'' -> (i,t'')
|
||||||
|
Nothing | null numberedts -> (0,nulltransaction)
|
||||||
|
| i > fst (last numberedts) -> last numberedts
|
||||||
|
| otherwise -> head numberedts
|
||||||
|
st' = st{aScreen=s{tsState=((i',t'),numberedts,acct)}}
|
||||||
|
continue $ reload j' d st'
|
||||||
|
|
||||||
Left err -> continue $ screenEnter d ES.screen{esState=err} st
|
Left err -> continue $ screenEnter d ES.screen{esState=err} st
|
||||||
|
|
||||||
-- Vty.EvKey (Vty.KChar 'C') [] -> continue $ reload j d $ stToggleCleared st
|
-- Vty.EvKey (Vty.KChar 'C') [] -> continue $ reload j d $ stToggleCleared st
|
||||||
|
|||||||
@ -41,7 +41,10 @@ data Screen =
|
|||||||
,sDrawFn :: AppState -> [Widget]
|
,sDrawFn :: AppState -> [Widget]
|
||||||
}
|
}
|
||||||
| TransactionScreen {
|
| TransactionScreen {
|
||||||
tsState :: ((Integer,Transaction), [(Integer,Transaction)], AccountName) -- ^ the (numbered) transaction we are viewing, a numbered list of transactions we can step through, and the account whose register we entered this screen from
|
tsState :: ((Integer,Transaction), [(Integer,Transaction)], AccountName)
|
||||||
|
-- ^ the (numbered) transaction we are currently viewing,
|
||||||
|
-- the list of numbered transactions we can step through,
|
||||||
|
-- and the account whose register we entered this screen from
|
||||||
,sInitFn :: Day -> AppState -> AppState
|
,sInitFn :: Day -> AppState -> AppState
|
||||||
,sHandleFn :: AppState -> V.Event -> EventM (Next AppState)
|
,sHandleFn :: AppState -> V.Event -> EventM (Next AppState)
|
||||||
,sDrawFn :: AppState -> [Widget]
|
,sDrawFn :: AppState -> [Widget]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user