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 feature to print unfulfilled requests as a picklists PDF #4598

Merged
merged 18 commits into from
Oct 13, 2024

Conversation

norrismei
Copy link
Contributor

@norrismei norrismei commented Aug 16, 2024

Resolves #4406

Description

Stakeholder asked for new functionality that allows printing a single file containing all outstanding requests so that pickers may use the documents as picklists, checking off as they go and making note of any differences.

When an organization goes to their Requests, there will now be a Print Unfulfilled Picklists button next to the Export Requests button.

Design decisions made:

  • Page numbers are based on the number of pages in the PDF file instead of numbering each request page 1 of 1 or 1 of 2 because if somehow the pages were scrambled up, we'd want a way of putting them back in order vs. risking not being able to identify multiple non-descript 2 of 2 pages.
  • Format of the Picklists PDF follows the Distribution PDF closely. The OpenSans font does not support checkboxes so I chose to go with [ ] (open and close brackets) to get the job done with minimal effort.
  • Filename of PDF is Picklists_#{Date}_#{Time}.pdf in case the file is generated and printed multiple times in a day, we'd want different file names based on time.

Things to note

  • It takes a little while for the PDF to generate in the testing site because there are 180+ outstanding requests. A query was ran to see how many outstanding requests a real bank would have on average. We're assuming about 10 outstanding requests on average, with the most being 44 requests at the time of the query.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

I manually tested the following scenarios:

  • With packs enabled, the PDF should have the Units (if applicable) column.
    To enable, I pointed my browser to http://localhost:3000/flipper and logged in
    userid: admin
    password: password
  • The PDF shows Partner Pickup Person if there is one listed under the Partner settings. I logged in as a Partner to toggle this setting.

Screenshots

No packs enabled and no partner pickup person:

Screen Shot 2024-08-29 at 1 00 09 PM

With packs enabled and no partner pickup person:

Screen Shot 2024-08-29 at 12 55 02 PM

With packs enabled and a partner pickup person listed:
Screen Shot 2024-08-29 at 1 05 07 PM

Index page with print button displaying unfulfilled requests count
Screen Shot 2024-09-23 at 11 29 35 PM

@norrismei norrismei marked this pull request as draft August 16, 2024 06:17
@norrismei norrismei force-pushed the 4406-add-print-picklists branch 6 times, most recently from da53d82 to 69135be Compare August 18, 2024 07:43
@awwaiid awwaiid added this to the Request Units (Packs) milestone Aug 25, 2024
@awwaiid
Copy link
Collaborator

awwaiid commented Aug 25, 2024

Ready for a review @norrismei?

@norrismei
Copy link
Contributor Author

@awwaiid There are a few changes I need to make and then I'll fill out the PR description and mark this ready for review.

@norrismei norrismei force-pushed the 4406-add-print-picklists branch from db42034 to 419a86c Compare August 29, 2024 21:28
@norrismei norrismei marked this pull request as ready for review August 29, 2024 21:35
@norrismei norrismei changed the title [WIP] Add feature to print unfulfilled requests as a picklists PDF Add feature to print unfulfilled requests as a picklists PDF Aug 29, 2024
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 @norrismei! Good job so far!

I am a little concerned about perceived performance (prod is slower than our locals), but I'll let @awwaiid / @dorner chime in on that from a technical pov.

(Edit: I could see adding the number of requests that will be in the picklist into the button. Just as an indication of what they are getting into.)

One other question -- does this include "started" requests?

@cielf cielf requested a review from awwaiid August 30, 2024 16:13
@cielf
Copy link
Collaborator

cielf commented Sep 1, 2024

@norrismei Please do change the button to have the number of unfulfilled requests..

e.g. Print Unfulfilled Picklists (44)

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.

Great first pass!

app/controllers/requests_controller.rb Outdated Show resolved Hide resolved
config/routes.rb Outdated Show resolved Hide resolved
@norrismei norrismei force-pushed the 4406-add-print-picklists branch 3 times, most recently from c1f35e8 to 84c788b Compare September 3, 2024 23:52
@norrismei
Copy link
Contributor Author

