UNPKG

probot-tax-calculator

Version:
32 lines (21 loc) 642 B
//Type Script better ;) const tax = (amount: number | string, wassit: number | string = 2.5) => { let probot_tax_percentage = 5 amount = Math.round(+amount) let wassit_percentage = +wassit if (!amount || isNaN(amount) || amount <= 0 || isNaN(wassit_percentage) || wassit <= 0) { throw new Error("Invalid Arguments") } let probot_tax = Math.round(amount * probot_tax_percentage / 100) let wassit_tax = Math.round (amount * wassit_percentage / 100) let tax = probot_tax + wassit_tax let all = amount + tax return { "protax": probot_tax, "wasitTax": wassit_tax, tax, all } } export =tax