Version 1 of 1 · · Current version

tags
#events

events-registrations

A new registration. The organizers hear who registered; the ticket type and the event count it (the event's seatsLeft follows), and when it reaches its capacity it's marked sold out, and the organizers are told that too.

$when events.registered (id: String) {
  r = dom.find(cls = "Registration", key = id)
  a = dom.find(cls = "Attendee", key = r.attendee)
  t = dom.find(cls = "TicketType", key = r.ticketType)
  sold = t.sold + 1
  full = sold >= t.capacity
  dom.upsert(cls = "TicketType", entity = t + {sold: sold, status: if full then "sold out" else t.status})
  e = dom.find(cls = "Event", key = t.event)
  dom.upsert(cls = "Event", entity = e + {registered: e.registered + 1})
  events.tellOrganizers(text = "${a.name} registered (${t.name})")
  if (full) {
    events.tellOrganizers(text = "${t.name} tickets are sold out")
  }
  payload = {ticket: t.id, sold: sold, soldOut: full}
}

A payment received. The registration is paid, an invoice is issued, and the attendee gets their badge.

$when events.paid (id: String) {
  p = dom.find(cls = "Payment", key = id)
  r = dom.find(cls = "Registration", key = p.registration)
  a = dom.find(cls = "Attendee", key = r.attendee)
  dom.upsert(cls = "Registration", entity = r + {status: "paid"})
  dom.upsert(cls = "Invoice", entity = {number: "INV-${r.id}", registration: r.id, amount: p.amount, issued: now()})
  dom.upsert(cls = "Badge", entity = {id: "b-${r.id}", registration: r.id, name: a.name, printed: false})
  events.notify(to = a.email, text = "Thanks, ${a.name}: you're in. Your badge: b-${r.id}")
  payload = {invoice: "INV-${r.id}", badge: "b-${r.id}"}
}