fixed total loss prime price
This commit is contained in:
parent
813fd73712
commit
894d5a1b53
1 changed files with 2 additions and 1 deletions
|
@ -17,6 +17,7 @@ module Handler.Statistics where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
import Data.List hiding (length)
|
import Data.List hiding (length)
|
||||||
|
import Data.Maybe (fromJust)
|
||||||
|
|
||||||
getStatisticsR :: Handler RepJson
|
getStatisticsR :: Handler RepJson
|
||||||
getStatisticsR = do
|
getStatisticsR = do
|
||||||
|
@ -36,7 +37,7 @@ getStatisticsR = do
|
||||||
archdevils <- runDB $ selectList [UserBalance <. -5000] []
|
archdevils <- runDB $ selectList [UserBalance <. -5000] []
|
||||||
bevs <- runDB $ selectList [] [Asc BeverageId]
|
bevs <- runDB $ selectList [] [Asc BeverageId]
|
||||||
totalLossPrime <- return $ foldl (\acc (Entity _ bev) ->
|
totalLossPrime <- return $ foldl (\acc (Entity _ bev) ->
|
||||||
let primePrice = (fromIntegral $ fromMaybe 0 (beveragePricePerCrate bev)) / (fromIntegral $ fromMaybe 1 (beveragePerCrate bev))
|
let primePrice = if not (isNothing (beveragePricePerCrate bev) && isNothing (beveragePerCrate bev)) then (fromIntegral $ fromJust (beveragePricePerCrate bev)) / (fromIntegral $ fromJust (beveragePerCrate bev)) else 0
|
||||||
in acc + (((fromIntegral $ beverageCorrectedAmount bev) * primePrice) / 100)
|
in acc + (((fromIntegral $ beverageCorrectedAmount bev) * primePrice) / 100)
|
||||||
) 0 bevs
|
) 0 bevs
|
||||||
totalLossRetail <- return $ foldl (\acc (Entity _ bev) ->
|
totalLossRetail <- return $ foldl (\acc (Entity _ bev) ->
|
||||||
|
|
Loading…
Reference in a new issue