Added is_changed to stop endless update loop with webhook

This commit is contained in:
2016-08-12 19:25:03 -04:00
committed by GitHub
parent 245d2b49a2
commit 4cb588e992

View File

@@ -61,6 +61,8 @@ class QboInvoice < ActiveRecord::Base
i.qbo_invoice = QboInvoice.find_by_id(invoice.id.to_i) i.qbo_invoice = QboInvoice.find_by_id(invoice.id.to_i)
i.save! i.save!
is_changed = false
# Update QBO with Milage & VIN # Update QBO with Milage & VIN
invoice.custom_fields.each { |cf| invoice.custom_fields.each { |cf|
# VIN # VIN
@@ -72,14 +74,17 @@ class QboInvoice < ActiveRecord::Base
# Update Matching Fields # Update Matching Fields
i.custom_field_values.each { |value| i.custom_field_values.each { |value|
if cf.name.eql? CustomField.find_by_id(value.custom_field_id).name if cf.name.eql? CustomField.find_by_id(value.custom_field_id).name
if not cf.string_value.to_s.eql? value.value.to_s
cf.string_value = value.value.to_s cf.string_value = value.value.to_s
is_changed = true
end
break break
end end
} }
} }
} }
# Push updates # Push updates
Qbo.get_base(:invoice).service.update(invoice) Qbo.get_base(:invoice).service.update(invoice) if is_changed
end end
} }
end end