Skip to content

Instantly share code, notes, and snippets.

@maxehmookau
Created May 20, 2016 15:07
Show Gist options
  • Save maxehmookau/b13e3d3887317236d82dc79346d01b4f to your computer and use it in GitHub Desktop.
Save maxehmookau/b13e3d3887317236d82dc79346d01b4f to your computer and use it in GitHub Desktop.
VAT_RATE = 20.0
# Public: Get the total amount for an invoice taking additional users in to
# account.
#
# Params
# ex_vat - if true, subtract 20% from amount
#
# Returns a number
def total_amount(ex_vat = false)
if number_of_permitted_users <= BASE_PERMITTED_USERS
total = instance.subscription_amount
else
total = instance.subscription_amount + (number_of_permitted_users - BASE_PERMITTED_USERS) * ADDITIONAL_USERS_EACH
end
if ex_vat
return total * (1 - (VAT_RATE / 100.0))
else
return total
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment