Skip to content

Commit

Permalink
Change Reappro so we don't calculate ttc from ht (#76)
Browse files Browse the repository at this point in the history
* Update the item state to put it Buyable if you do a restock

* Update bundle_cost_ttc in NewRestockItem interface and related code

* Refactor restock creation and update bundle costs

* Add bundle_cost_ttc field to RestockItem interface and bar.openapi.yml and calculate price Coutant with bundleCostTtc

* Update restock logic and add new fields in reappro page

* remove useless log
  • Loading branch information
BaptTF committed Apr 6, 2024
1 parent 2abe072 commit d550f43
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 131 deletions.
23 changes: 12 additions & 11 deletions backend/api/restock.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (s *Server) CreateRestock(c echo.Context) error {
AmountOfBundle: item.AmountOfBundle,
AmountPerBundle: item.AmountPerBundle,
BundleCostHt: item.BundleCostHt,
BundleCostTtc: item.BundleCostTtc,
ItemId: item.ItemId,
Tva: item.Tva,
}
Expand All @@ -104,31 +105,31 @@ func (s *Server) CreateRestock(c echo.Context) error {
item.State = autogen.ItemBuyable
item.AmountLeft += restockItem.AmountOfBundle * restockItem.AmountPerBundle
item.LastTva = &restockItem.Tva
item.Prices.Coutant = uint64(math.Ceil((10000.0 + float64(restockItem.Tva)) * float64(restockItem.BundleCostHt) / (10000.0 * float64(restockItem.AmountPerBundle))))
item.Prices.Coutant = uint64(math.Ceil(float64(restockItem.BundleCostTtc) / (float64(restockItem.AmountPerBundle))))
if item.Prices.Coutant < 30 {
item.Prices.Externe = arrondiAuMutilple(item.Prices.Coutant, 5) + 20
item.Prices.Ceten = arrondiAuMutilple(item.Prices.Coutant, 5) + 10
item.Prices.StaffBar = arrondiAuMutilple(item.Prices.Coutant, 5) + 5
item.Prices.Privilegies = arrondiAuMutilple(item.Prices.Coutant, 5) + 5
item.Prices.Menu = arrondiAuMutilple(item.Prices.Coutant, 5) + 10
item.Prices.Menu = arrondiAuMutilple(item.Prices.Coutant, 5) + 10
} else if item.Prices.Coutant >= 30 && item.Prices.Coutant < 130 {
item.Prices.Externe = arrondiAuMutilple(item.Prices.Coutant*3/2, 5)
item.Prices.Ceten = arrondiAuMutilple(item.Prices.Coutant*113/100, 5)
item.Prices.StaffBar = arrondiAuMutilple(item.Prices.Coutant*108/100, 5)
item.Prices.Ceten = arrondiAuMutilple(item.Prices.Coutant*113/100, 5)
item.Prices.StaffBar = arrondiAuMutilple(item.Prices.Coutant*108/100, 5)
item.Prices.Privilegies = arrondiAuMutilple(item.Prices.Coutant*11/10, 5)
item.Prices.Menu = arrondiAuMutilple(item.Prices.Coutant*13/10, 5)
item.Prices.Menu = arrondiAuMutilple(item.Prices.Coutant*13/10, 5)
} else if item.Prices.Coutant >= 130 && item.Prices.Coutant < 300 {
item.Prices.Externe = arrondiAuMutilple(item.Prices.Coutant*14/10, 5)
item.Prices.Ceten = arrondiAuMutilple(item.Prices.Coutant*11/10, 5)
item.Prices.StaffBar = arrondiAuMutilple(item.Prices.Coutant*108/100, 5)
item.Prices.Ceten = arrondiAuMutilple(item.Prices.Coutant*11/10, 5)
item.Prices.StaffBar = arrondiAuMutilple(item.Prices.Coutant*108/100, 5)
item.Prices.Privilegies = arrondiAuMutilple(item.Prices.Coutant*11/10, 5)
item.Prices.Menu = arrondiAuMutilple(item.Prices.Coutant*12/10, 5)
item.Prices.Menu = arrondiAuMutilple(item.Prices.Coutant*12/10, 5)
} else if item.Prices.Coutant >= 300 {
item.Prices.Externe = arrondiAuMutilple(item.Prices.Coutant*125/100, 5)
item.Prices.Ceten = arrondiAuMutilple(item.Prices.Coutant*11/10, 5)
item.Prices.StaffBar = arrondiAuMutilple(item.Prices.Coutant*105/100, 5)
item.Prices.Ceten = arrondiAuMutilple(item.Prices.Coutant*11/10, 5)
item.Prices.StaffBar = arrondiAuMutilple(item.Prices.Coutant*105/100, 5)
item.Prices.Privilegies = arrondiAuMutilple(item.Prices.Coutant*11/10, 5)
item.Prices.Menu = arrondiAuMutilple(item.Prices.Coutant*1125/1000, 5)
item.Prices.Menu = arrondiAuMutilple(item.Prices.Coutant*1125/1000, 5)
}
err = s.DBackend.UpdateItem(c.Request().Context(), item)
if err != nil {
Expand Down
186 changes: 94 additions & 92 deletions backend/autogen/bar.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d550f43

Please sign in to comment.