Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
price + tax rounding
#1
Hello,

wondering if anybody has some experience with prices + tax calculation?
I've been dealing with a following problem:

I am supposed to display product prices in cart already with tax included, but
let's say a product price without tax:
quantity = 1
price_without_tax = 285.07
tax = 1.21    # 21%
so that means I should display product price with tax:
price_with_tax = price_without_tax * quantity * tax     # 344.93469999999996 
price_with_tax_rounded = Decimal(price_with_tax).quantize(Decimal('.01'), rounding=ROUND_UP)     # 344.94
So the price I display for product is 344.94. The problem is that if I do the same calculation for
two products:
quantity = 2
total = price_without_tax * quantity * tax     #  689.8693999999999
I would like to get to get to price = 689.88 which would make sense,
but rounding gets me to 689.87 which I guess can be confusing for customer. Also I need to add tax
on the "total price" and not to every product individually because, sometimes I need to do some
discount subtractions on total_price without tax.

Any tips?

Thanks in advance
Reply


Messages In This Thread
price + tax rounding - by mlieqo - Sep-20-2019, 04:14 PM
RE: price + tax rounding - by metulburr - Sep-20-2019, 05:57 PM
RE: price + tax rounding - by mlieqo - Sep-20-2019, 07:00 PM
RE: price + tax rounding - by metulburr - Sep-20-2019, 07:32 PM
RE: price + tax rounding - by mlieqo - Sep-20-2019, 07:53 PM
RE: price + tax rounding - by snippsat - Sep-20-2019, 09:01 PM
RE: price + tax rounding - by navidmo - Sep-20-2019, 09:19 PM
RE: price + tax rounding - by mlieqo - Sep-20-2019, 09:31 PM
RE: price + tax rounding - by snippsat - Sep-20-2019, 10:01 PM
RE: price + tax rounding - by mlieqo - Sep-20-2019, 10:12 PM
RE: price + tax rounding - by DeaD_EyE - Sep-21-2019, 01:52 PM
RE: price + tax rounding - by mlieqo - Sep-21-2019, 04:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  need help rounding joseph202020 7 1,340 Feb-21-2023, 08:13 PM
Last Post: joseph202020
  from numpy array to csv - rounding SchroedingersLion 6 2,208 Nov-14-2022, 09:09 PM
Last Post: deanhystad
  Finding the price based on industry and number of transactions chandramouliarun 0 915 Jul-26-2022, 07:36 PM
Last Post: chandramouliarun
  class - calculate total price of copies 3lnyn0 1 1,575 Dec-12-2021, 11:43 PM
Last Post: BashBedlam
  Random data generation sum to 1 by rounding juniorcoder 9 3,457 Oct-20-2021, 03:36 PM
Last Post: deanhystad
  Rounding issue kmll 1 1,426 Oct-08-2021, 10:35 AM
Last Post: Yoriz
Exclamation Invalid syntax error(Predict Ethereum Price) lulu43366 2 3,183 Sep-24-2021, 01:24 PM
Last Post: lulu43366
  Not rounding to desired decimal places? pprod 2 2,575 Mar-05-2021, 11:11 AM
Last Post: pprod
  Decimal Rounding error project_science 4 2,777 Jan-06-2021, 03:14 PM
Last Post: project_science
  An important question is how to create a zigzag in price data? epsilon 0 1,313 Nov-18-2020, 08:06 PM
Last Post: epsilon

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020