mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-21 21:33:02 +01:00
Exclude items that have a solddate from total price calculation
This commit is contained in:
@@ -88,6 +88,9 @@ func (ctrl *V1Controller) HandleItemsGetAll() errchain.HandlerFunc {
|
|||||||
items, err := ctrl.repo.Items.QueryByGroup(ctx, ctx.GID, extractQuery(r))
|
items, err := ctrl.repo.Items.QueryByGroup(ctx, ctx.GID, extractQuery(r))
|
||||||
totalPrice := new(big.Int)
|
totalPrice := new(big.Int)
|
||||||
for _, item := range items.Items {
|
for _, item := range items.Items {
|
||||||
|
if !item.SoldTime.IsZero() { // Skip items with a non-null SoldDate
|
||||||
|
continue
|
||||||
|
}
|
||||||
totalPrice.Add(totalPrice, big.NewInt(int64(item.PurchasePrice*100)))
|
totalPrice.Add(totalPrice, big.NewInt(int64(item.PurchasePrice*100)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,6 +99,11 @@ func (ctrl *V1Controller) GetLocationWithPrice(auth context.Context, gid uuid.UU
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range items.Items {
|
for _, item := range items.Items {
|
||||||
|
// Skip items with a non-zero SoldTime
|
||||||
|
if !item.SoldTime.IsZero() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Convert item.Quantity to float64 for multiplication
|
// Convert item.Quantity to float64 for multiplication
|
||||||
quantity := float64(item.Quantity)
|
quantity := float64(item.Quantity)
|
||||||
itemTotal := big.NewInt(int64(item.PurchasePrice * quantity * 100))
|
itemTotal := big.NewInt(int64(item.PurchasePrice * quantity * 100))
|
||||||
|
|||||||
@@ -134,6 +134,9 @@ type (
|
|||||||
Labels []LabelSummary `json:"labels"`
|
Labels []LabelSummary `json:"labels"`
|
||||||
|
|
||||||
ImageID *uuid.UUID `json:"imageId,omitempty"`
|
ImageID *uuid.UUID `json:"imageId,omitempty"`
|
||||||
|
|
||||||
|
// Sale details
|
||||||
|
SoldTime time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemOut struct {
|
ItemOut struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user