mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 07:13:12 +00:00
fix(work-orders): never return a severity on an Overdue board row
A standalone severity patch on an Overdue WO still stores the value, because the board patches severity before type when correcting Overdue to Emergency/Reactive and that write must not be dropped or rejected. Project the severity as null for Overdue in the board row mapping, which also feeds the PATCH response, search results and the detail view, so a stored value never surfaces on a type that carries no severity.
This commit is contained in:
parent
c1910e5310
commit
47060f6a73
2 changed files with 35 additions and 2 deletions
|
|
@ -147,7 +147,12 @@ namespace SeaHaven.Services.Implementation
|
||||||
MediaCount = row.MediaCount,
|
MediaCount = row.MediaCount,
|
||||||
CompletedDate = row.CompletedDate,
|
CompletedDate = row.CompletedDate,
|
||||||
FlagColor = row.FlagColor,
|
FlagColor = row.FlagColor,
|
||||||
Severity = WorkOrderSeverityRules.ParseLevel(row.Severity),
|
// Overdue never carries a severity. A standalone severity patch can still
|
||||||
|
// store one (the board patches severity before type when correcting Overdue
|
||||||
|
// to Emergency/Reactive), so the row never returns it for an Overdue WO.
|
||||||
|
Severity = row.WorkOrderType == WorkOrderType.Overdue
|
||||||
|
? null
|
||||||
|
: WorkOrderSeverityRules.ParseLevel(row.Severity),
|
||||||
PrimaryDispatchId = row.PrimaryDispatchId,
|
PrimaryDispatchId = row.PrimaryDispatchId,
|
||||||
RowVersion = row.RowVersion,
|
RowVersion = row.RowVersion,
|
||||||
DispatchRowVersion = row.DispatchRowVersion,
|
DispatchRowVersion = row.DispatchRowVersion,
|
||||||
|
|
|
||||||
|
|
@ -202,12 +202,13 @@ public class WorkOrderOverdueTypeTests
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
var service = NewUpdateService(context);
|
var service = NewUpdateService(context);
|
||||||
|
|
||||||
await service.PatchFieldAsync(1, new WorkOrderBoardPatchRequestDto
|
var severityStep = await service.PatchFieldAsync(1, new WorkOrderBoardPatchRequestDto
|
||||||
{
|
{
|
||||||
Field = WorkOrderBoardFieldNames.Severity,
|
Field = WorkOrderBoardFieldNames.Severity,
|
||||||
Value = "2",
|
Value = "2",
|
||||||
WorkOrderVersion = ToVersion(wo)
|
WorkOrderVersion = ToVersion(wo)
|
||||||
}, "actor-1");
|
}, "actor-1");
|
||||||
|
Assert.Null(severityStep.Severity);
|
||||||
|
|
||||||
var updated = await context.workOrders.SingleAsync(w => w.Id == 1);
|
var updated = await context.workOrders.SingleAsync(w => w.Id == 1);
|
||||||
var result = await service.PatchFieldAsync(1, new WorkOrderBoardPatchRequestDto
|
var result = await service.PatchFieldAsync(1, new WorkOrderBoardPatchRequestDto
|
||||||
|
|
@ -224,6 +225,33 @@ public class WorkOrderOverdueTypeTests
|
||||||
Assert.Equal("2", persisted.Severity);
|
Assert.Equal("2", persisted.Severity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A severity patch with no following type change leaves a stored value on an
|
||||||
|
// Overdue WO; the board row still reports no severity.
|
||||||
|
[Fact]
|
||||||
|
public async Task PatchSeverity_OnOverdue_RowShowsNoSeverity()
|
||||||
|
{
|
||||||
|
await using var context = NewContext();
|
||||||
|
var wo = new WorkOrder
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
LifecycleStatus = LifecycleStatus.Scheduled,
|
||||||
|
WorkOrderType = WorkOrderType.Overdue,
|
||||||
|
RowVersion = new byte[] { 1, 0, 0, 0, 0, 0, 0, 1 }
|
||||||
|
};
|
||||||
|
context.workOrders.Add(wo);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
|
var result = await NewUpdateService(context).PatchFieldAsync(1, new WorkOrderBoardPatchRequestDto
|
||||||
|
{
|
||||||
|
Field = WorkOrderBoardFieldNames.Severity,
|
||||||
|
Value = "3",
|
||||||
|
WorkOrderVersion = ToVersion(wo)
|
||||||
|
}, "actor-1");
|
||||||
|
|
||||||
|
Assert.Equal(WorkOrderType.Overdue, result.WorkOrderType);
|
||||||
|
Assert.Null(result.Severity);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task PatchType_PmWithPmService_ToOverdue_KeepsService()
|
public async Task PatchType_PmWithPmService_ToOverdue_KeepsService()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue