You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: line_check.rb
    path of file: ./repos/double_entry/lib/double_entry/validation
    
    the code of the file until where you have to start completion: # encoding: utf-8
require 'set'

module DoubleEntry
  module Validation
    class LineCheck < ActiveRecord::Base

      def self.last_line_id_checked
        order('created_at DESC').limit(1).pluck(:last_line_id).first || 0
      end

      def self.perform!(fixer: nil)
        new.perform(fixer: fixer)
      end

      def perform(fixer: nil)
        log = ''
        current_line_id = nil

        active_accounts    = Set.new
        incorrect_accounts = Set.new

        new_lines_since_last_run.find_each do |line
    
      def cached_balance_correct?(account, log)
        DoubleEntry.lock_accounts(account) do
          cached_balance = AccountBalance.find_by_account(account).balance
          running_balance = account.balance
          correct = (cached_balance == running_balance)
          log << <<~MESSAGE unless correct
            *********************************
            Error on account #{account}: #{cached_balance} (cached balance) != #{running_balance} (running balance)
            *********************************

          MESSAGE
          return correct
        end
      end