<commit_before># encoding: utf-8

class Ifin24::Commands::AddExpense < Ifin24::Commands::Base
  include Ifin24::Models

  def execute
    entry = get_entry

    console_menu('Powrót do głównego menu') do |menu|
      menu.choice("Nazwa: #{entry.title}") { get_title_for(entry) }
      menu.choice("Data: #{entry.date}") { get_date_for(entry) }
      menu.choice("Konto: #{entry.account.name}") { get_account_for(entry) }
      menu.choice("Kategoria: #{entry.category_full_name}") { get_category_for(entry) }
      menu.choice("Kwota: #{entry.amount}") { get_amount_for(entry) }
      menu.choice("Tagi: #{entry.tags}") { get_tags_for(entry) }
      menu.choice("Opis: #{entry.note}") { get_note_for(entry) }

      menu.choice("Wyślij") do
        puts "Wysyłanie danych..."
        @client.send_entry(entry)
        throw :all_ok
      end
    end
  end

  private

  def get_entry
    entry = Entry.new

    get_title_for(entry)
    get_date_for(entry)
    get_account_for(entry)
    get_category_for(entry)
    get_amount_for(entry)
    get_tags_for(entry)
    get_note_for(entry)

    return entry
  end

  def get_title_for(entry)
    entry.title = ask('Nazwa: ')
  end

  def get_date_for(entry)
    curr_date = Date.today
    entry.date = ask('Data: ') do |q|
      q.default = curr_date
    end
  end

  def get_account_for(entry)
    choose do |menu|
      menu.prompt = 'Wybierz rachunek: '

      @client.accounts.each do |account|
        menu.choice(account.name) do
          entry.account = account
        end
      end
    end
  end

  def get_category_for(entry)
    choose do |menu|
      menu.prompt = 'Wybierz kategorię: '

      @client.categories.each do |category|
        menu.choice(category.name) do
          entry.category = category
        end
      end
    end

    choose do |menu|
      menu.prompt = 'Wybierz podkategorię: '

      entry.category.children.each do |child|
        menu.choice(child.name) do
          entry.sub_category = child
        end
      end
    end
  end

  def get_amount_for(entry)
    entry.amount = eval ask('Kwota: ')
  end

  def get_tags_for(entry)
    entry.tags = ask('Tagi: ')
  end

  def get_note_for(entry)
    entry.note = ask('Opis: ')
  end

end
<commit_msg>Fix minor bug in menu.<commit_after># encoding: utf-8

class Ifin24::Commands::AddExpense < Ifin24::Commands::Base
  include Ifin24::Models

  def execute
    entry = get_entry

    console_menu('Powrót do głównego menu') do |menu|
      menu.choice("Nazwa: #{entry.title}") { get_title_for(entry) }
      menu.choice("Data: #{entry.date}") { get_date_for(entry) }
      menu.choice("Konto: #{entry.account.name}") { get_account_for(entry) }
      menu.choice("Kategoria: #{entry.category_full_name}") { get_category_for(entry) }
      menu.choice("Kwota: #{entry.amount}") { get_amount_for(entry) }
      menu.choice("Tagi: #{entry.tags}") { get_tags_for(entry) }
      menu.choice("Opis: #{entry.note}") { get_note_for(entry) }

      menu.choice("Wyślij") do
        puts "Wysyłanie danych..."
        @client.send_entry(entry)
        throw :exit
      end
    end
  end

  private

  def get_entry
    entry = Entry.new

    get_title_for(entry)
    get_date_for(entry)
    get_account_for(entry)
    get_category_for(entry)
    get_amount_for(entry)
    get_tags_for(entry)
    get_note_for(entry)

    return entry
  end

  def get_title_for(entry)
    entry.title = ask('Nazwa: ')
  end

  def get_date_for(entry)
    curr_date = Date.today
    entry.date = ask('Data: ') do |q|
      q.default = curr_date
    end
  end

  def get_account_for(entry)
    choose do |menu|
      menu.prompt = 'Wybierz rachunek: '

      @client.accounts.each do |account|
        menu.choice(account.name) do
          entry.account = account
        end
      end
    end
  end

  def get_category_for(entry)
    choose do |menu|
      menu.prompt = 'Wybierz kategorię: '

      @client.categories.each do |category|
        menu.choice(category.name) do
          entry.category = category
        end
      end
    end

    choose do |menu|
      menu.prompt = 'Wybierz podkategorię: '

      entry.category.children.each do |child|
        menu.choice(child.name) do
          entry.sub_category = child
        end
      end
    end
  end

  def get_amount_for(entry)
    entry.amount = eval ask('Kwota: ')
  end

  def get_tags_for(entry)
    entry.tags = ask('Tagi: ')
  end

  def get_note_for(entry)
    entry.note = ask('Opis: ')
  end

end

{'fraction_non_alphanumeric': 0.11771275407639044, 'fraction_numerical': 0.003127094036184945, 'mean_word_length': 2.6229773462783172, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '953910', 'n_tokens_mistral': 1607, 'n_tokens_neox': 1586, 'n_words': 310}