<commit_before>class BookingsController < AuthorizedController
  # Scopes
  has_scope :by_value_period, :using => [:from, :to], :default => proc { |c| c.session[:has_scope] }
  has_scope :by_text

  # Actions
  def index
    @bookings = apply_scopes(Booking).accessible_by(current_ability, :list).includes(:credit_account, :debit_account).paginate(:page => params[:page], :per_page => params[:per_page])
    index!
  end

  def new
    @booking = Booking.new(:value_date => Date.today)
    @booking_templates = BookingTemplate.where("NOT(code LIKE '%:%')").paginate(:page => params[:page])
    new!
  end

  def select_booking
    @booking = Booking.find(params[:id]).clone
    @booking.value_date = params[:booking][:value_date]
    render :action => 'edit'
  end

  def select_booking_template
    @booking_template = BookingTemplate.find(params[:id]).clone

    booking_params = params[:booking] || {}
    booking_params[:value_date] ||= Date.today
    @booking = @booking_template.build_booking(booking_params)

    render :action => 'simple_edit'
  end

  def select
    @booking = Booking.new(params[:booking])
    @booking_templates = BookingTemplate.where("NOT(code LIKE '%:%')").paginate(:page => params[:page])
    @bookings = Booking.where("title LIKE ?", '%' + @booking.title + '%').order('value_date DESC').paginate(:page => params[:page])
  end

  def create
    @booking = Booking.new(params[:booking])

    create! do |success, failure|
      success.html {redirect_to new_booking_path(:notice => render_to_string(:partial => 'layouts/flash_new', :locals => {:object => @booking}))}<commit_msg>Autoincrement bookings code for new bookings.<commit_after>class BookingsController < AuthorizedController
  # Scopes
  has_scope :by_value_period, :using => [:from, :to], :default => proc { |c| c.session[:has_scope] }
  has_scope :by_text

  # Actions
  def index
    @bookings = apply_scopes(Booking).accessible_by(current_ability, :list).includes(:credit_account, :debit_account).paginate(:page => params[:page], :per_page => params[:per_page])
    index!
  end

  def new
    @booking = Booking.new(:value_date => Date.today)
    @booking_templates = BookingTemplate.where("NOT(code LIKE '%:%')").paginate(:page => params[:page])
    new!
  end

  def select_booking
    @booking = Booking.find(params[:id]).clone
    @booking.value_date = params[:booking][:value_date]
    render :action => 'edit'
  end

  def select_booking_template
    @booking_template = BookingTemplate.find(params[:id]).clone

    booking_params = params[:booking] || {}
    booking_params[:value_date] ||= Date.today
    booking_params[:code]       ||= (Booking.maximum(:code) || 0) + 1
    @booking = @booking_template.build_booking(booking_params)

    render :action => 'simple_edit'
  end

  def select
    @booking = Booking.new(params[:booking])
    @booking_templates = BookingTemplate.where("NOT(code LIKE '%:%')").paginate(:page => params[:page])
    @bookings = Booking.where("title LIKE ?", '%' + @booking.title + '%').order('value_date DESC').paginate(:page => params[:page])
  end

  def create
    @booking = Booking.new(params[:booking])

    create! do |success, failure|
      success.html {redirect_to new_booking_path(:notice => render_to_string(:partial => 'layouts/flash_new', :locals => {:object => @booking}))}
{'fraction_non_alphanumeric': 0.15773630343166767, 'fraction_numerical': 0.0006020469596628537, 'mean_word_length': 4.7791304347826085, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2123139', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1081, 'n_words': 200}