local order = {}

order.setdb = function(db)
  order.db = db
end

order.new = function(t)
  local order_record = {}
  order_record.type = 'order'
  order_record.cart_id = t.cart.id
  order_record.user_id = t.cart.user_id
  order_record.date_ordered = os.time()
  order_record.status = 'open'
  order_record.progress = 'ordered'
  
  order.db:insertrecord(order_record)
  
  t.cart.order_id = order_record.id
  t.cart:save()
  
  return order_record
end

return order