fix(vendors): keep company location authoritative

This commit is contained in:
Alexandre Brandizzi 2026-08-25 14:07:33 -03:00
parent 4f4e3997ba
commit 2461df5f71
2 changed files with 15 additions and 2 deletions

View file

@ -563,6 +563,8 @@ public class VendorDataServiceTests
CompanyName = "Addr Co",
ContactName = "Pat",
Address = "9 Old Street",
City = "Oldtown",
State = "OT",
IsActive = true,
IsDeleted = false,
Company = company
@ -577,6 +579,9 @@ public class VendorDataServiceTests
var stale = await service.GetDirectoryPagedAsync(1, 50, search: "9 old street", isActive: true);
stale.TotalCount.Should().Be(0);
var staleCity = await service.GetDirectoryPagedAsync(1, 50, search: "oldtown", isActive: true);
staleCity.TotalCount.Should().Be(0);
}
[Fact]
@ -600,6 +605,8 @@ public class VendorDataServiceTests
{
CompanyName = "Addr Only Co",
ContactName = "Pat",
City = "Oldtown",
State = "OT",
IsActive = true,
IsDeleted = false,
Company = addressOnlyCompany
@ -621,6 +628,10 @@ public class VendorDataServiceTests
var partial = await service.GetDirectoryPagedAsync(
1, 50, isActive: true, locations: new[] { "123 Main" });
partial.TotalCount.Should().Be(0);
var staleLocation = await service.GetDirectoryPagedAsync(
1, 50, isActive: true, locations: new[] { "Oldtown, OT" });
staleLocation.TotalCount.Should().Be(0);
}
[Fact]

View file

@ -208,12 +208,14 @@ namespace SeaHaven.DataServices.Implementation
: v.Address,
City = v.Company != null &&
((v.Company.City != null && v.Company.City.Trim() != "") ||
(v.Company.State != null && v.Company.State.Trim() != ""))
(v.Company.State != null && v.Company.State.Trim() != "") ||
(v.Company.Address != null && v.Company.Address.Trim() != ""))
? v.Company.City
: v.City,
State = v.Company != null &&
((v.Company.City != null && v.Company.City.Trim() != "") ||
(v.Company.State != null && v.Company.State.Trim() != ""))
(v.Company.State != null && v.Company.State.Trim() != "") ||
(v.Company.Address != null && v.Company.Address.Trim() != ""))
? v.Company.State
: v.State,
Zip = v.Zip,