household_people_and_contributions 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6388c7cd3cadb32b4112c5bfa9b417e91bdc47be
4
- data.tar.gz: f5e94fe8f9a495feb6baabfc1b4f7197ee2601df
3
+ metadata.gz: b9c256d0c422ecb7162b855841d3507fd2a25db1
4
+ data.tar.gz: 211ebb18cef5728653bf696369186f8b4c5ef785
5
5
  SHA512:
6
- metadata.gz: 41599e0515533e94b55ab850f8ceb429c7a58adc9d37bd48934a28ce562579dca5ff6b1a3b360cdb08073aef321f65ca32e2fd4c49276608544559b9692ba2d0
7
- data.tar.gz: 4ecfab1d1f2cca4526ada21f371c7bb2e6ad30b693f09263a3d42dee3c347ac02d85692f3eb81c63aed79b405bbbded57d81364a86cb5a65e1f149b5b5276aab
6
+ metadata.gz: 4fa7d7353e2ffc639595f1c8d13713291abc503460b0da1c17a881f77fb519d57bc63515fa75a0bc706b82533c9dc55e5dd0671ce556eec529552bc1c31a8289
7
+ data.tar.gz: 0282a8c4d2cd1d81ffe6fd20d8b0759905af8bb6ddef57d4c005600d61f89f8a85dd5bfb445f963fe25938fd4300a3f8d5d9d197053718cd628e306d22f98b39
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- household_people_and_contributions (0.0.2)
4
+ household_people_and_contributions (0.0.4)
5
5
  oauth
6
6
 
7
7
  GEM
@@ -175,11 +175,11 @@ module HouseholdPeopleAndContributions
175
175
  household_array = results["household"]
176
176
  @household_records += household_array.reduce([]) { |memo, household_record|
177
177
  tmp_record = {}
178
- tmp_record["id"] = household_record["@id"]
179
- tmp_record["household_name"] = household_record["householdName"]
180
- tmp_record["household_sort_name"] = household_record["householdSortName"]
181
- tmp_record["created_date"] = household_record["createdDate"]
182
- tmp_record["updated_date"] = household_record["lastUpdatedDate"]
178
+ tmp_record["key"] = household_record["@id"]
179
+ tmp_record["name"] = household_record["householdName"]
180
+ tmp_record["sort_name"] = household_record["householdSortName"]
181
+ tmp_record["created_at"] = household_record["createdDate"]
182
+ tmp_record["updated_at"] = household_record["lastUpdatedDate"]
183
183
  memo << tmp_record.dup
184
184
  memo
185
185
  }
@@ -210,7 +210,7 @@ module HouseholdPeopleAndContributions
210
210
 
211
211
  if current_month < 5 # we're nearing the end of the cycle
212
212
  # from previous year, to current-year
213
- from = "#{previous_year}-05-01"
213
+ from = "#{previous_year}-05-01" # TBD: make this configurable!
214
214
  upto_but_not_including ||= "#{current_year}-05-01"
215
215
  else
216
216
  # from current year, to next-year
@@ -229,14 +229,14 @@ module HouseholdPeopleAndContributions
229
229
  if contribution_array = results["contributionReceipt"]
