From 98e3b1a89f0895081523e4209b94806666392e8e Mon Sep 17 00:00:00 2001 From: mari <2312138+masimons@users.noreply.github.com> Date: Thu, 21 Nov 2024 17:32:49 -0600 Subject: [PATCH] map forecasted fields (#3518) Co-authored-by: Laurie Reynolds --- packages/server/src/lib/grants-ingest.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/server/src/lib/grants-ingest.js b/packages/server/src/lib/grants-ingest.js index dc80aaf6c..afb4d186e 100644 --- a/packages/server/src/lib/grants-ingest.js +++ b/packages/server/src/lib/grants-ingest.js @@ -45,10 +45,15 @@ function mapSourceDataToGrant(source) { raw_body_json: source, bill: source.bill, funding_instrument_codes: (source.funding_instrument_types || []).map((it) => it.code).join(' '), + grantor_contact_name: source.grantor?.name, + grantor_contact_phone_number: source.grantor?.phone, + fiscal_year: source.fiscal_year, }; const { milestones } = source.opportunity; - grant.open_date = milestones.post_date; + grant.open_date = milestones.post_date || milestones.estimated_start_date; + grant.forecast_creation_date = milestones.forecast_creation_date; + grant.award_date = milestones.award_date; grant.close_date = milestones.close && milestones.close.date ? milestones.close.date : '2100-01-01'; grant.close_date_explanation = milestones?.close?.explanation ?? undefined; @@ -58,6 +63,10 @@ function mapSourceDataToGrant(source) { grant.opportunity_status = 'archived'; } else if (today.isSameOrAfter(moment(grant.close_date), 'date')) { grant.opportunity_status = 'closed'; + } else if (today.isBefore(moment(grant.open_date), 'date')) { + // should we check for presence of !milestones.estimated_start_date instead? + // else if (!!milestones.estimated_start_date) + grant.opportunity_status = 'forecasted'; } else { grant.opportunity_status = 'posted'; }