From dbba128f29b7631487b91d3e055e48db113a3af4 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 15 Nov 2010 23:01:47 +0000 Subject: [PATCH] web: sync with recent refactoring --- hledger-web/Hledger/Web/App.hs | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/hledger-web/Hledger/Web/App.hs b/hledger-web/Hledger/Web/App.hs index ed717f138..abd07da3c 100644 --- a/hledger-web/Hledger/Web/App.hs +++ b/hledger-web/Hledger/Web/App.hs @@ -16,7 +16,6 @@ import Data.Either -- import System.Directory import System.FilePath ((), takeFileName) import System.IO.Storage (putValue, getValue) -import Text.ParserCombinators.Parsec (parse) import Database.Persist.GenericSql (ConnectionPool, SqlPersist, runMigration, migrate) import Yesod @@ -848,8 +847,8 @@ postAddForm = do descE = Right $ fromMaybe "" descM acct1E = maybe (Left "to account required") Right acct1M acct2E = maybe (Left "from account required") Right acct2M - amt1E = maybe (Left "amount required") (either (const $ Left "could not parse amount") Right . parse someamount "") amt1M - amt2E = maybe (Right missingamt) (either (const $ Left "could not parse amount") Right . parse someamount "") amt2M + amt1E = maybe (Left "amount required") (either (const $ Left "could not parse amount") Right . parseWithCtx nullctx someamount) amt1M + amt2E = maybe (Right missingamt) (either (const $ Left "could not parse amount") Right . parseWithCtx nullctx someamount) amt2M journalE = maybe (Right $ journalFilePath j) (\f -> if f `elem` journalFilePaths j then Right f @@ -865,16 +864,11 @@ postAddForm = do | otherwise = either (\e -> Left ["unbalanced postings: " ++ (head $ lines e)]) Right (balanceTransaction $ nulltransaction { tdate=parsedate date - ,teffectivedate=Nothing - ,tstatus=False - ,tcode="" ,tdescription=desc - ,tcomment="" ,tpostings=[ - Posting False acct1 amt1 "" RegularPosting Nothing - ,Posting False acct2 amt2 "" RegularPosting Nothing + Posting False acct1 amt1 "" RegularPosting [] Nothing + ,Posting False acct2 amt2 "" RegularPosting [] Nothing ] - ,tpreceding_comment_lines="" }) -- display errors or add transaction case tE of @@ -1008,16 +1002,16 @@ mixedAmountAsHtml b = preEscapedString $ addclass $ intercalate "
" $ lines $ ---------------------------------------------------------------------- -- | A standalone journal edit form page. -getEditR :: Handler RepHtml -getEditR = do - (a, p, _, _, _, msg, here) <- getHandlerData - today <- liftIO getCurrentDay - -- reload journal's text without parsing, if changed -- XXX are we doing this right ? - j <- liftIO $ fromJust `fmap` getValue "hledger" "journal" - changed <- liftIO $ journalFileIsNewer j - s <- liftIO $ if changed then readFile (filepath j) else return (jtext j) -- XXX readFile may throw an error - let td = mktd{here=here, title="hledger journal edit", msg=msg, a=a, p=p, j=j, today=today} - hamletToRepHtml $ pageLayout td $ editform td s +-- getEditR :: Handler RepHtml +-- getEditR = do +-- (a, p, _, _, _, msg, here) <- getHandlerData +-- today <- liftIO getCurrentDay +-- -- reload journal's text without parsing, if changed -- XXX are we doing this right ? +-- j <- liftIO $ fromJust `fmap` getValue "hledger" "journal" +-- changed <- liftIO $ journalFileIsNewer j +-- s <- liftIO $ if changed then readFile (filepath j) else return (jtext j) -- XXX readFile may throw an error +-- let td = mktd{here=here, title="hledger journal edit", msg=msg, a=a, p=p, j=j, today=today} +-- hamletToRepHtml $ pageLayout td $ editform td s ----------------------------------------------------------------------