Vibescript Showcase

Late fee policy

Apply late-fee policy with money values, Duration aging buckets, and typed standing enums.

Showcase
Source showcase/finance/late_fee_policy.vibe
# title: Late fee policy
# category: Vibescript Showcase
# difficulty: Showcase
# summary: Apply late-fee policy with money values, Duration aging buckets, and typed standing enums.
# description: This example shows how financial policy code stays readable when overdue windows and fee amounts remain semantic all the way through.
# tags: finance, money, durations, enums
# vibe: 0.2

enum AccountStanding
  Current
  Grace
  Delinquent
end

def standing_for(overdue: duration) -> AccountStanding
  if overdue <= 3.days
    AccountStanding::Current
  elsif overdue <= 15.days
    AccountStanding::Grace
  else
    AccountStanding::Delinquent
  end
end

def late_fee(standing: AccountStanding) -> money
  if standing == AccountStanding::Current
    money("0.00 USD")
  elsif standing == AccountStanding::Grace
    money("12.00 USD")
  else
    money("35.00 USD")
  end
end

def account_snapshot(invoice_id: string, balance: money, overdue: duration) -> hash
  standing = standing_for(overdue)
  fee = late_fee(standing)

  {
    invoice_id: invoice_id,
    standing: standing.name,
    overdue: overdue.iso8601,
    balance: balance,
    late_fee: fee,
    total_due: balance + fee
  }
end

def run
  {
    grace: account_snapshot("inv_310", money("240.00 USD"), 7.days),
    delinquent: account_snapshot("inv_311", money("240.00 USD"), 28.days)
  }
end
Output
Press run to execute run from this example.
showcase idiomatic-vibescript finance money durations enums browser-runner