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