Merge pull request #96 from Mic92/total-buyed-counter
add total bought counter
This commit is contained in:
commit
8098edd853
5 changed files with 11 additions and 2 deletions
|
@ -49,6 +49,7 @@ postBuyR uId bId = do
|
|||
update uId [UserTimestamp =. today]
|
||||
update uId [UserBalance -=. price]
|
||||
update bId [BeverageAmount -=. quant]
|
||||
update bId [BeverageTotalBought +=. 1]
|
||||
checkAlert bId
|
||||
master <- getYesod
|
||||
liftIO $ notifyUser user bev quant price master
|
||||
|
|
|
@ -91,6 +91,7 @@ postNewArticleR = do
|
|||
(modBevAvatar nBev)
|
||||
(modBevSupp nBev)
|
||||
(modBevMaxAmount nBev)
|
||||
0
|
||||
(modBevPC nBev)
|
||||
(modBevArtNr nBev)
|
||||
(modBevPricePC nBev)
|
||||
|
|
|
@ -49,6 +49,7 @@ data BevStore = BevStore
|
|||
, bevStoreAmount :: Int
|
||||
, bevStoreLostAmount :: Int
|
||||
, bevStoreMaxAmount :: Int
|
||||
, bevStoreTotalBought :: Int
|
||||
, bevStorePerCrate :: Maybe Int
|
||||
, bevStoreAlertAmount :: Int
|
||||
, bevStoreMl :: Int
|
||||
|
@ -57,7 +58,7 @@ data BevStore = BevStore
|
|||
}
|
||||
|
||||
instance ToJSON BevStore where
|
||||
toJSON (BevStore ident price amount loss maxAmount perCrate alertAmount ml artNr ppc) =
|
||||
toJSON (BevStore ident price amount loss maxAmount totalBought perCrate alertAmount ml artNr ppc) =
|
||||
object
|
||||
[ "name" .= ident
|
||||
, "price" .= price
|
||||
|
@ -65,6 +66,7 @@ instance ToJSON BevStore where
|
|||
, "lost_amount" .= loss
|
||||
, "alertAt" .= alertAmount
|
||||
, "max" .= maxAmount
|
||||
, "total_bought" .= totalBought
|
||||
, "perCrate" .= perCrate
|
||||
, "ml" .= ml
|
||||
, "artNr" .= artNr
|
||||
|
@ -78,6 +80,7 @@ instance FromJSON BevStore where
|
|||
<*> o .: "amount"
|
||||
<*> o .: "lost_amount"
|
||||
<*> o .: "max"
|
||||
<*> o .: "total_bought"
|
||||
<*> o .:? "perCrate"
|
||||
<*> o .: "alertAt"
|
||||
<*> o .: "ml"
|
||||
|
@ -97,6 +100,7 @@ getInventoryJsonR = do
|
|||
(beverageAmount bev)
|
||||
(beverageCorrectedAmount bev)
|
||||
(beverageMaxAmount bev)
|
||||
(beverageTotalBought bev)
|
||||
(beveragePerCrate bev)
|
||||
(beverageAlertAmount bev)
|
||||
(beverageMl bev)
|
||||
|
@ -147,6 +151,7 @@ insOrUpd bev = do
|
|||
Nothing
|
||||
Nothing
|
||||
(bevStoreMaxAmount bev)
|
||||
(bevStoreTotalBought bev)
|
||||
(bevStorePerCrate bev)
|
||||
(bevStoreArtNr bev)
|
||||
(bevStorePricePerCrate bev)
|
||||
|
@ -158,6 +163,7 @@ insOrUpd bev = do
|
|||
, BeverageAlertAmount =. bevStoreAlertAmount bev
|
||||
, BeverageMl =. bevStoreMl bev
|
||||
, BeverageMaxAmount =. bevStoreMaxAmount bev
|
||||
, BeverageTotalBought =. bevStoreTotalBought bev
|
||||
, BeveragePerCrate =. bevStorePerCrate bev
|
||||
, BeverageArtNr =. bevStoreArtNr bev
|
||||
, BeveragePricePerCrate =. bevStorePricePerCrate bev
|
||||
|
|
|
@ -17,6 +17,7 @@ Beverage
|
|||
avatar AvatarId Maybe
|
||||
supplier SupplierId Maybe
|
||||
maxAmount Int default=0
|
||||
totalBought Int default=0
|
||||
perCrate Int Maybe
|
||||
artNr Text Maybe
|
||||
pricePerCrate Int Maybe
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: yammat
|
||||
version: 0.0.5
|
||||
version: 0.0.6
|
||||
cabal-version: >= 1.8
|
||||
build-type: Simple
|
||||
license: AGPL-3
|
||||
|
|
Loading…
Reference in a new issue