lib/zold/wallet.rb
def add(txn)
      raise 'The txn has to be of type Txn' unless txn.is_a?(Txn)
      raise "Wallet #{id} can't pay itself: #{txn}" if txn.bnf == id
      raise "The amount can't be zero in #{id}: #{txn}" if txn.amount.zero?
      if txn.amount.negative? && includes_negative?(txn.id)
        raise "Negative transaction with the same ID #{txn.id} already exists in #{id}"
      end
      if txn.amount.positive? && includes_positive?(txn.id, txn.bnf)
        raise "Positive transaction with the same ID #{txn.id} and BNF #{txn.bnf} already exists in #{id}"
      end
      raise "The tax payment already exists in #{id}: #{txn}" if Tax.new(self).exists?(txn.details)
      File.open(path, 'a') { |f| f.print "#{txn}\n" }
      @txns.flush
    end
def add(txn)
      raise 'The txn has to be of type Txn' unless txn.is_a?(Txn)
      raise "Wallet #{id} can't pay itself: #{txn}" if txn.bnf == id
      raise "The amount can't be zero in #{id}: #{txn}" if txn.amount.zero?
      if txn.amount.negative? && includes_negative?(txn.id)
        raise "Negative transaction with the same ID #{txn.id} already exists in #{id}"
      end
      if txn.amount.positive? && includes_positive?(txn.id, txn.bnf)
        raise "Positive transaction with the same ID #{txn.id} and BNF #{txn.bnf} already exists in #{id}"
      end
      raise "The tax payment already exists in #{id}: #{txn}" if Tax.new(self).exists?(txn.details)
      File.open(path, 'a') { |f| f.print "#{txn}\n" }
      @txns.flush
    end
Add a transaction to the wallet.