from ..utils.cost_factor_loader import get_cost_factors def calculate_base_price(mold_main_type, mold_sub_type, mold_specific_type, sliders_count, cavity_count, digital_texture_type, complexity_high_sidewall=False): """ Calculate the base price for a mold based on various factors. Args: mold_main_type (str): The main type of the mold mold_sub_type (str): The sub type of the mold mold_specific_type (str): The specific type of the mold sliders_count (int): Number of sliders cavity_count (int): Number of cavities digital_texture_type (str): Type of digital texture complexity_high_sidewall (bool): Whether the mold has high sidewall complexity Returns: dict: A dictionary containing all cost components """ # Get cost factors from database (or fallback to defaults) cost_factors, tax_rates, default_net_base = get_cost_factors() # Start with the default net base base_price = default_net_base # Apply mold type factor if mold_specific_type in cost_factors['mold']: base_price *= cost_factors['mold'][mold_specific_type] # Calculate complexity cost complexity_cost = 0 # Add slider complexity if sliders_count > 0: complexity_cost += base_price * (sliders_count * cost_factors['complexity']['slider']) # Add cavity complexity if cavity_count > 1: complexity_cost += base_price * ((cavity_count - 1) * cost_factors['complexity']['cavity']) # Add high sidewall complexity if complexity_high_sidewall: complexity_cost += base_price * cost_factors['complexity']['high_sidewall'] # Calculate texture cost texture_cost = 0 if digital_texture_type in cost_factors['texture']: texture_cost = base_price * cost_factors['texture'][digital_texture_type] # Calculate total cost total_cost = base_price + complexity_cost + texture_cost return { 'base_price': round(base_price, 2), 'complexity_cost': round(complexity_cost, 2), 'texture_cost': round(texture_cost, 2), 'total_cost': round(total_cost, 2) }