Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to control whether "in-kind value" of each item should be added in export of donations and distributions #4897

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nozomirin
Copy link
Contributor

@nozomirin nozomirin commented Dec 31, 2024

Resolves #4858

Description

  1. add include_in_kind_values_in_exported_files column in Organizations table.
  2. add radio buttons in view/organization/edit.html.erb.
  3. make some changes to add in-kind value for each item in exported donation and distribution files when the Include in-kind value in donation and distribution exports? is set to yes.
  4. add explanations in docs/user_guide/bank/exports.md

Note: I changed the "In-Kind Value" header to "In-Kind Total" in the exported donation file to avoid ambiguity. However, I used "Header + In-Kind Value" for the in-kind value of items, so perhaps the change is unnecessary. If there’s anything incorrect or unclear, please let me know.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

bundle exec rspec spec/services/exports/export_distributions_csv_service_spec.rb 
bundle exec rspec spec/services/exports/export_donations_csv_service_spec.rb

Screenshots

@nozomirin nozomirin force-pushed the 4858-add-an-option-to-include-in-kind-values-in-export-of-donations-and-distributions branch 4 times, most recently from 41722bc to a21bf2d Compare January 2, 2025 08:36
Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Light testing looks good. User manual changes for the organization bit are outstanding, though.

The relevant area for that updating are: docs/user_guide/bank/getting_started_customization.md

I'll review the user manual stuff later.

Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm suggesting some expanded text around the instructions.

@@ -129,6 +129,9 @@ For each of the distributions in the filtered list:

[!NOTE] This includes inactive Items as well as active ones.

### Add In-Kind Value for each item
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add something like "The default export includes the number of items exported, but not the values. If you want to also have the export include the in-kind value for each item in the distributions, you can set that option." before the instructions.

And after, please add a "[!NOTE] Setting this affects both the donation and distribution exports."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

@@ -157,6 +160,9 @@ For each of the Donations in the filtered list:
- Comments,
- and the quantity of each of your organization's Items in the Donations.

### Add In-Kind Value for each item
Click "My Organization" in the left hand manu. Click "Edit" button. Set the "Include in-kind value in donation and distribution exports?" to "yes".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add similar text as noted above in the distribution section.

@@ -129,6 +129,9 @@ For each of the distributions in the filtered list:

[!NOTE] This includes inactive Items as well as active ones.

### Add In-Kind Value for each item
Click "My Organization" in the left hand manu. Click "Edit" button. Set the "Include in-kind value in donation and distribution exports?" to "yes".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to "yes", then click "Save".

@nozomirin nozomirin force-pushed the 4858-add-an-option-to-include-in-kind-values-in-export-of-donations-and-distributions branch 2 times, most recently from 62279c2 to 4ae30dc Compare January 6, 2025 04:55
@nozomirin
Copy link
Contributor Author

Light testing looks good. User manual changes for the organization bit are outstanding, though.

The relevant area for that updating are: docs/user_guide/bank/getting_started_customization.md

I'll review the user manual stuff later.

What contents should I add in this file?

@cielf
Copy link
Collaborator

cielf commented Jan 6, 2025

The relevant area for that updating are: docs/user_guide/bank/getting_started_customization.md
I'll review the user manual stuff later.

What contents should I add in this file?

Well -- I would add a section, at the same level as "customizing the distribution printout", called "Configuring exports", then a subsection for the field. In that, I would talk about what the default distribution and donation exports are (as you did in the exports section), and the effect that setting this field to "yes' will have.

IIRC, your new field is just before "Distribution Email Content". If that's right, put the new section there.

@nozomirin nozomirin force-pushed the 4858-add-an-option-to-include-in-kind-values-in-export-of-donations-and-distributions branch from 4ae30dc to d8051fe Compare January 7, 2025 05:40
@nozomirin
Copy link
Contributor Author

The relevant area for that updating are: docs/user_guide/bank/getting_started_customization.md
I'll review the user manual stuff later.

What contents should I add in this file?

Well -- I would add a section, at the same level as "customizing the distribution printout", called "Configuring exports", then a subsection for the field. In that, I would talk about what the default distribution and donation exports are (as you did in the exports section), and the effect that setting this field to "yes' will have.

IIRC, your new field is just before "Distribution Email Content". If that's right, put the new section there.

It seems odd to me that there is a second-level section between two fourth-level sections.
I made a commit. Please check if it meets your expectations.

@cielf
Copy link
Collaborator

cielf commented Jan 7, 2025

The relevant area for that updating are: docs/user_guide/bank/getting_started_customization.md
I'll review the user manual stuff later.

