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

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

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

@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 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.

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!


move_down 20

items = request.item_requests
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are basically line items, not items. Probably best to rename.

"Differences / Comments"]]

data + items.map do |i|
item_name = Item.find(i.item_id).name
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't necessary now - you can just do i.item.name.

def print_unfulfilled
requests = current_organization
.requests
.includes(:item_requests, partner: [:profile])
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 .includes(item_requests: :item) to eager-load items as well.

"Differences / Comments"]]

data + items.map do |i|
item_name = Item.find(i.item_id).name
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

@@ -61,6 +61,12 @@
<%= clear_filter_button %>
<%= modal_button_to("#calculateTotals", {text: "Calculate Product Totals", icon: nil, size: "md", type: "success"}) %>
<span class="float-right">
<% if @unfulfilled_requests.exists? %>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I usually use any? here.

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