<commit_before>class OrderImporter < Client
  attr_accessor :order

  def consume
    response = import_to_quickbooks
    response.to_hash
  end

  private

  def quickbooks_address(address)
      a = Quickeebooks::Windows::Model::Address.new
      a.line1   = [address["firstname"], address["lastname"]].join(" ")
      a.line2   = address["address1"]
      a.line3   = address["address2"]
      a.city    = address["city"]
      a.country = address["country"]["name"]
      a.country_sub_division_code = address["state_name"] 
      a.country_sub_division_code ||= address["state"]["name"] if address["state"]
      a.postal_code = address["zipcode"]
      return a
    end

  def import_to_quickbooks
    raise "Total Fail <0" if @order['total'].to_f < 0
    raise "No Web Order Customer Defined in Quickbooks" unless quickbooks_customers.include?("Web Order")

    h = Quickeebooks::Windows::Model::SalesReceiptHeader.new
    h.doc_number = @order['number']
    payment_name = "None"

    if flatten_child_nodes(@order, "credit_card").first.present?
      payment_name = flatten_child_nodes(@order, "credit_card").first["cc_type"]
    elsif flatten_child_nodes(@order, "payment").first.present?
      payment_name = flatten_child_nodes(@order, "payment").first["payment_method"]["name"]
    end
    h.deposit_to_account_name = deposit_to_account_name(payment_name)

    h.class_name = "DRCT-LBT"

    create_account(h.deposit_to_account_name)

    h.total_amount = @order['total']
    h.txn_date = Time.parse(@order['completed_at']).in_time_zone("EST").strftime("%Y-%m-%d")
    h.customer_name = "Web Order"
    h.shipping_address = quickbooks_address(@order["ship_address"])
    h.note = [@order["bill_address"]["firstname"],@order["bill_address"]["lastname"]].join(" ")
    h.ship_method_name = ship_method_name(flatten_child_nodes(@order, "shipment").first["shipping_method"]["name"]) 
<commit_msg>Fix class mapping<commit_after>class OrderImporter < Client
  attr_accessor :order

  def consume
    response = import_to_quickbooks
    response.to_hash
  end

  private

  def quickbooks_address(address)
      a = Quickeebooks::Windows::Model::Address.new
      a.line1   = [address["firstname"], address["lastname"]].join(" ")
      a.line2   = address["address1"]
      a.line3   = address["address2"]
      a.city    = address["city"]
      a.country = address["country"]["name"]
      a.country_sub_division_code = address["state_name"] 
      a.country_sub_division_code ||= address["state"]["name"] if address["state"]
      a.postal_code = address["zipcode"]
      return a
    end

  def import_to_quickbooks
    raise "Total Fail <0" if @order['total'].to_f < 0
    raise "No Web Order Customer Defined in Quickbooks" unless quickbooks_customers.include?("Web Order")

    h = Quickeebooks::Windows::Model::SalesReceiptHeader.new
    h.doc_number = @order['number']
    payment_name = "None"

    if flatten_child_nodes(@order, "credit_card").first.present?
      payment_name = flatten_child_nodes(@order, "credit_card").first["cc_type"]
    elsif flatten_child_nodes(@order, "payment").first.present?
      payment_name = flatten_child_nodes(@order, "payment").first["payment_method"]["name"]
    end
    h.deposit_to_account_name = deposit_to_account_name(payment_name)

    h.class_name = "DRTC:LBT"

    create_account(h.deposit_to_account_name)

    h.total_amount = @order['total']
    h.txn_date = Time.parse(@order['completed_at']).in_time_zone("EST").strftime("%Y-%m-%d")
    h.customer_name = "<NAME>"
    h.shipping_address = quickbooks_address(@order["ship_address"])
    h.note = [@order["bill_address"]["firstname"],@order["bill_address"]["lastname"]].join(" ")
    h.ship_method_name = ship_method_name(flatten_child_nodes(@order, "shipment").first["shipping_method"]["name"]) 

{'fraction_non_alphanumeric': 0.1458934662818158, 'fraction_numerical': 0.0036735764891104696, 'mean_word_length': 4.516642547033285, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 4, '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': '2932865', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1254, 'n_words': 193}