Sha256: 61f18cbcd602961ec420fa260609589bc1bb9cb2cf286f8ac237aeeb7d5a1ade

Contents?: true

Size: 1.66 KB

Versions: 4

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

require 'builder'

module SolidusBacktracs
  module ExportHelper
    DATE_FORMAT = '%m/%d/%Y %H:%M'
    BACTRACS_DATE_FORMAT = '%Y-%m-%dT%H:%M:%S'

    # rubocop:disable all
    def self.address(xml, order, type)
      name = "#{type.to_s.titleize}To"
      address = order.send("#{type}_address")

      xml.__send__(name) {
        xml.Name         address.respond_to?(:name) ? address.name : address.full_name
        xml.Company      address.company

        if type == :ship
          xml.Address1   address.address1
          xml.Address2   address.address2
          xml.City       address.city
          xml.State      address.state ? address.state.abbr : address.state_name
          xml.PostalCode address.zipcode
          xml.Country    address.country.iso
        end

        xml.Phone        address.phone
      }
    end

    def self.backtracs_address(xml, order, type)
      name = "#{type.to_s.titleize}To"
      address = order.send("#{type}_address")

      xml.__send__(name) {
        xml.CompanyName   address.company ? address.company : address.name
        xml.Contact       address.name
        xml.ContactEmail  order.email
        xml.Address1      address.address1
        xml.Address2      address.address2
        xml.City          address.city
        xml.State         address.state ? address.state.abbr : address.state_name
        xml.Zip           address.zipcode
        xml.Phone         address.phone.present? ? address.phone : "000-000-0000"
        xml.PhoneAlt      address.phone.present? ? address.phone : "000-000-0000"
        xml.Country       address.country.iso
      }
    end    
    # rubocop:enable all
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solidus_backtracs-2.2.3 app/helpers/solidus_backtracs/export_helper.rb
solidus_backtracs-2.2.2 app/helpers/solidus_backtracs/export_helper.rb
solidus_backtracs-2.2.1 app/helpers/solidus_backtracs/export_helper.rb
solidus_backtracs-2.2.0 app/helpers/solidus_backtracs/export_helper.rb