How do you print a product price label?

Hello all,  apologies if this seems like an easy question.

 

I want to print a price label for each product on our shelves (NB this is not all products in our catalogue, just ones I select on our shelves).

 

What is the easiest way to do this?

 

Thanks.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: How do you print a product price label?

Cahir - what is the exact problem - selecting the products for which to print labels, or hacking one of the standard reports (eg Product Price List) to generate labels?

If the second, I would be tempted to use the Export button to generate a CSV file and then play with this in Excel to strip the columns you don't want, then paste this into Word and use Word to generate the labels (or use Word's mail merge facility to generate the labels from the Excel data).

Regards, Tim G

Re: How do you print a product price label?

Tim,

     Thanks for your reply.  I just want to select individual products and print a label with their name (as stated in the catalogue) and price. 

 

If I try your second approach, would I be able to generate individual labels from the product screen, or would it create a label run of the whole catalogue?

Re: How do you print a product price label?

OK - think I may have got round this, no idea if this is the correct method, but here is what I have done so far:

 

Go to Administration>Templates.

Create a template for product price label, upload a bespoke odt file and save this new template under a name like "price_labels"

Go to any product you wish to put on your shelf.  Select the document tab on that product and attach your "price_label" template.

Then CLOSE that window.

Select your product again and hit "view", not "edit".  Go to document and your template should be a hyperlink.  Click on that and your document should open.

The only two bits I have yet to figure out is how to create a (jasper?) report with fields in it that select the notable product features from the currently selected product, and attach that report to the template instead of the odt file.

Re: How do you print a product price label?

I suspect that won't do what you want. When you click on the document link, it just displays the document template; it won't do any content generation.

I think your best approach is to develop a Jasper Report for this that you run from the Reporting - Report workspace. If you add create a product classification to denote that a product is on the shelves (E.g. On Shelf), you can then generate a label for all shelved products. If your report also prompts for the product name, then you can have it print only products matching the supplied name.

-Tim A

Re: How do you print a product price label?

Tim,

    Thanks for your reply.  You are correct, it seems I need to build a Jasper Report.

I had a go at this using ireport following a how-to vid on YouTube, but only got so far as using a few fields.

If you have any tips to save time on creating a report from the OpenVPMS database using iReport I would appreciate it!

Cahir

Re: How do you print a product price label?

