probot-tax-calculator
Version:
A package calculate probot tax
21 lines (20 loc) • 643 B
JavaScript
;
const tax = (amount, wassit = 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
};
};
module.exports = tax;