diff --git a/fec/fec/static/js/widgets/contributions-by-state-box.js b/fec/fec/static/js/widgets/contributions-by-state-box.js index 6cfb598cce..b9898a465c 100644 --- a/fec/fec/static/js/widgets/contributions-by-state-box.js +++ b/fec/fec/static/js/widgets/contributions-by-state-box.js @@ -52,7 +52,13 @@ function formatAsCurrency(passedValue, roundToWhole = true) { * @param {String} stateID Optional. A null value will not filter for any state but show entries for the entire country * @returns {String} URL or empty string depending on */ -function buildIndividualContributionsUrl(cycle, office, committeeIDs, stateID) { +function buildIndividualContributionsUrl( + cycle, + office, + committeeIDs, + stateID, + candidateState +) { // If we're missing required params, just return '' and be done if (!cycle || !office || !committeeIDs) return ''; @@ -64,10 +70,13 @@ function buildIndividualContributionsUrl(cycle, office, committeeIDs, stateID) { // The API currently wants a two_year_transaction_period value for each set of two years // so we'll add the previous two-year period for presidential races - if (office == 'P') + // + // Also, Puerto Rico's House elections are for four years so we'll need to + // add the previous two-year period to the query string for House candidates from Puerto Rico + if (office == 'P' || (office == 'H' && candidateState == 'PR')) { transactionPeriodsString += '&two_year_transaction_period=' + (cycle - 2); - // and the two earlier two-year periods for Senate races - else if (office == 'S') { + // and the two earlier two-year periods for Senate races + } else if (office == 'S') { transactionPeriodsString += '&two_year_transaction_period=' + (cycle - 2); transactionPeriodsString += '&two_year_transaction_period=' + (cycle - 4); } @@ -696,7 +705,8 @@ ContributionsByState.prototype.displayUpdatedData_states = function() { this.baseStatesQuery.cycle, this.baseStatesQuery.office, theCommitteeIDs, - theResults[i].state + theResults[i].state, + this.candidateDetails.state ); // Number cell