<commit_before>require 'double_entry'

Money.default_currency = Money::Currency.new(ENV["DEFAULT_CURRENCY"] || "INR")

DoubleEntry.configure do |config|
  config.define_accounts do |accounts|
    accounts.define(identifier: :wallet, scope_identifier: accounts.active_record_scope_identifier(Wallet), positive_only: true)
    accounts.define(identifier: :recharger, scope_identifier: accounts.active_record_scope_identifier(Recharger))
    accounts.define(identifier: :revenue, scope_identifier: accounts.active_record_scope_identifier(Revenue), positive_only: true)
  end

  config.define_transfers do |transfers|
    transfers.define(from: :recharger, to: :wallet, code: :recharge)
    transfers.define(from: :wallet, to: :revenue, code: :spend)
    transfers.define(from: :revenue, to: :wallet, code: :refund)
  end
end<commit_msg>Allowing overdraft if the OVERDRAFT env variable is set to true or 1<commit_after>require 'double_entry'

Money.default_currency = Money::Currency.new(ENV["DEFAULT_CURRENCY"] || "INR")

DoubleEntry.configure do |config|
  config.define_accounts do |accounts|
    positive_values_only = true
    if ENV["OVERDRAFT"] == "true" || ENV["OVERDRAFT"] == "1" 
      positive_values_only = false
    end
    accounts.define(identifier: :wallet, scope_identifier: accounts.active_record_scope_identifier(Wallet), positive_only: positive_values_only)
    accounts.define(identifier: :recharger, scope_identifier: accounts.active_record_scope_identifier(Recharger))
    accounts.define(identifier: :revenue, scope_identifier: accounts.active_record_scope_identifier(Revenue), positive_only: true)
  end

  config.define_transfers do |transfers|
    transfers.define(from: :recharger, to: :wallet, code: :recharge)
    transfers.define(from: :wallet, to: :revenue, code: :spend)
    transfers.define(from: :revenue, to: :wallet, code: :refund)
  end
end
{'fraction_non_alphanumeric': 0.11312700106723586, 'fraction_numerical': 0.0010672358591248667, 'mean_word_length': 6.530120481927711, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2958527', 'n_tokens_mistral': 598, 'n_tokens_neox': 604, 'n_words': 123}