# File lib/quickbooks/base.rb, line 228
    def save
      return false unless dirty?
      self.errors.clear # Clear out any errors: start with a clean slate!
      if new_record?
        self.class.query(self, :add)
        ret = !dirty?
        @new_record = false if ret
      else
        # Smart system that respects EditSequences and other people's changes.
        # 1) Try to save
        # 2) When we get a status of 3200, that means our EditSequence is not up to date
        # 3) Replace self's original_attributes with those just retrieved, and update the automatic attributes, like EditSequence and TimeModified
        # 4) Return false, return the object dirty but ready to save
        old_originals = original_values.dup # Save the old_originals so we can detect any attributes that changed since we last loaded the object
        ret = self.class.query(self, :mod).error? ? false : true # Saves if possible, if EditSequence is out of date, it will read the up-to-date object into original_values
        # If save failed (dirty?) because of old record (status 3200), but none of the fields conflict (attributes I've modified and are still different aren't the same attributes as any of the attributes someone else updated), then re-save!
        if dirty? && self.response_log.last.status == 3200 && (dirty_attributes.only(dirty_attributes(old_originals).keys).keys - self.class.read_only.stringify_values).length == (dirty_attributes(old_originals).keys - old_originals.diff(original_values).keys - self.class.read_only.stringify_values).length
          # 'Revert' fields I didn't modify to equal the values of the more up-to-date record just loaded.
          # Fields I didn't modify: dirty_attributes - dirty_attributes(old_originals).keys
          (dirty_attributes - dirty_attributes(old_originals).keys).each_key do |at|
            self.send(at + '=', original_values[at]) if respond_to?(at + '=')
          end
          ret = self.save
        end
      end
      # ret should be a false value if self has errors. Either way, ret gets the errors too.
      ret.errors << self.errors if self.error?
      # Should be true or false with an error attached.
      ret
    end