/*
 * Business settings loaded from application.yml (store hours,
 * slot intervals, image size limits, discount/loyalty config).
 *
 * Author: Harkamal
 * Date: April 2026
 */
package com.petshop.backend.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.math.BigDecimal;
import java.time.LocalTime;

@ConfigurationProperties(prefix = "petshop.business")
public record BusinessProperties(
        LocalTime openTime,
        LocalTime closeTime,
        int slotIntervalMinutes,
        long maxImageSizeBytes,
        BigDecimal employeeDiscountPercent,
        int loyaltyPointsPerDollar
) {
    public BusinessProperties {
        if (openTime == null) openTime = LocalTime.of(9, 0);
        if (closeTime == null) closeTime = LocalTime.of(17, 0);
        if (slotIntervalMinutes <= 0) slotIntervalMinutes = 30;
        if (maxImageSizeBytes <= 0) maxImageSizeBytes = 5 * 1024 * 1024;
        if (employeeDiscountPercent == null) employeeDiscountPercent = new BigDecimal("0.10");
        if (loyaltyPointsPerDollar <= 0) loyaltyPointsPerDollar = 20;
    }
}
