mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-10-04 19:32:10 +00:00
fix(work-orders): map primary dispatch status on detail (SH-183)
This commit is contained in:
parent
75d337df0f
commit
743841d93e
2 changed files with 68 additions and 0 deletions
|
|
@ -118,6 +118,7 @@ namespace SeaHaven.Services.Implementation
|
||||||
DayGroup = row.DayGroup,
|
DayGroup = row.DayGroup,
|
||||||
VendorId = row.VendorId,
|
VendorId = row.VendorId,
|
||||||
VendorName = row.VendorName,
|
VendorName = row.VendorName,
|
||||||
|
PrimaryDispatchStatus = row.PrimaryDispatchStatus,
|
||||||
TechName = row.TechName,
|
TechName = row.TechName,
|
||||||
TechPhone = row.TechPhone,
|
TechPhone = row.TechPhone,
|
||||||
ApptDate = row.ApptDate,
|
ApptDate = row.ApptDate,
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,73 @@ public class WorkOrderDetailServiceTests
|
||||||
Assert.Equal(1500m, detail.Info.UpliftSummary.Amount);
|
Assert.Equal(1500m, detail.Info.UpliftSummary.Amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetDetail_InactivePrimaryDispatch_OmitsVendorAndMapsStatus()
|
||||||
|
{
|
||||||
|
var (context, service) = CreateSut();
|
||||||
|
|
||||||
|
context.Vendors.Add(new Vendor { Id = 1, CompanyName = "Acme HVAC" });
|
||||||
|
context.Dispatches.Add(new Dispatch
|
||||||
|
{
|
||||||
|
Id = 10,
|
||||||
|
VendorId = 1,
|
||||||
|
WorkOrderId = 1,
|
||||||
|
Status = "Refused",
|
||||||
|
ScheduledDate = new DateTime(2026, 6, 24, 8, 0, 0)
|
||||||
|
});
|
||||||
|
context.workOrders.Add(new WorkOrder
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
InternalWONumber = "10000000001",
|
||||||
|
LifecycleStatus = LifecycleStatus.Scheduled,
|
||||||
|
ScheduledDate = DateTime.UtcNow.AddDays(1),
|
||||||
|
PrimaryDispatchId = 10,
|
||||||
|
SiteCode = "BK5",
|
||||||
|
RowVersion = new byte[] { 1, 0, 0, 0, 0, 0, 0, 1 }
|
||||||
|
});
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
|
var detail = await service.GetDetailAsync(1, WorkOrderAccountTestHelpers.OrgWideAdmin());
|
||||||
|
|
||||||
|
Assert.NotNull(detail);
|
||||||
|
Assert.Null(detail!.Info.VendorId);
|
||||||
|
Assert.Null(detail.Info.VendorName);
|
||||||
|
Assert.Equal("Refused", detail.Info.PrimaryDispatchStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetDetail_LiveDispatchWithEmptyCompanyName_KeepsVendorIdAndMapsStatus()
|
||||||
|
{
|
||||||
|
var (context, service) = CreateSut();
|
||||||
|
|
||||||
|
context.Vendors.Add(new Vendor { Id = 1, CompanyName = "" });
|
||||||
|
context.Dispatches.Add(new Dispatch
|
||||||
|
{
|
||||||
|
Id = 10,
|
||||||
|
VendorId = 1,
|
||||||
|
WorkOrderId = 1,
|
||||||
|
Status = "Sent",
|
||||||
|
ScheduledDate = new DateTime(2026, 6, 24, 8, 0, 0)
|
||||||
|
});
|
||||||
|
context.workOrders.Add(new WorkOrder
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
InternalWONumber = "10000000001",
|
||||||
|
LifecycleStatus = LifecycleStatus.Scheduled,
|
||||||
|
ScheduledDate = DateTime.UtcNow.AddDays(1),
|
||||||
|
PrimaryDispatchId = 10,
|
||||||
|
SiteCode = "BK5",
|
||||||
|
RowVersion = new byte[] { 1, 0, 0, 0, 0, 0, 0, 1 }
|
||||||
|
});
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
|
var detail = await service.GetDetailAsync(1, WorkOrderAccountTestHelpers.OrgWideAdmin());
|
||||||
|
|
||||||
|
Assert.NotNull(detail);
|
||||||
|
Assert.Equal(1, detail!.Info.VendorId);
|
||||||
|
Assert.Equal("Sent", detail.Info.PrimaryDispatchStatus);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetDetail_ReturnsAdditionalContactsFromBoardRow()
|
public async Task GetDetail_ReturnsAdditionalContactsFromBoardRow()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue