From f368274bc5341793cf00d9062eddc674db2d79d6 Mon Sep 17 00:00:00 2001 From: IJ Kim Date: Fri, 15 Mar 2019 17:45:22 -0400 Subject: [PATCH] get the year of incommon participation to be used for getting registration classes --- lib/sf/account.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/sf/account.rb b/lib/sf/account.rb index cbfdaa2..21c4e7a 100644 --- a/lib/sf/account.rb +++ b/lib/sf/account.rb @@ -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) @@ -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