@ultraviolet/plus
Version:
Ultraviolet Plus
17 lines (16 loc) • 403 B
JavaScript
import { multiplier } from "./constants.js";
const calculatePrice = ({
price,
amount,
amountFree = 0,
timeUnit,
timeAmount,
discount = 0
}) => {
const nonNanTimeAmount = Number.isNaN(timeAmount) ? 0 : timeAmount;
const value = (price - price * discount) * (nonNanTimeAmount * multiplier[`${timeUnit}`]) * Math.max(amount - amountFree, 0);
return value;
};
export {
calculatePrice
};