Skip to content

Instantly share code, notes, and snippets.

@phildionne
Last active January 9, 2016 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phildionne/9feea07cbd07aa05b907 to your computer and use it in GitHub Desktop.
Save phildionne/9feea07cbd07aa05b907 to your computer and use it in GitHub Desktop.
@client.query_in_batches("SELECT * FROM Invoice", per_page: 1000) do |records|
records.entries.each do |record|
# Record has an active class
if record.class_ref.present? && !record.class_ref.name.match(/supprimé/)
reference = record.class_ref
# Find project & organisation
project = Project.find_by!(quickbooks_class_id: reference.value)
organisation = project.organisation
# Update record line
record.customer_ref = Quickbooks::Model::BaseReference.new(project.quickbooks_id)
record.class_ref = nil
# Partially update record
@client.update(record, sparse: true)
end
end
end
@phildionne
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment