package adapters import ( "time" oppintel "github.com/missionworkforce/missionmatch/internal/modules/opportunity_intelligence" "github.com/missionworkforce/missionmatch/internal/platform/samawards" ) // fromSAMAward converts a normalized SAM contract award into a unified contract award record. The // recipient is the incumbent, the dollar figure is the contract ceiling (base and all options) falling // back to the obligated amount, and value_source is sam because the figure came from SAM. A nil amount // stays nil, never a fabricated zero. func fromSAMAward(a samawards.Award, fetchedAt time.Time) oppintel.OpportunityRecord { rec := oppintel.OpportunityRecord{ SourceName: "SAM Contract Awards", SourceRecordID: a.UniqueKey, DedupeKey: dedupe(a.PIID, a.UniqueKey), Kind: oppintel.KindContractAward, Title: a.Description, Agency: a.Department, SubAgency: a.Subtier, NAICS: a.NAICSCode, SetAside: a.SetAside, IncumbentName: a.AwardeeName, IncumbentUEI: a.AwardeeUEI, AwardDate: a.DateSigned, PopStart: a.POPStart, PopEnd: a.POPEnd, FetchedAt: fetchedAt, Raw: a.Raw, } value := a.TotalValue if value == nil { value = a.ObligatedValue } if value != nil { rec.EstimatedValue = value rec.ValueSource = "sam" } return rec }