Skip to content

calculateTax

calculateTax(amount, rate) → number · Financial

Calculate the tax amount for a given amount and rate (returns only the tax portion, not the total).

  • amount (required): taxable amount

  • rate (required): tax rate as decimal (e.g., 0.21 for 21%)

bash
echo '{"subtotal": 500, "vatRate": 0.21}' | utlx -e 'calculateTax($input.subtotal, $input.vatRate)'
# 105.0
utlx
{
  subtotal: $input.amount,
  tax: calculateTax($input.amount, 0.21),
  total: addTax($input.amount, 0.21)
}

Released under AGPL-3.0.