Improving Tickets (a 2-3 part issue)
pdxdiaperbank opened this issue ยท 12 comments
Hi all,
This should be my final request (for today anyway;) -
As you know, tickets are created for our outgoing donations to each of our partner agencies. When we provide a partner agency with diapers each month we provide them with an invoice (in the case of the new database it would be called "ticket details"). Currently, the only way I can print the form is from my computer's print preview mode (which is tricky because I often email it). Can we possibly create the ability for the ticket details to be pulled up/saved as a pdf (or some kind of doc format)?
Second, I'd really like to improve the details on the ticket as well. Right now it just lists the items with their quantities (see actual ticket below). I'd really love it if we can add the total items distributed for/on each ticket. Our partner agencies need this information for the annual reports that they complete for PDX Diaper Bank (if we keep it as is, they have to add up all of the items they receive annually with a calculator which leaves a lot of room for human error). If diapers and wipes can be listed separately on the ticket, that is even better! Something like this:
Total Items Distributed
Diapers: 1,092
Wipes: 27
A wishlist request for the tickets would be to have the ability to add our logo to the top under the organization name. :)
Thank you!!
Rachel
If anyone has the ability to create a pdf with the pdx diaper bank logo and the other details (except the things that will be filled in from the ticket) I'll take care of code that inserts the ticket items into it :) I built a stationery ordering platform for a university and have a bit of experience with this :)
@seanmarcia I can tackle the pdf report portion. I've worked with prawn and wicked_pdf before.
@pdxdiaperbank Here's a PDF report I gen'd up. Please give me any feedback you have. Let me know exactly what type of information you want to be included on the invoice (i.e. Partner address, PDX phone number, section headings, etc...)
I also added the category groups when viewing the ticket. Currently the groupings are based on the value of the category associated with an Item which includes information such as type (i.e. Diaper) and user (i.e. child vs adult). In your example you showed the summary should just be based on the type, correct? If so, then we might have to split that category field up so it's easier to group by without being so granular. Here's a snapshot of the updated ticket page.
Also, notice in the top right corner I placed a new action button for printing. This button will generate the PDF.
Again, any and all feedback welcome.
@seanmarcia I started this work in a new branch called ticket_invoice
. If you want, you can take an look and clean up how I'm inserting the data. It could probably benefit from a second set of eyes.
Awesome job @cattywampus!
So you know, I'm going to take credit for this ;)
The only thing we need to account for now is how the styling hold up on when it is a really large order and it overflows onto two pages. I've used prawn but not prawn-rails so the DSL is a little different than I am used to and I wasn't able to tell just by looking at the code what will happen but I'll definitely test when I get home tonight.
Also, in the print.pdf.prawn file on line 65 we should probably change summary = [["Category", "Quantity"]]
to summary = [["Total Items Distributed", "Quantity"]]
to line up with the language Rachel used when she created the issue :)
PS- I love the succinct way you did your quantities_by_category
method. In my first pass at it I did something that wasn't nearly as elegant :)
Thanks @seanmarcia! I'm all about making result align with the business language. Let's do that.
prawn-rails
pulls in prawn
proper and sets up some initial boilerplate such as automatically starting new prawn documents and detecting prawn templates. Personally, I think I would prefer to instantiate the document class object manually. My prawn template doesn't seem to run within the context of a Prawn document class but rather passes in the document to the block, making it required to invoke every prawn method off of that variable, which got annoying.
I did a few things to try to handle multiple pages but it hasn't been tested. Spefically, the page should :
- display the footer on every page
- display items table header row on every page if number of items spans multiple pages.
I thought about putting the top portion in a header that gets rendered on every page too, but I didn't want to over implement work if @pdxdiaperbank doesn't want it. Again, any feedback on the PDF is welcome.
You guys rock.
This is fantastic, thanks everyone! Thanks for jumping in too, @seanmarcia !
@cattywampus , I REALLY like the changes to the ticket with the addition of the category breakdown! The only thing I can think to add (and this is a WISHLIST kind of thing, not absolutely necessary for functionality) is a comment box (we sometimes have a special note for the partner agency pertaining to their order fulfillment). Would this be a pretty simple function to add to the ticket? -Rachel
hey @pdxdiaperbank I added the comment functionality but I wanted to be clear that you wanted it to show up in the pdf that you print/send and not just something for your internal records. Let me know and I'll add it to the pdf as well.
Comments with dummy text
If it should look like this then the code is ready :)
PDF with comments
Love it, @seanmarcia! Yes, the comments should carry over to the printable PDF. :)
Also, would you mind adding a title to top of the PDF (in bold)? I'm thinking "Partner Agency Invoice". Visually I'm thinking on the top right side underneath the business address (with a gap/space between). But whatever is easiest. Much appreciated!!
Updated to look like this