feat(reports): simplify dashboards, align OT flow labels, and normalize filters
This commit is contained in:
@@ -234,8 +234,8 @@ func addItemH() fiber.Handler {
|
||||
}
|
||||
return fiber.NewError(500, "erro ao validar ordem")
|
||||
}
|
||||
if status == "open" && b.ChangeJustification == "" {
|
||||
return fiber.NewError(400, "justificação da alteração é obrigatória em orçamento aprovado")
|
||||
if status == "in_progress" && b.ChangeJustification == "" {
|
||||
return fiber.NewError(400, "justificação da alteração é obrigatória durante o trabalho")
|
||||
}
|
||||
item, err := AddItem(c.Context(), conn, c.Params("id"), b.CatalogItemID, b.Description, b.ChangeJustification, b.Qty, b.UnitPrice, b.DiscountPct)
|
||||
if err != nil {
|
||||
|
||||
@@ -53,8 +53,7 @@ type WorkOrderDetail struct {
|
||||
}
|
||||
|
||||
var allowedTransitions = map[string][]string{
|
||||
"quote": {"open", "cancelled"},
|
||||
"open": {"in_progress", "cancelled"},
|
||||
"quote": {"in_progress", "cancelled"},
|
||||
"in_progress": {"completed", "cancelled"},
|
||||
"completed": {"invoiced", "cancelled"},
|
||||
"invoiced": {},
|
||||
@@ -236,7 +235,7 @@ func AddItem(ctx context.Context, conn *pgxpool.Conn, woID, catalogItemID, descr
|
||||
FROM work_orders
|
||||
WHERE id=$1
|
||||
AND status NOT IN ('cancelled','invoiced')
|
||||
AND (status <> 'open' OR NULLIF($4,'') IS NOT NULL)
|
||||
AND (status <> 'in_progress' OR NULLIF($4,'') IS NOT NULL)
|
||||
RETURNING id, work_order_id, catalog_item_id, description, COALESCE(change_justification,''), qty, unit_price, discount_pct, total`,
|
||||
woID, catalogItemID, description, changeJustification, qty, unitPrice, discountPct).
|
||||
Scan(&i.ID, &i.WorkOrderID, &i.CatalogItemID, &i.Description, &i.ChangeJustification, &i.Qty, &i.UnitPrice, &i.DiscountPct, &i.Total)
|
||||
|
||||
@@ -55,9 +55,9 @@ func TestWorkOrderTransition(t *testing.T) {
|
||||
wo, err := workorder.CreateWorkOrder(ctx, conn, "", "", "", "", 1, "", "")
|
||||
require.NoError(t, err)
|
||||
|
||||
wo2, err := workorder.TransitionStatus(ctx, conn, wo.ID, "open", "", "", "")
|
||||
wo2, err := workorder.TransitionStatus(ctx, conn, wo.ID, "in_progress", "", "", "")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "open", wo2.Status)
|
||||
assert.Equal(t, "in_progress", wo2.Status)
|
||||
|
||||
_, err = workorder.TransitionStatus(ctx, conn, wo.ID, "cancelled_invalid", "", "", "")
|
||||
assert.Error(t, err, "invalid transition should error")
|
||||
@@ -69,15 +69,11 @@ func TestAllowedTransitions(t *testing.T) {
|
||||
to string
|
||||
valid bool
|
||||
}{
|
||||
{"quote", "open", true},
|
||||
{"quote", "in_progress", true},
|
||||
{"quote", "cancelled", true},
|
||||
{"quote", "in_progress", false},
|
||||
{"open", "in_progress", true},
|
||||
{"open", "cancelled", true},
|
||||
{"open", "completed", false},
|
||||
{"quote", "open", false},
|
||||
{"in_progress", "completed", true},
|
||||
{"in_progress", "cancelled", true},
|
||||
{"in_progress", "open", false},
|
||||
{"completed", "invoiced", true},
|
||||
{"completed", "cancelled", true},
|
||||
{"invoiced", "cancelled", false},
|
||||
|
||||
Reference in New Issue
Block a user