class Decidim::Meetings::Admin::MeetingAgendaForm

def agenda_items_duration_too_long

def agenda_items_duration_too_long
  agenda_items.each do |agenda_item|
    children_duration = agenda_item.agenda_item_children.sum(&:duration)
    if children_duration > agenda_item.duration
      difference = children_duration - agenda_item.duration
      errors.add(:base, :too_many_minutes_child, parent_title: translated_attribute(agenda_item.title), count: difference)
    end
  end
end