Skip to content

Commit

Permalink
get the year of incommon participation to be used for getting registr…
Browse files Browse the repository at this point in the history
…ation classes
  • Loading branch information
ij committed Mar 15, 2019
1 parent 849228a commit f368274
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/sf/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ def inc_execs
Sf::Contact.inc_execs_for(self.Id)
end

def inc_part_since_year
if self.InCommon_Participant__c
start_date = start_dates_by_subscription["InCommon Participation"]
start_date.split("-")[0] if start_date
end
end

# Class Methods
def self.find(id)
new Sf.client.find("Account", id)
Expand Down Expand Up @@ -122,4 +129,21 @@ def self.active_inc_parts(service_name)
and Do_Not_Publish__c <> true")
build_collection sobjects.map(&:Supporting_Institution__r) unless sobjects.blank?
end

private

def subscriptions
Sf.client.query("select Service__r.Id, Service__r.Name, Service_Start_Date__c, Service_End_Date__c from Service_Institution__c where Supporting_Institution__c = \'#{self.Id}\'")
end

def subscription_names
subscriptions.map{|s| s.Service__r.Name}
end

def start_dates_by_subscription
start_dates = {}
subscriptions.each {|s| start_dates[s.Service__r.Name] = s.Service_Start_Date__c}
start_dates
end

end

0 comments on commit f368274

Please sign in to comment.