230
230
  @contribution_records += contribution_array.reduce([]) { |memo, contribution_record|
231
231
  tmp_record = {}
232
- tmp_record["id"] = contribution_record["@id"]
232
+ tmp_record["key"] = contribution_record["@id"]
233
233
  tmp_record["amount"] = contribution_record["amount"]
234
- tmp_record["fund_id"] = contribution_record["fund"]["@id"]
234
+ tmp_record["fund_key"] = contribution_record["fund"]["@id"]
235
235
  tmp_record["fund_name"] = contribution_record["fund"]["name"]
236
- tmp_record["household_id"] = contribution_record["household"]["@id"]
236
+ tmp_record["household_key"] = contribution_record["household"]["@id"]
237
237
  tmp_record["received_date"] = contribution_record["receivedDate"]
238
238
  tmp_record["transmit_date"] = contribution_record["transmitDate"]
239
- tmp_record["created_date"] = contribution_record["createdDate"]
239
+ tmp_record["created_at"] = contribution_record["createdDate"]
240
240
 
241
241
  tmp_record["updated_date"] = contribution_record["lastUpdatedDate"]
242
242
  memo << tmp_record.dup
@@ -264,16 +264,16 @@ module HouseholdPeopleAndContributions
264
264
  if VALID_STATUSES.include?(status) && household_id == person_record["@householdID"]
265
265
  tmp_record = {}
266
266
 
267
- tmp_record["id"] = person_record["@id"]
268
- tmp_record["household_id"] = person_record["@householdID"]
267
+ tmp_record["key"] = person_record["@id"]
268
+ tmp_record["household_key"] = person_record["@householdID"]
269
269
  tmp_record["status"] = status
270
270
 
271
271
  tmp_record["first_name"] = person_record["firstName"]
272
272
  tmp_record["last_name"] = person_record["lastName"]
273
273
  tmp_record["suffix"] = person_record["suffix"]
274
274
 
275
- tmp_record["created_date"] = person_record["createdDate"]
276
- tmp_record["updated_date"] = person_record["lastUpdatedDate"]
275
+ tmp_record["created_at"] = person_record["createdDate"]
276
+ tmp_record["updated_at"] = person_record["lastUpdatedDate"]
277
277
 
278
278
  memo << tmp_record.dup
279
279
  end
@@ -284,7 +284,7 @@ module HouseholdPeopleAndContributions
284
284
  end
285
285
 
286
286
  def household_ids_for(households)
287
- households.map { |household_record| household_record["id"] }
287
+ households.map { |household_record| household_record["key"] }
288
288
  end
289
289
 
290
290
  def get_people_in_households(households=[])
@@ -308,8 +308,8 @@ module HouseholdPeopleAndContributions
308
308
  tmp_record = {}
309
309
  attributes_array = scholar_record["attributes"]["attribute"]
310
310
  attributes_array.each do |attribute_entry|
311
- if attribute_entry["attributeGroup"]["name"] == "Grade"
312
- tmp_record["id"] = attribute_entry["person"]["@id"]
311
+ if attribute_entry["attributeGroup"]["name"].downcase == "grade"
312
+ tmp_record["key"] = attribute_entry["person"]["@id"]
313
313
  tmp_record["grade"] = attribute_entry["attributeGroup"]["attribute"]["name"]
314
314
  end
315
315
  end
@@ -324,10 +324,10 @@ module HouseholdPeopleAndContributions
324
324
  def get_scholar_grades_for(people=[], options = {})
325
325
  n_at_a_time = options[:recordsPerPage] || 200
326
326
  @attributed_scholars = []
327
- scholars = people.select { |person| SCHOLAR_STATUS == person["status"] }
327
+ scholars = people.select { |person| SCHOLAR_STATUS == person["status"] }.dup
328
328
  extra_params = "recordsPerPage=#{n_at_a_time}"
329
329
  while !scholars.empty?
330
- scholar_id_list = scholars.pop(n_at_a_time).map {|s| s["id"] }
330
+ scholar_id_list = scholars.pop(n_at_a_time).map {|s| s["key"] }
331
331
  scholar_id_list_csv = scholar_id_list.join(",")
332
332
  @attributed_scholars += scholar_records(scholar_id_list_csv, extra_params: extra_params)
333
333
  end
@@ -337,7 +337,7 @@ module HouseholdPeopleAndContributions
337
337
 
338
338
  def add_contribution_sum_to_households(contributions, hh)
339
339
  contributions.each do |contribution_record|
340
- household = hh.detect { |h| h["id"] == contribution_record["household_id"] }
340
+ household = hh.detect { |h| h["key"] == contribution_record["household_key"] }
341
341
  if household
342
342
  household["contribution_total"] ||= 0
343
343
  household["contribution_total"] += contribution_record["amount"].to_f
@@ -348,7 +348,7 @@ module HouseholdPeopleAndContributions
348
348
 
349
349
  def add_grades_to_people(as, pp)
350
350
  as.each do |scholar|
351
- person = pp.detect { |p| p["id"] == scholar["id"] }
351
+ person = pp.detect { |p| p["key"] == scholar["key"] }
352
352
  if person
353
353
  person["grade"] = scholar["grade"]
354
354
  end
@@ -399,10 +399,6 @@ module HouseholdPeopleAndContributions
399
399
  end
400
400
 
401
401
  def report
402
- warn "--> hh: "
403
- File.write(OUTPUT_DIR + "/" + "households.json", hh.to_json)
404
- puts hh.to_json
405
-
406
402
  warn "\n--> people and scholars: "
407
403
  File.write(OUTPUT_DIR + "/" + "people.json", pp.to_json)
408
404
  puts pp.to_json
@@ -410,6 +406,11 @@ module HouseholdPeopleAndContributions
410
406
  warn "\n--> contributions: "
411
407
  File.write(OUTPUT_DIR + "/" + "contributions.json", contributions_by_household.to_json)
412
408
  puts contributions_by_household.to_json
409
+
410
+ warn "--> hh: "
411
+ File.write(OUTPUT_DIR + "/" + "households.json", hh.to_json)
412
+ puts hh.to_json
413
+
413
414
  return {hh: @hh, pp: @pp, contributions_by_household: @contributions_by_household}
414
415
  end
415
416
  end
@@ -1,3 +1,3 @@
1
1
  module HouseholdPeopleAndContributions
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: household_people_and_contributions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Tee