Home ›

# Invoice line item rounding

## Donate to this project

Submitted by Matt C on Mon, 14/11/2011 - 11:59

### Development Project Status: Developer Review

Forum http://www.openvpms.org/forum/victorian-open-vpms-users-meeting-18th-october-2011-730pm#comment-4174

Jira: https://openvpms.atlassian.net/browse/OVPMS-1091

o Add an option to round invoice items at the level of each individual item.

o This would need to be able to switched on/off

o At the level of each product

o Have a default state (ie. Either On/Off) set at Practice level for new Products.

We have had requests for rounding increments of 5c and 10c

## Comments

## Re: Invoice line item rounding

Yes please.

Also could we have option to round to

nearest5c or 10cor

up to next5c or 10cYuri.

## Re: Invoice line item rounding

Yes from me too! I agree with Yuri and I would also like the flexibility of an option of rounding up to the next whole dollar as well if possible.

Anthony (ActiVet)

Kind regards,

Anthony (ActiVet)

## Re: Invoice line item rounding

Thinking about this.......

Customisable round up levels,

eg <0.50 round to nearest 5c

0.50 - $20.00 round up to next 10c (thus extra markup 20% at .50, or less)

$20.01 - $40.00 round up to next 50c ( thus extra markup 2.5% or less )

>$40.00 round up to next dollar (thus extra markup 2.5% or less)

This is on invoice line rounding, not individual items; it's unlikely you well ever sell just 1 Prednil tablet at 0.03c; if you dispense 15 tablets, invoice line rounding will round item total .45 to .50 plus/minus dispensing fee. Hmm, thinking this through, invoice line rounding should be done before the addition of dispensing (linked) fee as a, say, $10 dispensing fee could push line items up through one of those categories.

Yuri.

## Re: Invoice line item rounding

Hi

We would be happy to have individual item - including dispensing fee round to the closest 5c

Cheers

Bernie & Jannine

## Re: Invoice line item rounding

Not sure about the legality of rounding line items according to a practice defined rule.

As far as I am aware, there are country-specific legal requirements to do with how line items and invoices are rounded.

We do support rounding cash payments to a minimum denomination. This would be legal in Australia for invoices as well.

If the intention is to handle different prices for different quantities, then this is better handled as part of product pricing, not line item rounding.

-Tim

## Re: Invoice line item rounding

Agree Tim.

I just thought of an issue with this. If it is implemented, I wouldn't limit the rounding to any particular numbers. The way things are going the Lira might make a come-back at which point you would need to see rounding to the nearest 10,000 or 20,000. Yen and several other currencies have similar issues with no decimal point (ronuding in the hundreds and tens place, not the tenths and hundreths).

One could consider an implementation that does something like:

Rounding decimal place: the number beyond which all decimal places become zero.

Rounding increment: What quantization to round to.

For instance, if the number were 12345.45 and we specified the decimal place to be 2 then it would look at the 10's place. If the increment were 2, then it would round only to 0,2,4,6,8. If the increment were 5, it would round to 0,5. Non-factors would not work, so you could only really have 0, 2, or 5 -- which are akin to the 5c and 10c mentioned earlier in the thread.

These different strategies for 12345.45 would yield:

2/0: 12300.00 (0 snaps to 0 or 10)

2/2: 12360.00 (2 snaps to 0, 2, 4, 6, 8, 10)

2/5: 12350.00 (5 snaps to 0, 5, or 10)

for a different number 1235.26

-1/0: 1235.00

-1/2: 1235.20

-1/5: 1235.50

Rounding on the right side of the decimal place can be accomplished with negative indexes for the decimal place.

Just trying to envision a flexible approach if that's what's decided on.

The whole thing then gets more convoluted if we try to handle the other internationalized rounding systems including bankers' rounding etc. (http://en.wikipedia.org/wiki/Rounding).

Cheers, Paul

## Re: Invoice line item rounding

There is actually provision in the code to handle currency rounding, although in practice its not widely used.

The lookup.currency archetype specifies the rounding mode for the currency used by the practice, as well as the minimum cash denomination. The number of digits to round to is determined by the java.util.Currency class.

This code is currently only used when calculating product prices.

Amounts are currently rounded to 2 decimal places using HALF_UP convention.

-Tim

## Re: Invoice line item rounding

Note that in 1.9, there is now a facility to round product prices to a minimum price.

This means that line items will be rounded to the nearest 5 cents for example when whole quantities are being used. If fractional quantities are being used, then line item totals may rounded to less than the minimum price.

From the documentation:

## Price Rounding

Prices are rounded to the default number of decimal places for the currency.

This can be changed by specifying a

Minimum Priceon the practice Currency.E.g., to round prices to the nearest 5 cents, specify 0.05 for the

Minimum Price.Prices will be rounded to the

Minimum Price:CostorMarkupis changedNote that the

MarkupandMax Discountmay be recalculated after the price is rounded.Prices will not be rounded to the Minimum Price: