Vibescript Showcase
Quote approval
Route quotes with money thresholds, approval enums, and structured decision output.
Source
showcase/commerce/quote_approval.vibe
# title: Quote approval
# category: Vibescript Showcase
# difficulty: Showcase
# summary: Route quotes with money thresholds, approval enums, and structured decision output.
# description: This example turns a common sales-ops rule set into small typed helpers so approval behavior stays auditable and obvious.
# tags: commerce, money, enums, approvals
# vibe: 0.2
enum ApprovalLane
AutoApprove
Manager
Finance
end
def approval_lane(total: money, margin_points: int) -> ApprovalLane
if total >= money("25000.00 USD") || margin_points < 20
ApprovalLane::Finance
elsif total >= money("5000.00 USD") || margin_points < 35
ApprovalLane::Manager
else
ApprovalLane::AutoApprove
end
end
def quote_decision(quote_id: string, total: money, margin_points: int) -> hash
lane = approval_lane(total, margin_points)
{
quote_id: quote_id,
total: total,
margin_points: margin_points,
approval_lane: lane.name,
note: "{{quote}} routes to {{lane}}".template({ quote: quote_id, lane: lane.name })
}
end
def run
{
self_serve: quote_decision("quote_410", money("1800.00 USD"), 48),
enterprise: quote_decision("quote_411", money("48000.00 USD"), 18)
}
end
Output
Press run to execute run from this example.