a bit templating

This commit is contained in:
Stefan Dresselhaus
2015-08-07 02:26:16 +02:00
parent 617e225624
commit 9ad4be6ba4
8 changed files with 42 additions and 6 deletions

6
Handler/Stock.hs Normal file
View File

@ -0,0 +1,6 @@
module Handler.Stock where
import Import
getStockR :: Handler Html
getStockR = error "Not yet implemented: getStockR"

View File

@ -8,7 +8,6 @@ import qualified Eve.Api.Types as T
import qualified Eve.Api.Char.Standings as ST
import qualified Eve.Api.Char.Skills as SK
import Database.Persist.Sql
import qualified Debug.Trace as Debug
accountingId :: Int64
accountingId = 16622
@ -97,11 +96,7 @@ updateProfits dat = updateProfits' [] dat
t' = t {transactionInStock = transactionInStock t + m}
ct' = ct {transactionInStock = transactionInStock ct - m}
prof' = (transactionPriceCents t - transactionPriceCents ct) * m
(t'',ct'') = if prof' > 0 then
Debug.trace ("Item "++show (transactionTypeId t)++" has profit "++show prof'++" ("++show (transactionPriceCents t)++" - "++show (transactionPriceCents ct)++")*"++show m)
$ updateProfits'' (Entity et (t' { transactionProfit = maybe (Just prof') (\a -> Just (a + prof')) (transactionProfit t')})) ts
else
updateProfits'' (Entity et (t' { transactionProfit = maybe (Just prof') (\a -> Just (a + prof')) (transactionProfit t')})) ts
(t'',ct'') = updateProfits'' (Entity et (t' { transactionProfit = maybe (Just prof') (\a -> Just (a + prof')) (transactionProfit t')})) ts
in
(t'' ,(Entity cet ct'):ct'')
else

View File

@ -15,13 +15,25 @@ getWalletDetailsR hrs days = loginOrDo (\(uid,user) -> do
<a href=@{WalletDetailsR 168 days}>show last 7 days
<h1>Transactions in the last #{hrs} hours
<table>
<tr>
<th>Time
<th>Price
<th>Name
<th>Profit
$forall Entity _ t <- trans
<tr>
<td>#{show $ transactionDateTime t}
<td>#{transactionPriceCents t}
<td>#{transactionClientName t}
<td>
$maybe profit <- transRealProfit t
#{profit}
$nothing
-
<h1>Statistices for the last #{days} days
|]
)
transRealProfit :: Transaction -> Maybe Int64
transRealProfit t = (\a b c -> a - b - c) <$> transactionProfit t <*> transactionFee t <*> transactionTax t