<commit_before>module Spree
  module Core
    module Importer
      Order.class_eval do
        def self.import(user, params)
          begin
            ensure_country_id_from_params params[:ship_address_attributes]
            ensure_state_id_from_params params[:ship_address_attributes]
            ensure_country_id_from_params params[:bill_address_attributes]
            ensure_state_id_from_params params[:bill_address_attributes]

            create_params = params.slice :currency, :reseller, :reseller_reference
            order = Spree::Order.create! create_params
            order.associate_user!(user)

            create_line_items_from_params(params.delete(:line_items_attributes),order)
            create_shipments_from_params(params.delete(:shipments_attributes), order)
            create_adjustments_from_params(params.delete(:adjustments_attributes), order)
            create_payments_from_params(params.delete(:payments_attributes), order)<commit_msg>adjustable create_params in order importer<commit_after>module Spree
  module Core
    module Importer
      Order.class_eval do
        def self.import(user, params, options={})
          begin
            ensure_country_id_from_params params[:ship_address_attributes]
            ensure_state_id_from_params params[:ship_address_attributes]
            ensure_country_id_from_params params[:bill_address_attributes]
            ensure_state_id_from_params params[:bill_address_attributes]

            # Use options[:create_params] to insert any attributes which need to be present before
            # creating line items, shipments, etc
            create_params = [:currency] + (options[:create_params] || [])
            create_params = params.slice(*create_params)

            order.associate_user!(user)

            create_line_items_from_params(params.delete(:line_items_attributes),order)
            create_shipments_from_params(params.delete(:shipments_attributes), order)
            create_adjustments_from_params(params.delete(:adjustments_attributes), order)
            create_payments_from_params(params.delete(:payments_attributes), order)
{'fraction_non_alphanumeric': 0.06835205992509363, 'fraction_numerical': 0.0, 'mean_word_length': 3.556503198294243, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5388902', 'n_tokens_mistral': 560, 'n_tokens_neox': 548, 'n_words': 90}