// Функции расчета для калькулятора мыла export function calculateSoapStep( stepId: string, values: Record ): number { const { weight = 0, basePrice = 0, aromaPrice = 0, aromaWeight = 0, pigmentPrice = 0, pigmentWeight = 0, moldPrice = 0, box = 0, filler = 0, ribbon = 0, label = 0, } = values; switch (stepId) { case 'base': if (weight <= 0 || basePrice <= 0) return 0; return (weight / 1000) * basePrice; case 'aroma': if (weight <= 0 || aromaWeight <= 0 || aromaPrice <= 0) return 0; return ((weight * 0.01) / aromaWeight) * aromaPrice; case 'pigment': if (weight <= 0 || pigmentWeight <= 0 || pigmentPrice <= 0) return 0; return ((weight * 0.005) / pigmentWeight) * pigmentPrice; case 'mold': if (moldPrice <= 0) return 0; return moldPrice / 100; case 'packaging': return (box || 0) + (filler || 0) + (ribbon || 0) + (label || 0); default: return 0; } } export function calculateSoapSubtotal( subtotalId: string, values: Record, steps: Record ): number { switch (subtotalId) { case 'operational': const subtotal = (steps.base || 0) + (steps.aroma || 0) + (steps.pigment || 0) + (steps.mold || 0) + (steps.packaging || 0); return subtotal * 0.05; case 'total': return ( (steps.base || 0) + (steps.aroma || 0) + (steps.pigment || 0) + (steps.mold || 0) + (steps.packaging || 0) + (steps.operational || 0) ); default: return 0; } } export function round(val: number): number { return Math.round(val * 10) / 10; }