What contents should I add in this file?

Well -- I would add a section, at the same level as "customizing the distribution printout", called "Configuring exports", then a subsection for the field. In that, I would talk about what the default distribution and donation exports are (as you did in the exports section), and the effect that setting this field to "yes' will have.
IIRC, your new field is just before "Distribution Email Content". If that's right, put the new section there.

It seems odd to me that there is a second-level section between two fourth-level sections. I made a commit. Please check if it meets your expectations.

Yeah (haven't checked yet) We need to do some reorganization of that screen so that same-concepted things are together - but that's out of scope for this change.

cielf
cielf previously requested changes Jan 8, 2025
Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of tweaks, please, and over to @dorner for technical input.

@@ -182,6 +182,16 @@ Partners can't submit Requests until they are approved by the bank.
The full partner approval process requires the partner to fill in their profile and submit it for approval. Some banks handle that for their partners, gather the information through other means (such as a phone conversation).
Checking this will change the process so that the partners are automatically approved when they are invited. Note that any invited partners that are not yet approved will still need to be approved by the bank.

## Configuring exports

### Add In-Kind Value for each item
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this the whole field name -- i.e. Include in-kind value in donation and distribution exports?

This matches the practice for the field-level sections in the rest of the file.


### Add In-Kind Value for each item

You can configure whether the export file includes the "In-Kind Value" column for each item. By default, these values are excluded. To include them, set the "Include in-kind value in donation and distribution exports?" option to "Yes".
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change "the export file includes " to "the exports for donations and distributions include "

@cielf cielf requested a review from dorner January 8, 2025 01:49
…be added in export of donations and distributions
@nozomirin nozomirin force-pushed the 4858-add-an-option-to-include-in-kind-values-in-export-of-donations-and-distributions branch from d8051fe to a15b1de Compare January 9, 2025 10:16
@cielf cielf dismissed their stale review January 9, 2025 16:17

Addressed

Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @nozomirin . This looks pretty good to me from a functional pov.

One note -- when you do a force push it makes it harder for the reviewers, because they can't see the incremental changes.

Over to @dorner for technical review

Copy link
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great - I had a request for the tests.

@@ -0,0 +1,6 @@
class AddIncludeInKindValuesInExportedFilesToOrganizations < ActiveRecord::Migration[7.2]
def change
add_column :organizations, :include_in_kind_values_in_exported_files, :boolean
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be NOT NULL. Otherwise it's got three values, true false and null. :)

distribution.comment
]

row += quantities_and_values_of_item.flat_map { |item| [item[:quantity], item[:value].to_f] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really should be setting up the data using explicit values rather than trying to calculate aggregations of random values. If it's not too much work, would you be able to make that change?

Copy link
Contributor Author

@nozomirin nozomirin Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nozomirin FYI, we will be addressing those inconsistencies in PR4924. I'd like to get this one in first if we can.

I will change this test later in another PR.


row += item_quantities

expect(item_quantities.sum).to eq(total_item_quantity)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@nozomirin
Copy link
Contributor Author

Hey @nozomirin . This looks pretty good to me from a functional pov.

One note -- when you do a force push it makes it harder for the reviewers, because they can't see the incremental changes.

Over to @dorner for technical review

I understand that I should not force push after a review. Got it—this won't happen again.

@nozomirin
Copy link
Contributor Author

If the filter is set to item A, the total number is the number of A. But what is the 'total value'? Is it the value of A or the value of the entire distribution?

@cielf
Copy link
Collaborator

cielf commented Jan 13, 2025

We recently merged a change to make it so that the filtered values on the index reflect only the values for the items in the filter. The export should match that. I don't recall immediately if the export was addressed at that time, but suggest you merge main into your branch and confirm.

@nozomirin
Copy link
Contributor Author

I pulled and tested it on the main branch. The total value represents the value of the entire distribution.

@cielf
Copy link
Collaborator

cielf commented Jan 14, 2025

Huh. I thought we'd addressed that. I'm going to have to track down what happened there (and I can't do that in the next few minutes. Maybe later today).

The export should match the index.

@cielf
Copy link
Collaborator

cielf commented Jan 15, 2025

I've dug into this a bit more. For the scope of this PR, leave the total value as is.

We have some inconsistencies between how we are handling filtering by item and filtering by item category in the export that need to be resolved, but it's out of scope for this PR.

@cielf
Copy link
Collaborator

cielf commented Jan 16, 2025

@nozomirin FYI, we will be addressing those inconsistencies in PR4924. I'd like to get this one in first if we can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an option to include in-kind values in export of donations and distributions
3 participants