@cielf I added the number of unfulfilled requests to the print button, and yes, unfulfilled requests includes "started" requests.

@dorner I scoped the query to the organization (thanks for catching) and updated statuses to be more obvious. Awaiting clarity on item_requests vs request_items.

@norrismei norrismei force-pushed the 4406-add-print-picklists branch 2 times, most recently from 5b31977 to 03a7b79 Compare September 12, 2024 07:16
@cielf
Copy link
Collaborator

cielf commented Sep 12, 2024

Hey @norrismei - just noting that the lint is failing -- just a wee thing to change there.

@cielf
Copy link
Collaborator

cielf commented Sep 12, 2024

@norrismei, but do please change to @item_requests -- we are going to be stripping out request_items entirely in the near future.

I think I'll hold off on a final functional check until that's in.

@norrismei norrismei force-pushed the 4406-add-print-picklists branch 2 times, most recently from 826d4ec to 61aada6 Compare September 13, 2024 06:15
@norrismei norrismei requested review from dorner and cielf September 13, 2024 06:30
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.

This needs a unit test please!

app/pdfs/picklists_pdf.rb Outdated Show resolved Hide resolved
app/pdfs/picklists_pdf.rb Outdated Show resolved Hide resolved
app/controllers/requests_controller.rb Show resolved Hide resolved
app/pdfs/picklists_pdf.rb Outdated Show resolved Hide resolved
app/views/requests/index.html.erb Outdated Show resolved Hide resolved
@norrismei norrismei force-pushed the 4406-add-print-picklists branch 3 times, most recently from 854389f to b385ba2 Compare September 24, 2024 07:01
@norrismei norrismei force-pushed the 4406-add-print-picklists branch from b385ba2 to a537810 Compare September 24, 2024 07:04
@norrismei norrismei requested a review from dorner September 24, 2024 07:17
@norrismei
Copy link
Contributor Author

@dorner unit tests added. Both for the PDF and the button on the index page

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.

LGTM from a functional pov.

@cielf
Copy link
Collaborator

cielf commented Sep 28, 2024

@norrismei FYI: We had an urgent fix that required all the senior contributors this week , so we didn't get to look at this again. Hopefully this week will go better.

dorner
dorner previously requested changes Sep 30, 2024
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.

One minor comment. Otherwise this looks great!

spec/factories/partners.rb Outdated Show resolved Hide resolved
@norrismei norrismei force-pushed the 4406-add-print-picklists branch from 8243bad to 9173819 Compare October 4, 2024 17:50
@norrismei norrismei force-pushed the 4406-add-print-picklists branch from fe12dfa to 8439cc2 Compare October 4, 2024 18:05
@norrismei norrismei requested a review from dorner October 4, 2024 18:25
Copy link
Collaborator

@awwaiid awwaiid left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you :)

@@ -40,6 +40,20 @@ def start
redirect_to new_distribution_path(request_id: request.id)
end

def print_unfulfilled
requests = Request.includes(partner: [:profile]).where(status: [0, 1])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note to self -- is there something more explicit than 0 and 1?

<% if @requests.any? { |request| request.status == "pending" || request.status == "started" } %>
<%= print_button_to(
print_unfulfilled_requests_path(format: :pdf),
text: "Print Unfulfilled Picklists",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a count so they know what to expect. "Print Unfulfilled Picklists (34 partner requests)"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahh -- this needs to pass the filter through for the pdf to also apply.

@awwaiid awwaiid merged commit 5fe25bb into rubyforgood:main Oct 13, 2024
11 checks passed
Copy link
Contributor

@norrismei: Your PR Add feature to print unfulfilled requests as a picklists PDF is part of today's Human Essentials production release: 2024.10.20.
Thank you very much for your contribution!

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.

[PACKS] #11: Add ability to print all outstanding requests as pick-lists
4 participants