From f4cbea2281f6e15af1fa7e270618b8ec77fdb9b5 Mon Sep 17 00:00:00 2001 From: John Coote Date: Wed, 12 Jun 2024 17:43:18 +1000 Subject: [PATCH] only strip or parse if the data is present in the row (general upload) money summary should consider giver type and giver id (and taker type taker id) to remove ambiguity (and bug) - dont merge until polymorphic transfer is complete --- app/services/file_ingestor.rb | 8 ++++---- app/views/components/common/money_summary.rb | 4 ++-- csv_data/other_people_groups_positions.csv | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/services/file_ingestor.rb b/app/services/file_ingestor.rb index 6a6eb59..1cb85d4 100644 --- a/app/services/file_ingestor.rb +++ b/app/services/file_ingestor.rb @@ -120,7 +120,7 @@ def ministries_upload(file) ministry_group = RecordGroup.call(row['group']) person = RecordPerson.call(row['person']) - title = row['title'].strip + title = row['title'].strip if row['title'] start_date = parse_date(row['start_date']) end_date = parse_date(row['end_date']) @@ -148,9 +148,9 @@ def general_upload(file) person = RecordPerson.call(row['person']) - title = row['title'].strip - start_date = parse_date(row['start_date']) - end_date = parse_date(row['end_date']) + title = row['title'].strip if row['title'].present? + start_date = parse_date(row['start_date']) if row['start_date'].present? + end_date = parse_date(row['end_date']) if row['end_date'].present? # the membership may not exist, if so, we need to create it membership = Membership.find_or_create_by( diff --git a/app/views/components/common/money_summary.rb b/app/views/components/common/money_summary.rb index b6ae19b..ed5e9b6 100644 --- a/app/views/components/common/money_summary.rb +++ b/app/views/components/common/money_summary.rb @@ -25,14 +25,14 @@ def template end def money_in - amount = Transfer.where(taker: entity).sum(:amount) + amount = Transfer.where(taker_type: entity.class.name, take_id: entity.id).sum(:amount) return unless amount.positive? number_to_currency amount, precision: 0 end def money_out - amount = Transfer.where(giver: entity).sum(:amount) + amount = Transfer.where(giver_type: entity.class.name, giver_id: entity.id).sum(:amount) return unless amount.positive? number_to_currency amount, precision: 0 diff --git a/csv_data/other_people_groups_positions.csv b/csv_data/other_people_groups_positions.csv index 1fa04f5..2709aa0 100644 --- a/csv_data/other_people_groups_positions.csv +++ b/csv_data/other_people_groups_positions.csv @@ -105,9 +105,9 @@ The Trustee for ST Baker Family Trust, Trevor St-Baker, Owner Pesca Aviation, Steve Baxter,,,, https://www.afr.com/rich-list/the-heavy-hitters-behind-australia-s-biggest-conservative-lobby-group-20240201-p5f1pt Advance Australia, Matthew Sheahan,,,, https://www.advanceaustralia.org.au/about-menu Hadley Holdings, Brian Anderson,,,, https://www.afr.com/rich-list/the-heavy-hitters-behind-australia-s-biggest-conservative-lobby-group-20240201-p5f1pt -Kennards Self Storage's, Sam Kennard,,,, https://www.afr.com/rich-list/the-heavy-hitters-behind-australia-s-biggest-conservative-lobby-group-20240201-p5f1pt +Kennards Self Storage, Sam Kennard, Owner,,, https://www.afr.com/rich-list/the-heavy-hitters-behind-australia-s-biggest-conservative-lobby-group-20240201-p5f1pt Centre for Independent Studies, Sam Kennard, Board Memeber,,, https://reneweconomy.com.au/the-network-of-conservative-think-tanks-out-to-kill-the-switch-to-renewables/ -Siesta Holdings, Sam Kennard,,,, https://www.afr.com/rich-list/the-heavy-hitters-behind-australia-s-biggest-conservative-lobby-group-20240201-p5f1pt +Siesta Holdings Australia Pty Ltd, Sam Kennard,,,, https://www.afr.com/rich-list/the-heavy-hitters-behind-australia-s-biggest-conservative-lobby-group-20240201-p5f1pt Pitcher Partners, Ronald Pitcher,,,, https://www.afr.com/rich-list/the-heavy-hitters-behind-australia-s-biggest-conservative-lobby-group-20240201-p5f1pt Consolidated Pastoral, Kenneth Warriner,,,, https://www.afr.com/rich-list/the-heavy-hitters-behind-australia-s-biggest-conservative-lobby-group-20240201-p5f1pt JMR Management Consultancy Services, Brett Ralph,,,, https://www.afr.com/rich-list/the-heavy-hitters-behind-australia-s-biggest-conservative-lobby-group-20240201-p5f1pt