mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 09:24:23 -05:00
Update qbo_invoice.rb
Loose the loop!
This commit is contained in:
@@ -19,13 +19,14 @@ class QboInvoice < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.update_all
|
def self.update_all
|
||||||
|
#Pull the invoices from the quickbooks server
|
||||||
invoices = get_base.service.all
|
invoices = get_base.service.all
|
||||||
|
ids = invoices.map {|i| i.id}
|
||||||
|
doc_numbers = invoices.map {|i| i.doc_number}
|
||||||
|
|
||||||
# Update the invoice table
|
# Update the invoice table
|
||||||
invoices.each { | invoice |
|
find_or_create_by(id: ids, doc_number: doc_numbers)
|
||||||
find_or_create_by(id: invoice.id) do |i|
|
|
||||||
i.doc_number
|
|
||||||
end
|
|
||||||
}
|
|
||||||
#remove deleted invoices
|
#remove deleted invoices
|
||||||
where.not(invoices.map(&:id)).destroy_all
|
where.not(invoices.map(&:id)).destroy_all
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user