mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 01:14:23 -05:00
Update qbo_invoice.rb
Added a block to find_or_create_by to succinctly update doc_number
This commit is contained in:
@@ -22,9 +22,9 @@ class QboInvoice < ActiveRecord::Base
|
|||||||
invoices = get_base.service.all
|
invoices = get_base.service.all
|
||||||
# Update the invoice table
|
# Update the invoice table
|
||||||
invoices.each { | invoice |
|
invoices.each { | invoice |
|
||||||
qbo_invoice = find_or_create_by(id: invoice.id)
|
find_or_create_by(id: invoice.id) do |i|
|
||||||
qbo_invoice.doc_number = invoice.doc_number
|
i.doc_number
|
||||||
qbo_invoice.save!
|
end
|
||||||
}
|
}
|
||||||
#remove deleted invoices
|
#remove deleted invoices
|
||||||
where.not(invoices.map(&:id)).destroy_all
|
where.not(invoices.map(&:id)).destroy_all
|
||||||
|
|||||||
Reference in New Issue
Block a user