added structure for problematic transactions
This commit is contained in:
parent
5266c5c5da
commit
445bd85ce4
@ -39,6 +39,7 @@ import Handler.Stock
|
|||||||
import Handler.ProfitItems
|
import Handler.ProfitItems
|
||||||
import Handler.Orders
|
import Handler.Orders
|
||||||
import Handler.Item
|
import Handler.Item
|
||||||
|
import Handler.Problematic
|
||||||
|
|
||||||
-- This line actually creates our YesodDispatch instance. It is the second half
|
-- This line actually creates our YesodDispatch instance. It is the second half
|
||||||
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
|
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
|
||||||
|
25
Handler/Problematic.hs
Normal file
25
Handler/Problematic.hs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
module Handler.Problematic where
|
||||||
|
|
||||||
|
import Import
|
||||||
|
|
||||||
|
problematicDaysInterval :: [Int]
|
||||||
|
problematicDaysInterval = [1,2,7,14,31]
|
||||||
|
|
||||||
|
getProblematicR :: Handler Html
|
||||||
|
getProblematicR = getProblematicDaysR 1
|
||||||
|
|
||||||
|
getProblematicDaysR :: Int -> Handler Html
|
||||||
|
getProblematicDaysR days = loginOrDo (\(uid,user) -> do
|
||||||
|
let rawSQL = "select \
|
||||||
|
max(date_time), trans_for_corp, trans_is_sell, type_id, type_name, sum(quantity) as quantity, \
|
||||||
|
sum(in_stock) as in_stock, sum(price_cents) as price_cents, station_id, station_name \
|
||||||
|
from \
|
||||||
|
transaction \
|
||||||
|
where \
|
||||||
|
\"user\"=? and CURRENT_TIMESTAMP - date_time < INTERVAL '? day' and problematic \
|
||||||
|
group by type_id, trans_for_corp, trans_is_sell, type_name, station_id, station_name \
|
||||||
|
order by max(date_time) desc"
|
||||||
|
loginLayout user $ [whamlet|
|
||||||
|
Not yet implemented.
|
||||||
|
|]
|
||||||
|
)
|
@ -16,3 +16,5 @@
|
|||||||
/orders OrdersR GET
|
/orders OrdersR GET
|
||||||
/history/#Int64 ItemR GET
|
/history/#Int64 ItemR GET
|
||||||
/history/#Int64/#Int ItemPagedR GET
|
/history/#Int64/#Int ItemPagedR GET
|
||||||
|
/transactions/problematic ProblematicR GET
|
||||||
|
/transactions/problematic/#Int ProblematicDaysR GET
|
||||||
|
@ -29,6 +29,7 @@ library
|
|||||||
Handler.ProfitItems
|
Handler.ProfitItems
|
||||||
Handler.Orders
|
Handler.Orders
|
||||||
Handler.Item
|
Handler.Item
|
||||||
|
Handler.Problematic
|
||||||
|
|
||||||
if flag(dev) || flag(library-only)
|
if flag(dev) || flag(library-only)
|
||||||
cpp-options: -DDEVELOPMENT
|
cpp-options: -DDEVELOPMENT
|
||||||
|
10
test/Handler/ProblematicSpec.hs
Normal file
10
test/Handler/ProblematicSpec.hs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
module Handler.ProblematicSpec (spec) where
|
||||||
|
|
||||||
|
import TestImport
|
||||||
|
|
||||||
|
spec :: Spec
|
||||||
|
spec = withApp $ do
|
||||||
|
|
||||||
|
describe "getProblematicR" $ do
|
||||||
|
error "Spec not implemented: getProblematicR"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user