Price start/end times

When investigating the 'print price labels' problem [see http://www.openvpms.org/forum/how-do-you-print-product-price-label#comment-5432 ] I was playing with setting multiple prices for a product with different start dates. Being lazy, I didn't bother to set the end date, so I had 3 different prices starting at different dates, but all with the end date not set.

However, I found that the actual price displayed on the product screen, and used when invoicing the product was NOT the one with the latest start time.

Investigation showed that OPV's get price code (in ProductPriceRules.java and DateRules.java) looks for the first price active on the required date, and treats a null end date as a match. Hence my laziness led to the wrong price being selected.

Thus, if you are going to have historical prices in the system, then you MUST close off the end dates. ie

Price Start End
100 1/1/2005  
120 1/1/2011  
140 1/1/2013  

will result in $100 being chosen.  You must use

 

Price Start End
100 1/1/2005  31/12/2010
120 1/1/2011  31/12/2012
140 1/1/2013  

Regards, Tim G

Syndicate content