Created
May 13, 2009 15:36
-
-
Save jonmagic/111089 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Job Starting!" | |
$bootstrap = File.open('import_clients_from_qb.rb', 'w') | |
$bootstrap << File.read('db/utilities/suite_qb_bootstrap/bootstrap_bootstrap.rb') | |
$bootstrap << "puts \"Bootstrap Begin!\"\n" | |
class Addresser | |
def self.parse(qb_address_block) | |
return '' unless qb_address_block | |
hit_numeric = false | |
keep_lines = [] | |
qb_address_block.attributes.each do |line| | |
hit_numeric = true if line.to_s =~ /\d/ | |
keep_lines << line if hit_numeric | |
end | |
return keep_lines.join(', ') | |
end | |
end | |
# def self.import_qb(qb_id, name, firstname, lastname, company, note, email_address, phone, fax, alt_phone, bill_address, ship_address) | |
QB::Customer.each do |customer| | |
bill_address_street = customer[:BillAddress][:Addr2] | |
bill_address_city = customer[:BillAddress][:City] | |
bill_address_state = customer[:BillAddress][:State] | |
bill_address_zip = customer[:BillAddress][:PostalCode] | |
if customer[:FirstName] != nil | |
firstname = customer[:FirstName].to_s.inspect | |
else | |
if customer[:FullName].to_s.inspect.split(", ")[1] | |
firstname = customer[:FullName].to_s.inspect.split(", ")[1] | |
end | |
end | |
!firstname.blank? ? true : firstname = '""' | |
if customer[:LastName] != nil | |
lastname = customer[:LastName].to_s.inspect | |
else | |
if customer[:FullName].to_s.inspect.split(", ")[0] | |
lastname = customer[:FullName].to_s.inspect.split(", ")[0] | |
end | |
end | |
!lastname.blank? ? true : lastname = '""' | |
$bootstrap << "Client.import_qb(#{customer[:ListID].to_s.inspect}, #{customer[:CompanyName].to_s.inspect}, #{firstname}, #{lastname}, #{!customer[:CompanyName].blank?}, #{customer[:Notes].to_s.inspect}, #{customer[:Email].to_s.inspect}, #{customer[:Phone].to_s.inspect}, #{customer[:Fax].to_s.inspect}, #{customer[:AltPhone].to_s.inspect}, #{bill_address_street.to_s.inspect}, #{bill_address_city.to_s.inspect}, #{bill_address_state.to_s.inspect}, #{bill_address_zip.to_s.inspect}) rescue Client.rescue!(#{customer[:FullName].to_s.inspect})\n" | |
end | |
Quickbooks.connection.close | |
$bootstrap << "puts \"Bootstrap End!\"" | |
$bootstrap.close | |
puts "Job Completed!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment