Last active
January 9, 2016 15:50
-
-
Save phildionne/9feea07cbd07aa05b907 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
@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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using this API client: https://github.com/ruckus/quickbooks-ruby