feat: admin Verktyg (live fordon + sanktioner lookup) + service-type pricing in configurator
/admin/verktyg uses live /api/vehicles (RDW) + /api/screen (OpenSanctions); added to admin nav. Configurator now has a Tjänst selector that applies each service's price multiplier (lib/services) to the live estimate + summary; service_type carried into the order so orders-store prices by service. tsc 0, build green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+3
-1
@@ -99,6 +99,7 @@ export interface EstimateInput {
|
||||
volume: number;
|
||||
frequency: Frequency;
|
||||
confidence: number; // target 80–99
|
||||
serviceMult?: number; // service-type price multiplier (see lib/services)
|
||||
}
|
||||
|
||||
export interface Estimate {
|
||||
@@ -118,7 +119,8 @@ export function computeEstimate(input: EstimateInput): Estimate {
|
||||
const confidenceMult = 1 + Math.max(0, input.confidence - 90) * 0.03;
|
||||
const enrichWeight = ENRICHMENTS.filter((e) => input.enrichmentIds.includes(e.id)).reduce((s, e) => s + e.weight, 0);
|
||||
|
||||
const base = fieldWeight * markets * FIELD_RATE * (input.volume / 1000) * entityMult * confidenceMult;
|
||||
const serviceMult = input.serviceMult ?? 1;
|
||||
const base = fieldWeight * markets * FIELD_RATE * (input.volume / 1000) * entityMult * confidenceMult * serviceMult;
|
||||
const price = Math.round((base * (1 + enrichWeight)) / 5) * 5; // round to 5 kr
|
||||
const deposit = Math.round(price / 2);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { getSql } from "@/lib/db";
|
||||
import { computeEstimate, type EntityType, type Frequency } from "@/lib/data";
|
||||
import { serviceById } from "@/lib/services";
|
||||
|
||||
export interface OrderConfig {
|
||||
markets?: string[];
|
||||
@@ -10,6 +11,7 @@ export interface OrderConfig {
|
||||
frequency?: Frequency;
|
||||
confidence?: number;
|
||||
formats?: string[];
|
||||
service_type?: string;
|
||||
}
|
||||
|
||||
export interface Order {
|
||||
@@ -37,6 +39,7 @@ function estimateFor(config: OrderConfig) {
|
||||
volume: config.volume ?? 1000,
|
||||
frequency: config.frequency ?? "Engångs",
|
||||
confidence: config.confidence ?? 92,
|
||||
serviceMult: serviceById(config.service_type ?? "")?.mult ?? 1,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user