[Cahir - note that there are two Tim's involved in this conversation - Tim G (me) and Tim A (who does most of the development work).]

Jasper - humm - my first one took me about 6 hours even though I was cloning an existing one. Give me a couple of days [I am still trying to recover from work not done while we were in Hong Kong over Christmas] and I will try and put some hints on the Implementors forum. In the meantime can I suggest you use the appoach that I initially suggested - ie export the output from the standard pricing report and import into Excel, hack it about and then use it as a feed to Word's label printing facility.

Can you tell me what label stationary you are going to use - single labels (like the drug label print ones), or A4 sheets containing multiple labels.

Next - how will you do the product selection - by name (like the existing product pricing report) or by putting each products you need pricing labels for in a specific type or classification. [I would recommend classification so that you can keep type separate for other purposes like invoice ordering/grouping.  Also, one can assign a product to multiple classes, so that you can if you want you can use the classification for both price label printing and something else. Note also that in my case we ended up using Types to control the invoice ordering and we do not (currently) use classifications.]

Regards, Tim G

Re: How do you print a product price label?

Tim G - thanks for your reply.  You are a lifesaver!

 

I am using single labels printed from a Dymo 450 label printer.

 

I am going to use product classification as previously suggested by the other tim.  i.e. Add an "on shelf" classification to those products that will be on the shelf.

 

Cheers,

Cahir

Re: How do you print a product price label?

Cahir - it was faster for me to knock up the report than write the iReports cheat sheet (but I still hope to get around to writing one)

See the attached file.  The Hong Kong Practice uses Dymo LabelWriter Duo's and I have used the label size from these - 70mmx54mm.  I have not hard coded the classification, so you will need to enter "On Shelf" or whatever you are going to use.

Don't look to closely at the SQL - I cloned what I needed and there is probably some tightening that could be done (my moto - adjust until it works ;-)

You may want to strip the UOM field and the 'per' before it. The amount field is set as a currency so for me its showing a dollar sign.  Hopefully for you it will show whatever you use locally. If problems just change it to a numeric 2 decimal places.

Have a play.  Regards, Tim G

AttachmentSize
productPriceLabels.jrxml 3.25 KB

Re: How do you print a product price label?

Tim,

   That label worked well thank you.  I still don't have a clue how to make one of my own in iReport.  Whenever I try, and suck the data out of the OPV database, then compile the report I get a "no data" error.

 

Just a few questions about your label (jasper report):

 

1. It comes out in portrait, how do I change that to landscape (ie, the print runs across the label, not up and down the long axis)?

2. Whenever I cut and paste your jasper coding, the label loads well into OPV.  However, whenever I look at it and save it in iReport, OPV cannot load it giving a "not found" error.  I am using iReport 5.0.1, and I think from previous forum posts that this is the cause of the error.  OPV cannot cope with reports created using iReport 5.0.1 - any thoughts?

 

Cheers!

 

Cahir

 

P.S. The currency symbol prints as £ and works well.

Re: How do you print a product price label?

In answer to my own question - to get a Jasper Report to print in landscape, add

orientation="Landscape"

to the <jasperReport header before "pageWidth" or so.

 

Fiddle with the rest of the settings to get your label right.

Re: How do you print a product price label?

Cahir - you fixed the landscape problem yourself.

iReport 5 - I had a play with this and then dropped it because of compatibility problems and went back to 3.7.6

"no data" problem - see http://www.openvpms.org/documentation/ireports-tips-and-tricks - this is the start of my 'you too can use iReports'.

Regards, Tim G 

Re: How do you print a product price label?

For Future reference the highest version of Ireports that supports compatibility (and you need to select that mode) is Ireports 4.5.0.

I believe after that release they dropped the 3.7.6 compatibility mode, we can update the jasperreports library I suspect to update compatibility however that is a Enhancement we would need to budget (cost/benefit).

Re: How do you print a product price label?

OK,

  Mostly got this sorted.

One lesson learned is that iReport seems to have a bug where it sees dimensions only in pixels, no matter what the default unit of measurement is.  Took me a while to realize this.

The final hurdle - how do I get OPV to prompt me for a product name when I run the report (as suggested by Tim A)?  I don't want to print the full list of "On Shelf" products each time, just perhaps update one or two that I enter into the system.

Cheers.

Cahir

Re: How do you print a product price label?

Cahir: do as follows in iReport:

  1. Right-click on Parameters, and click Add Parameter - it will add a parameter named 'parameter1'
  2. Right-click on the new parameter name, and click rename and change to say "Name"
  3. On the right of the screen, click the Properties button to show the properties of the Name parameter, set the default to "%", and the description to say 'Product Name Selection'.
  4. In the Designer window, click the Report Query button (between 'Preview' and the + button) to show the SQL code
  5. In the where clause add 'and e.name like $P{Name}'. 
    If we want to be a bit more user friendly and automatically add a trailing % so if the user enters XXXX as the Name selection, then we will display all product names starting XXXX, then the additional where clause needs to be 'and e.name like concat($P{Name},"%")' 

The resulting jrxml is attached.

Note that in step 3, you need to leave the 'Use as Prompt' property as true (ie ticked). It you don't do this then the parameter becomes a hard coded value which the user cannot alter (because they will  not be prompted for its value).

Regards, Tim G

AttachmentSize
productPriceLabels.jrxml 3.49 KB

Re: How do you print a product price label?

Cheers Tim,

  That nailed it.  For anyone else following this, remember to include the quotation marks around the % to make the code work.

 

I have uploaded my version of the label for selecting products in addition to Tim's.  It contains a bit of additional code for adding the date the price was printed to the label and works on the Dymo 450.

 

Cahir

AttachmentSize
dymo-450-shelfproduct.jrxml 4.16 KB

Re: How do you print a product price label?

What I hope will be a final comment:

 

When I run the report for printing labels that are on shelf, OPV prints all Fixed prices and unit prices linked to that product, including historical prices.

 

Is there a simple way to structure the report just to print the most recent product fixed price, without having to delete the historical prices?

Cahir

Re: How do you print a product price label?

Updated 16/2/13

The following will list all active products with their most recent fixed and unit prices.

This has the limitation that if you don't set a start_time for a product price (i.e the start_time is null), then incorrect results will be returned.

 select e.name as product, e.arch_short_name as archetype, if(p1.price,p1.price,0.00) as fixedPrice, if(p2.price,p2.price,0.00) as unitPrice,
    d1.value as uom, p1.product_price_id as fixedPriceId, p2.product_price_id as unitPriceId
from products p
join entities e on p.product_id = e.entity_id
left join
    (select product_id, max(start_time) as start_time
     from product_prices
     where arch_short_name = "productPrice.fixedPrice"
     group by product_id) as p1max on p1max.product_id = p.product_id
left join product_prices p1 on p1.product_id = p.product_id and p1.start_time = p1max.start_time and p1.arch_short_name = "productPrice.fixedPrice"    
left join
    (select product_id, max(start_time) as start_time
     from product_prices
     where arch_short_name = "productPrice.unitPrice"
     group by product_id) as p2max on p2max.product_id = p.product_id
left join product_prices p2 on p2.product_id = p.product_id and p2.start_time = p2max.start_time and p2.arch_short_name = "productPrice.unitPrice"    
left join entity_details d1 on d1.entity_id = e.entity_id and d1.name = "sellingUnits"
left join entity_classifications productgroup on productgroup.entity_id = e.entity_id
left join lookups grouplookup on grouplookup.lookup_id = productgroup.lookup_id
left outer join entity_relationships rpt on rpt.target_id = e.entity_id and rpt.arch_short_name = "entityRelationship.productTypeProduct"
left outer join entities producttype on producttype.entity_id = rpt.source_id
where e.active = 1
order by product

 

-Tim

Re: How do you print a product price label?

Thanks Tim.

I tried fitting your sql query in with the sql code in the existing report, but although I could get it to print one price, which is progress, it only printed the lowest price, not the most recent.  What am I doing wrong?

 

Here is my exisiting code:

 

select e.name as product, e.arch_short_name as archetype, if(p1.price,p1.price,0.00) as fixedPrice, if(p2.price,p2.price,0.00) as unitPrice, d1.value as uom
from
entities e inner join products p on e.entity_id = p.product_id
left join product_prices p1 on p1.product_id = p.product_id and p1.arch_short_name = "productPrice.fixedPrice"
left join product_prices p2 on p2.product_id = p.product_id and p2.arch_short_name = "productPrice.unitPrice"
left join entity_details d1 on d1.entity_id = e.entity_id and d1.name = "sellingUnits"
    left outer join entity_classifications productgroup on productgroup.entity_id = e.entity_id
    left outer join lookups grouplookup on grouplookup.lookup_id = productgroup.lookup_id
    left outer join entity_relationships rpt on rpt.target_id = e.entity_id and rpt.arch_short_name = "entityRelationship.productTypeProduct"
    left outer join entities producttype on producttype.entity_id = rpt.source_id
where
    if($P{Classifications} = "On Shelf",(grouplookup.name like $P{Classifications} or grouplookup.lookup_id is null),grouplookup.name like $P{Classifications})
and e.active = true
order by product

Re: How do you print a product price label?

Try replacing:

 order by product

with:

group by e.name
order by e.name, p1.start_time desc, p2.start_time desc

-Tim

Re: How do you print a product price label?

Tim A - am I fairly confident that you are incorrect.  One cannot use group by and order by in this way to achieve 'get me only the latest price for each product'.  MySQL processes group before order.  To get the latest of price you need MySQL to do ordering before grouping.

The only way to select the latest price for each product is to use a subquery.

Googling 'mysql group by order' yields a lot of discussion on this topic - see for example http://stackoverflow.com/questions/14770671/mysql-order-by-before-group-by

Regards, Tim G

Re: How do you print a product price label?

You're right. I've updated my answer.

Thanks,

Tim

Re: How do you print a product price label?

Thanks for your replies guys.

I have run Tim A's updated code.  However, there seems to be a (hopefully final) bug.

The report asks me to input a value for "classification" and then "product name" as it should.

But then it completely ignores any values I enter, and instead runs the whole list of products.

I have fiddled with the code, but could not change this behaviour.

 

Any ideas?

Re: How do you print a product price label?

I removed the jasperreports parameters from the query as I ran it in MySQL.

Make sure your where clause looks like:

 where
    if($P{Classifications} = "On Shelf",(grouplookup.name like $P{Classifications} or grouplookup.lookup_id is null),grouplookup.name like $P{Classifications})
and e.active = true
order by e.name

Re: How do you print a product price label?

Tim,

   Thanks for the prompt response.  Nearly there.

I inserted the above code and all products classed as "On Shelf" printed, but only if I left the classification box in OPV as "%".  i.e. If I typed "On Shelf" into the box and ran the report, all the product catalogue was printed.

 

Also, whenever I entered a name in the Product Name Selection box on OPV, it had no effect on the final report.  Whatever product I entered was totally ignored.

Re: How do you print a product price label?

Carrick - I lifted your Dymo-450 jrxml, added my SQL code, tarted it up to add the Price Start Time, and tested with both Classification and Name selection in both iReports and OPV.  The resulting jrxml is attached.  I know of only one problem: if the product name requires more than 3 lines of text then it will be truncated.  However, to check this I had to dummy up a really long name - all the standard products seemed to fit in the 3 available lines. The price slot will not overflow - I had a test item priced at $12,345.00 and it displayed happily.  You may want to remove the  'Set dd/mm/yyyy' if you don't want a display of when the price was set.

Regards, Tim

AttachmentSize
dymo-450-shelfproduct.jrxml 4.62 KB

Re: How do you print a product price label? FINISHED

Cheers Guys.

That last rendition by Tim G sorted it.  I have now posted the complete report in the "shared resources" section of the website:

http://www.openvpms.org/customisation/jasper-report-printing-labels-prod...

 

I had to edit the font a little to make the dates smaller.  I also found that the currency was printing with an "Â" before the "£" sign.  So I edited the XML to delete this symbol and the report works well.

 

Keep up the good work.

 

Re: How do you print a product price label? FINISHED - Almost!

Finally,

  And sorry for being a bit lazy about this (busy clinic coming up)
 

The current "on shelf" label prints the product price exclusive of sales tax.  What do I need to change in the jasper xml to make it print the price inclusive of sales tax?

 

Cahir

Re: How do you print a product price label? FINISHED - Almost!

Cahir - Note that since Hong Kong has no VAT/GST I had not looked at how taxes worked.  However, I have had a play, and it seems to me that the price set for the product is the 'tax included' amount.  That is if I have a product priced at $100 and the tax is set at 10%, then an invoice for one of these shows 'Total amount $100, Invoice amount is inclusive of $9.09 GST'.  So the report as is is showing you the 'tax included' price.

Regards, Tim G

Syndicate content