Merge pull request #16 from astro/json-export

summary.json
This commit is contained in:
rys ostrovid 2015-04-10 08:37:55 +02:00
commit de5ed7abf5
2 changed files with 16 additions and 1 deletions

View file

@ -1,7 +1,7 @@
module Handler.Summary where
import Import
import Data.List as L
import qualified Data.List as L
import Handler.Common
getSummaryR :: Handler Html
@ -10,3 +10,17 @@ getSummaryR = do
bevs <- runDB $ selectList [] [Asc BeverageIdent]
defaultLayout $ do
$(widgetFile "summary")
getSummaryJsonR :: Handler RepJson
getSummaryJsonR = do
master <- getYesod
bevs <- runDB $ selectList [] [Asc BeverageIdent]
return $
repJson $ array $
map (\(Entity _ bev) ->
object [ "name" .= beverageIdent bev
, "value" .= beverageAmount bev
, "price" .= beveragePrice bev
, "currency" .= appCurrency (appSettings master)
]
) bevs

View file

@ -19,6 +19,7 @@
/journal JournalR GET
/payout PayoutR GET POST
/summary SummaryR GET
/summary.json SummaryJsonR GET
/modify/#BeverageId ModifyR GET POST
/delete/#BeverageId DeleteBeverageR GET
/cashcheck CashCheckR GET POST