We do some things that required an advanced template to print sales orders and invoices. This is reasonably straightforward with several exceptions. Here is one of the exceptions.
We use group items in place of kits most of the time. Kits copy the price in the sales order line item from the item’s price. Groups allow us to treat every item in the “Kit” as an individual item, assigning a unique price to each as it gets added to a sales order.
It works like this… When a group item is added to a sales order, it explodes into all the individual items in the group. However, when we print a sales order or invoice, we only want to show the “kitted” item, not items that make up the group.
At this point, you are thinking, no problem, right? Simply use the basic print form and uncheck the box on the group item called “Display Components on Transaction.” This does exactly what I just described, only printing the group item, nothing else. It rolls up the price too. Excellent! Unfortunately, this falls short for us! For other reasons I won’t go into here, we need to print using an Advanced PDF Template.
When you use an advanced template, you do the exact opposite of what I just described. You CHECK the box on the group item titled “Display Components on Transaction.”
Unless you check this box, the individual items are not available in your advanced template. When you iterate through items, all you see is the group item, no sub-items.
<#list record.item as item>
When loop through your items, check the item.itemtype. First, you’ll see the Group item.
<#if item.itemtype == “Group”>
And after all your sub-items pass by, you’ll see the End Group item.
<#if item.itemtype == “EndGroup”>
The hard part of this is waiting to print the Group item until you’ve added up all the prices of items in the group.
Other gotchas…
It is a good idea to set the “Display Components on Transaction” at the time a group item is created. If you don’t have that box checked and you add the group to a sales order, you’re stuck. The sales order will act as though the box had never been checked.
If you add a group to a sales order with the box unchecked, then check the box and create an invoice from the sales order. Once again… lost you will be (spoken in the voice of Yoda). Your group’s sub-items (in the printed invoice) will NOT show up on the Advanced PDF Template for your invoice.
Wow! It sure would have been easier if I could have used the basic template. Oh well. I write software for a living. I’m here all week.
Thank you for the info! I’m dealing with this issue right now. Are you managing to print the groups subtotal up with the group line item with this method? Can you give some more guidance on getting the group item price rolled up at the top of the group list, rather than at the end? Maybe you weren’t trying to do this, but it seemed like our use cases are decently similar.
LikeLike
Rob, I emailed you directly with some code samples. However, the answer is yes, I print group items using the advanced template and they work just like the basic template. In my case, I use a Freemarker macro to print line items. The macro iterates through the line items and starts building the Group Item line when it sees the start of group. It accumulates sub-item totals so that it can print the group item’s part number along with the quantity and extended price when it hits the Group End item.
LikeLike