<commit_before>Given /^there is a configuration item named "([^\"]*)" with value "([^\"]*)"$/ do |name, value|
  ci = ConfigurationItem.new(:description => name,:name => name, :key => name, :value => value)
  ci.save
end

When /^I invoice the order$/ do
  # TODO: This depends on these accounts actually being there. Create the accounts
  # if they aren't. Find them, if they need to be found.
  ConfigurationItem.create(:name => "accounts_receivable_id", :key => "accounts_receivable_id", :value => Account.find_by_name("Accounts Receivable"))
  
  ConfigurationItem.create(:name => "sales_income_account_id", :key => "sales_income_account_id", :value => Account.find_by_name("Product Sales"))
  
  @invoice = Invoice.create_from_order(@order)
end

When /^the invoice is paid$/ do
  # TODO: These accounts should all exist and be configured in the system anyway.
  # Should make sure that they exist in the core of the system instead of here.
  accts_receivable = Account.find_by_name("Accounts Receivable")
  ci = ConfigurationItem.create(:key => "accounts_receivable_id",
                                :value => accts_receivable.id)
  
  bank_account = Account.find_by_name("Bank")
  ci = ConfigurationItem.find_or_create_by_key(:key => "cash_account_id", 
                                :value => bank_account.id)
  
  @invoice.record_payment_transaction
end

Then /^the invoice total is (\d+\.\d+)$/ do  |num|   
   puts "invoice total: incoming #{num.inspect} of class #{num.class}, string form #{num.to_s} actual taxed price #{@invoice.taxed_price.inspect} number to bigdecimal: #{BigDecimal.new(num.to_s).inspect}"
   puts "and the two are the same" if @invoice.taxed_price == BigDecimal.new(num.to_s)
   
   @invoice.taxed_price.should == BigDecimal.new(num.to_s)
end

Then /^the balance of the sales income account is (\d+\.\d+)$/ do |balance|
  Account.find(ConfigurationItem.get('sales_income_account_id').value).balance.should == BigDecimal.new(balance.to_s)
end<commit_msg>These tests are stupidly stubborn on the CI environment...<commit_after>Given /^there is a configuration item named "([^\"]*)" with value "([^\"]*)"$/ do |name, value|
  ci = ConfigurationItem.new(:description => name,:name => name, :key => name, :value => value)
  ci.save
end

When /^I invoice the order$/ do
  # TODO: This depends on these accounts actually being there. Create the accounts
  # if they aren't. Find them, if they need to be found.
  ConfigurationItem.create(:name => "accounts_receivable_id", :key => "accounts_receivable_id", :value => Account.find_by_name("Accounts Receivable"))
  
  ConfigurationItem.create(:name => "sales_income_account_id", :key => "sales_income_account_id", :value => Account.find_by_name("Product Sales"))
  
  @invoice = Invoice.create_from_order(@order)
end

When /^the invoice is paid$/ do
  # TODO: These accounts should all exist and be configured in the system anyway.
  # Should make sure that they exist in the core of the system instead of here.
  accts_receivable = Account.find_by_name("Accounts Receivable")
  ci = ConfigurationItem.create(:key => "accounts_receivable_id",
                                :value => accts_receivable.id)
  
  bank_account = Account.find_by_name("Bank")
  ci = ConfigurationItem.find_or_create_by_key(:key => "cash_account_id", 
                                :value => bank_account.id)
  
  @invoice.record_payment_transaction
end

Then /^the invoice total is (\d+\.\d+)$/ do  |num|   
   puts "HELLO? ANYONE LISTENING?"
   puts "invoice total: incoming #{num.inspect} of class #{num.class}, string form #{num.to_s} actual taxed price #{@invoice.taxed_price.inspect} number to bigdecimal: #{BigDecimal.new(num.to_s).inspect}"
   puts "and the two are the same" if @invoice.taxed_price == BigDecimal.new(num.to_s)
   
   @invoice.taxed_price.should == BigDecimal.new(num.to_s)
end

Then /^the balance of the sales income account is (\d+\.\d+)$/ do |balance|
  Account.find(ConfigurationItem.get('sales_income_account_id').value).balance.should == BigDecimal.new(balance.to_s)
end
{'fraction_non_alphanumeric': 0.12980295566502464, 'fraction_numerical': 0.0, 'mean_word_length': 4.069912609238452, 'pattern_counts': {'":': 0, '<': 3, '<?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': '815836', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1286, 'n_words': 359}