export { applyPricingRules } from '../../services/pricingRuleService'

export function calculateUpdatedInsuranceCharge(
  chargeType: 'PER_DAY' | 'PER_RENTAL' | 'PERCENTAGE_OF_RENTAL',
  chargeValue: number,
  totalDays: number,
  baseRentalAmount: number,
): number {
  switch (chargeType) {
    case 'PER_DAY':              return chargeValue * totalDays
    case 'PER_RENTAL':           return chargeValue
    case 'PERCENTAGE_OF_RENTAL': return Math.round(baseRentalAmount * chargeValue / 100)
    default:                     return 0
  }
}

export function calculateUpdatedAdditionalDriverCharge(
  chargeType: 'PER_DAY' | 'FLAT' | 'FREE',
  chargeValue: number,
  totalDays: number,
): number {
  switch (chargeType) {
    case 'PER_DAY': return chargeValue * totalDays
    case 'FLAT':    return chargeValue
    default:        return 0
  }
}
