From b54a78024c8983abbf0d53e517689ef8d68d4434 Mon Sep 17 00:00:00 2001 From: jparcill Date: Sun, 15 Sep 2024 00:53:56 -0400 Subject: [PATCH 1/2] Export In Kind in donations csv --- app/services/exports/export_donations_csv_service.rb | 3 +++ spec/services/exports/export_donations_csv_service_spec.rb | 2 ++ 2 files changed, 5 insertions(+) diff --git a/app/services/exports/export_donations_csv_service.rb b/app/services/exports/export_donations_csv_service.rb index 254ebcd196..cf2119b25c 100644 --- a/app/services/exports/export_donations_csv_service.rb +++ b/app/services/exports/export_donations_csv_service.rb @@ -80,6 +80,9 @@ def base_table "Variety of Items" => ->(donation) { donation.line_items.map(&:name).uniq.size }, + "In-Kind Value" => ->(donation) { + donation.value_per_itemizable + }, "Comments" => ->(donation) { donation.comment } diff --git a/spec/services/exports/export_donations_csv_service_spec.rb b/spec/services/exports/export_donations_csv_service_spec.rb index 237c1a4513..e47e8cf6b4 100644 --- a/spec/services/exports/export_donations_csv_service_spec.rb +++ b/spec/services/exports/export_donations_csv_service_spec.rb @@ -51,6 +51,7 @@ "Storage Location", "Quantity of Items", "Variety of Items", + "In-Kind Value", "Comments" ] + expected_item_headers end @@ -84,6 +85,7 @@ donation.storage_view, donation.line_items.total, total_item_quantity.count(&:positive?), + donation.value_per_itemizable, donation.comment ] From c1449db106e8047f6292ede7090ff106adedfc6f Mon Sep 17 00:00:00 2001 From: jared Date: Fri, 20 Sep 2024 04:33:09 -0400 Subject: [PATCH 2/2] Formatting money --- app/models/donation.rb | 4 ++++ app/services/exports/export_donations_csv_service.rb | 2 +- spec/services/exports/export_donations_csv_service_spec.rb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/donation.rb b/app/models/donation.rb index 2100b738af..6fb1466d78 100644 --- a/app/models/donation.rb +++ b/app/models/donation.rb @@ -136,6 +136,10 @@ def storage_view storage_location.nil? ? "N/A" : storage_location.name end + def in_kind_value_money + Money.new(value_per_itemizable) + end + private def combine_duplicates diff --git a/app/services/exports/export_donations_csv_service.rb b/app/services/exports/export_donations_csv_service.rb index cf2119b25c..6e600ea09b 100644 --- a/app/services/exports/export_donations_csv_service.rb +++ b/app/services/exports/export_donations_csv_service.rb @@ -81,7 +81,7 @@ def base_table donation.line_items.map(&:name).uniq.size }, "In-Kind Value" => ->(donation) { - donation.value_per_itemizable + donation.in_kind_value_money }, "Comments" => ->(donation) { donation.comment diff --git a/spec/services/exports/export_donations_csv_service_spec.rb b/spec/services/exports/export_donations_csv_service_spec.rb index e47e8cf6b4..7990929f63 100644 --- a/spec/services/exports/export_donations_csv_service_spec.rb +++ b/spec/services/exports/export_donations_csv_service_spec.rb @@ -85,7 +85,7 @@ donation.storage_view, donation.line_items.total, total_item_quantity.count(&:positive?), - donation.value_per_itemizable, + donation.in_kind_value_money, donation.comment ]