def valid?
      @errors = []

      if !bank_transaction_id.nil? && bank_transaction_id !~ GUID_REGEX
        @errors << ['bank_transaction_id', 'must be blank or a valid Xero GUID']
      end

      if type && !TYPES[type]
        @errors << ['type', "must be one of #{TYPES.keys.join('/')}"]
      end

      if status && !STATUSES[status]
        @errors << ['status', "must be one of #{STATUSES.keys.join('/')}"]
      end

      unless date
        @errors << ['date', "can't be blank"]
      end

      # Make sure contact is valid.
      unless @contact && @contact.valid?
        @errors << ['contact', 'is invalid']
      end

      # Make sure all line_items are valid.
      unless line_items.all? { | line_item | line_item.valid? }
        @errors << ['line_items', "at least one line item invalid"]
      end

      @errors.size == 0
    end
def valid?
      @errors = []

      if !bank_transaction_id.nil? && bank_transaction_id !~ GUID_REGEX
        @errors << ['bank_transaction_id', 'must be blank or a valid Xero GUID']
      end

      if type && !TYPES[type]
        @errors << ['type', "must be one of #{TYPES.keys.join('/')}"]
      end

      if status && !STATUSES[status]
        @errors << ['status', "must be one of #{STATUSES.keys.join('/')}"]
      end

      unless date
        @errors << ['date', "can't be blank"]
      end

      # Make sure contact is valid.
      unless @contact && @contact.valid?
        @errors << ['contact', 'is invalid']
      end

      # Make sure all line_items are valid.
      unless line_items.all? { | line_item | line_item.valid? }
        @errors << ['line_items', "at least one line item invalid"]
      end

      @errors.size == 0
    end
Validate the BankTransaction record according to what will be valid by the gateway.

 Usage:
  bank_transaction.valid?     # Returns true/false

  Additionally sets bank_transaction.errors array to an array of field/error.