package handlers import ( "encoding/json" "net/http" "mgit.msbls.de/m/KanzlAI-mGMT/internal/models" "mgit.msbls.de/m/KanzlAI-mGMT/internal/services" ) // FeeCalculatorHandler handles fee calculation API endpoints. type FeeCalculatorHandler struct { calc *services.FeeCalculator } func NewFeeCalculatorHandler(calc *services.FeeCalculator) *FeeCalculatorHandler { return &FeeCalculatorHandler{calc: calc} } // Calculate handles POST /api/fees/calculate. func (h *FeeCalculatorHandler) Calculate(w http.ResponseWriter, r *http.Request) { var req models.FeeCalculateRequest if err := json.NewDecoder(r.Body).Decode(&req); err != nil { writeError(w, http.StatusBadRequest, "invalid request body") return } if req.Streitwert <= 0 { writeError(w, http.StatusBadRequest, "streitwert must be positive") return } if req.VATRate < 0 || req.VATRate > 1 { writeError(w, http.StatusBadRequest, "vat_rate must be between 0 and 1") return } if len(req.Instances) == 0 { writeError(w, http.StatusBadRequest, "at least one instance is required") return } resp, err := h.calc.CalculateFullLitigation(req) if err != nil { writeError(w, http.StatusBadRequest, err.Error()) return } writeJSON(w, http.StatusOK, resp) } // Schedules handles GET /api/fees/schedules. func (h *FeeCalculatorHandler) Schedules(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusOK, h.calc.GetSchedules()) }