diff --git a/backend/app/api/handlers/v1/v1_ctrl_items.go b/backend/app/api/handlers/v1/v1_ctrl_items.go index 6582adac..7242aa54 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_items.go +++ b/backend/app/api/handlers/v1/v1_ctrl_items.go @@ -88,6 +88,9 @@ func (ctrl *V1Controller) HandleItemsGetAll() errchain.HandlerFunc { items, err := ctrl.repo.Items.QueryByGroup(ctx, ctx.GID, extractQuery(r)) totalPrice := new(big.Int) 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))) } diff --git a/backend/app/api/handlers/v1/v1_ctrl_locations.go b/backend/app/api/handlers/v1/v1_ctrl_locations.go index f8099b7a..33f93b30 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_locations.go +++ b/backend/app/api/handlers/v1/v1_ctrl_locations.go @@ -99,6 +99,11 @@ func (ctrl *V1Controller) GetLocationWithPrice(auth context.Context, gid uuid.UU } for _, item := range items.Items { + // Skip items with a non-zero SoldTime + if !item.SoldTime.IsZero() { + continue + } + // Convert item.Quantity to float64 for multiplication quantity := float64(item.Quantity) itemTotal := big.NewInt(int64(item.PurchasePrice * quantity * 100)) diff --git a/backend/internal/data/repo/repo_items.go b/backend/internal/data/repo/repo_items.go index 854f28c1..fd4f3aac 100644 --- a/backend/internal/data/repo/repo_items.go +++ b/backend/internal/data/repo/repo_items.go @@ -134,6 +134,9 @@ type ( Labels []LabelSummary `json:"labels"` ImageID *uuid.UUID `json:"imageId,omitempty"` + + // Sale details + SoldTime time.Time `json:"updatedAt"` } ItemOut struct {