Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Last active June 5, 2026 16:31
Show Gist options
  • Select an option

  • Save trikitrok/86a1ec1e13bcd6840a1529e2f2ebe8a8 to your computer and use it in GitHub Desktop.

Select an option

Save trikitrok/86a1ec1e13bcd6840a1529e2f2ebe8a8 to your computer and use it in GitHub Desktop.

Calculating final price per unit of a product.

As a seller I'd like to compute the final price of a product including taxes in order to show it to my customers.

  1. Products have a cost per unit and tax percentage to apply.
  2. The cost per unit is in euros.
  3. The final price has to be rounded up. For instance, if the calculated final price of a product is 1.7825€, the expected final price for that product is 1.79€.
  4. The final price of the product is then calculated as the cost per unit with the taxes rounded up.
  5. All the prices are in euros.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment