change price logic on the ,rule engine ui, auto generate the contrat

This commit is contained in:
marshal
2026-06-08 10:04:23 +03:00
parent 4993453993
commit 88df20be6b
76 changed files with 4907 additions and 225 deletions

View File

@@ -0,0 +1,32 @@
import type { RuleEngineRecord, RuleEngineResourceSlug } from "@/types/rule-engine";
export const RULE_ENGINE_POSITION_END = "__end__";
export function getOrderItemLabel(
record: RuleEngineRecord,
slug: RuleEngineResourceSlug,
): string {
const code = String(record.code ?? "").trim();
switch (slug) {
case "cargo-types":
return String(record.cargoTypeName ?? (code || record.id));
case "container-types":
case "yards":
case "shipping-lines":
return String(record.label ?? (code || record.id));
case "service-types":
return String(record.serviceName ?? (code || record.id));
case "approval-rules":
return String(record.actionLabel ?? record.requiredRole ?? record.id);
default:
return String(record.label ?? record.code ?? record.id);
}
}
export function getOrderValue(
record: RuleEngineRecord,
field: "displayOrder" | "stepOrder",
): number {
const raw = record[field];
return typeof raw === "number" ? raw : Number(raw ?? 0);
}