Score:0

Tax round calculation on order

jp flag

How can we round up the tax to 2 decimals, but the last decimal should be either 0 or 5. I have this rule for the round up:

if ($decimal % 10 <= 2) {
  // Here, the last decimal should be 0.
}
else if ($decimal%10 > 2 && $decimal%10 <=7) {
  // Here, the last decimal should be 5.
}
else {
  // Here, the decimal should be incremented by 1, while making the last decimal 0.
}

For examples:

  • 10.24, rounds up to 10.25
  • 10.67 rounds up to 10.65
  • 10.88 rounds up to 10.90
  • 10.99 rounds up to 11.00

Can I alter the tax adjustment somewhere? Also, I would like to calculate it on the full order price, not individually for all order items.

apaderno avatar
us flag
Welcome to Drupal Answers! Are you asking how to achieve what described with code, or with a module?
Ivan Ginovski avatar
jp flag
With code if it is possible, even with a patch on commerce that I could attach
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.