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: accounting_system_changing_test.rb
    path of file: ./repos/ekylibre/test/services/accountancy
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

require 'test_helper'

module Accountancy
  class AccountingSystemChangingTest < Ekylibre::Testing::ApplicationTestCase::WithFixtures
    setup do
      I18n.locale = :fra
      FinancialYear.delete_all
      Preference.set!(:accounting_system, 'fr_pcga')
      Preference.set!(:account_numbe
    
      def new_purchase(type: 'PurchaseInvoice', nature: nil, supplier: nil, invoiced_at: nil, currency: 'EUR', state: nil, items_attributes: nil)
        attributes = {
          type: type,
          nature: nature || @nature,
          supplier: supplier || @supplier,
          invoiced_at: invoiced_at || @invoiced_at,
          currency: currency,
          state: state,
          items_attributes: items_attributes || {}
        }

        Purchase.create!(attributes)
      end