refactor(shipping): check ALREADY_LABELED before INVALID_STATE in PurchaseLabel
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
2026-05-12 21:47:06 +02:00
parent 37ad51949b
commit a2afc47f32

View File

@@ -185,15 +185,16 @@ func (h *OrderHandler) PurchaseLabel(w http.ResponseWriter, r *http.Request) {
return
}
if order.Status != models.OrderStatusPaid {
utils.RespondError(w, http.StatusConflict, "INVALID_STATE", "only paid orders can be labeled", nil)
return
}
if order.TrackingNumber != "" {
utils.RespondError(w, http.StatusConflict, "ALREADY_LABELED", "order already has a tracking number", nil)
return
}
if order.Status != models.OrderStatusPaid {
utils.RespondError(w, http.StatusConflict, "INVALID_STATE", "only paid orders can be labeled", nil)
return
}
// Coffee.Ounces in ounces; shippo client expects kg
const ozToKg = 0.0283495
const defaultOunces = 12.0