mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 20:40:55 +00:00
change price logic on the ,rule engine ui, auto generate the contrat
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user