Files
rentall-app/backend/utils/feeCalculator.js
2025-11-07 15:51:32 -05:00

26 lines
752 B
JavaScript

class FeeCalculator {
static calculateRentalFees(totalAmount) {
const platformFeeRate = 0.1;
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)} (10%)`,
totalCharge: `$${fees.totalChargedAmount.toFixed(2)}`,
ownerPayout: `$${fees.payoutAmount.toFixed(2)}`,
};
}
}
module.exports = FeeCalculator;