function getDiscountedRate(transactionAmount, baseRate) {
let discount = 0;
const rateTiers = [
{ min: 15001, rate: 1 },
{ min: 5001, rate: 0.7 },
{ min: 1001, rate: 0.55 },
{ min: 201, rate: 0.35 },
{ min: 51, rate: 0.2 },
{ min: 0, rate: 0.0 }
];
const sortedThresholds = rateTiers.sort((a, b) => b.min - a.min);
for (const threshold of sortedThresholds) {
if (transactionAmount >= threshold.min) {
discount = threshold.rate;
break;
}
}
const discountedRate = baseRate * (1 + discount / 100);
return Number(discountedRate.toFixed(2));
}