mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-10-04 02:03:20 +00:00
Extract zip code from location address as fallback for distance calc
- Regex extracts 5-digit zip from address string when ZipCode field is empty - Enables distance calculation for synced locations without structured zip data
This commit is contained in:
parent
521bb0fba2
commit
b072d1fa2d
1 changed files with 8 additions and 1 deletions
|
|
@ -610,7 +610,7 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
assignee = s.AssignToUser != null ? s.AssignToUser.FirstName : "",
|
assignee = s.AssignToUser != null ? s.AssignToUser.FirstName : "",
|
||||||
location = s.Locations != null ? s.Locations.Name : "",
|
location = s.Locations != null ? s.Locations.Name : "",
|
||||||
locationId = s.LocationId,
|
locationId = s.LocationId,
|
||||||
locationZip = s.Locations != null ? s.Locations.ZipCode : "",
|
locationZip = s.Locations != null ? (s.Locations.ZipCode ?? ExtractZip(s.Locations.Address)) : "",
|
||||||
priority = s.Priority,
|
priority = s.Priority,
|
||||||
s.Problem,
|
s.Problem,
|
||||||
s.Trade,
|
s.Trade,
|
||||||
|
|
@ -1115,6 +1115,13 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
return Ok(data);
|
return Ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string? ExtractZip(string? address)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(address)) return null;
|
||||||
|
var match = System.Text.RegularExpressions.Regex.Match(address, @"\b(\d{5})(?:-\d{4})?\b");
|
||||||
|
return match.Success ? match.Groups[1].Value : null;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<string> GenerateInternalWONumber()
|
private async Task<string> GenerateInternalWONumber()
|
||||||
{
|
{
|
||||||
var lastWO = await _db.workOrders
|
var lastWO = await _db.workOrders
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue