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: quick_purchases_controller_test.rb
    path of file: ./repos/ekylibre/test/controllers/backend
    
    the code of the file until where you have to start completion: require 'test_helper'
module Backend
  class QuickPurchasesControllerTest < Ekylibre::Testing::ApplicationControllerTestCase::WithFixtures
    setup do
      OutgoingPayment.delete_all
      Payslip.delete_all
      PayslipNature.delete_all
      Journal.delete_all
      Account.delete_all
      Cash.delete_all
      BankStatement.delete_all
      BankStatementItem.delete_all
      PurchaseNature.delete_all
      PurchaseAffair.destroy_all
      OutgoingPaymentMode.delete_all
      Entity.delete_all
      Purchase.delete_all
      PurchasePayment.delete_all
      Tax.delete_all
      Role.delete_all
      User.delete_all

      role = Role.create!(name: 'Imperator')
      user = User.create!(first_name: 'Furiosa', last_name: 'Vuvalini', email: 'furiosa@greenland.org', password: 'youkilledtheworld', role: role)
      sign_in user

      journal = Journal.create!(name: 'The Record')
      caps_act = Account.create!(name: 'Caps', 
    
      def complete_create_params(modes: { trade: :new, payment: :new }, matching: { cash: true, amount: true })
        amount = matching[:amount] ? 1379 : 1250
        mode = matching[:cash] ? @diesel : @caps
        @deal.reload
        @deal.update!(amount: amount)
        @deal.items.first.update!(amount: amount, unit_pretax_amount: amount / 500.0)
        @payment.reload
        @payment.update!(amount: amount, mode_id: mode.id)
        {
          'mode-trade': modes[:trade],
          'mode-payment': modes[:payment],
          affair: {
            trade_id: @deal.id,
            third_id: @max.id,
            payment_id: @payment.id
          },
          trade: {
            invoiced_at: Time.zone.now,
            nature_id: @nature.id,
            items_attributes: [{
                                 variant_id: @carrots,
                                 quantity: 100,
                                 amount: amount,
                                 tax_id: @citadels.id,
                                 reduction_percentage: 0,
                                 unit_pretax_amount: amount / 100.0
                               }]
          },
          payment: {
            mode_id: mode,
            amount: amount,
            bank_statement_item_ids: @tanks.map(&:id)
          }
        }
      end