Files
rentall-app/backend/utils/feeCalculator.js
2025-09-04 16:44:47 -04:00

26 lines
752 B
JavaScript

class FeeCalculator {
static calculateRentalFees(totalAmount) {
const platformFeeRate = 0.2;
const platformFee = totalAmount * platformFeeRate;
return {
totalAmount: parseFloat(totalAmount.toFixed(2)),
platformFee: parseFloat(platformFee.toFixed(2)),
totalChargedAmount: parseFloat(totalAmount.toFixed(2)),
payoutAmount: parseFloat((totalAmount - platformFee).toFixed(2)),
};
}
static formatFeesForDisplay(fees) {
return {
totalAmount: `$${fees.totalAmount.toFixed(2)}`,
platformFee: `$${fees.platformFee.toFixed(2)} (20%)`,
totalCharge: `$${fees.totalChargedAmount.toFixed(2)}`,
ownerPayout: `$${fees.payoutAmount.toFixed(2)}`,
};
}
}
module.exports = FeeCalculator;