mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 17:04:23 -05:00
Added logging
This commit is contained in:
@@ -92,7 +92,7 @@ class QboController < ApplicationController
|
|||||||
# Quickbooks Webhook Callback
|
# Quickbooks Webhook Callback
|
||||||
def qbo_webhook
|
def qbo_webhook
|
||||||
|
|
||||||
logger.debug "Quickbooks is calling webhook"
|
logger.info "Quickbooks is calling webhook"
|
||||||
|
|
||||||
# check the payload
|
# check the payload
|
||||||
signature = request.headers['intuit-signature']
|
signature = request.headers['intuit-signature']
|
||||||
@@ -149,14 +149,14 @@ class QboController < ApplicationController
|
|||||||
render nothing: true, status: 400
|
render nothing: true, status: 400
|
||||||
end
|
end
|
||||||
|
|
||||||
logger.debug "Quickbooks webhook complete"
|
logger.info "Quickbooks webhook complete"
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Synchronizes the QboCustomer table with QBO
|
# Synchronizes the QboCustomer table with QBO
|
||||||
#
|
#
|
||||||
def sync
|
def sync
|
||||||
logger.debug "Syncing EVERYTHING"
|
logger.info "Syncing EVERYTHING"
|
||||||
# Update info in background
|
# Update info in background
|
||||||
Thread.new do
|
Thread.new do
|
||||||
if Qbo.exists?
|
if Qbo.exists?
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class QboEstimate < ActiveRecord::Base
|
|||||||
|
|
||||||
# sync all estimates
|
# sync all estimates
|
||||||
def self.sync
|
def self.sync
|
||||||
|
logger.debug "Syncing ALL estimates"
|
||||||
estimates = get_base.all
|
estimates = get_base.all
|
||||||
estimates.each { |estimate|
|
estimates.each { |estimate|
|
||||||
process_estimate(estimate)
|
process_estimate(estimate)
|
||||||
@@ -35,6 +36,7 @@ class QboEstimate < ActiveRecord::Base
|
|||||||
|
|
||||||
# sync only one estimate
|
# sync only one estimate
|
||||||
def self.sync_by_id(id)
|
def self.sync_by_id(id)
|
||||||
|
logger.debug "Syncing estimate #{id}"
|
||||||
process_estimate(get_base.fetch_by_id(id))
|
process_estimate(get_base.fetch_by_id(id))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -49,6 +51,7 @@ class QboEstimate < ActiveRecord::Base
|
|||||||
|
|
||||||
# process an estimate into the database
|
# process an estimate into the database
|
||||||
def self.process_estimate(estimate)
|
def self.process_estimate(estimate)
|
||||||
|
logger.info "Processing estimate #{estimate.id}"
|
||||||
qbo_estimate = find_or_create_by(id: estimate.id)
|
qbo_estimate = find_or_create_by(id: estimate.id)
|
||||||
qbo_estimate.doc_number = estimate.doc_number
|
qbo_estimate.doc_number = estimate.doc_number
|
||||||
qbo_estimate.customer_id = estimate.customer_ref.value
|
qbo_estimate.customer_id = estimate.customer_ref.value
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class QboInvoice < ActiveRecord::Base
|
|||||||
|
|
||||||
# processes the invoice into the database
|
# processes the invoice into the database
|
||||||
def self.process_invoice(invoice)
|
def self.process_invoice(invoice)
|
||||||
logger.debug "Processing invoice"
|
logger.info "Processing invoice #{invoice.id}"
|
||||||
|
|
||||||
# Load the invoice into the database
|
# Load the invoice into the database
|
||||||
qbo_invoice = QboInvoice.find_or_create_by(id: invoice.id)
|
qbo_invoice = QboInvoice.find_or_create_by(id: invoice.id)
|
||||||
@@ -104,6 +104,7 @@ class QboInvoice < ActiveRecord::Base
|
|||||||
# this condions causes an infinite loop as the webhook is called when an invoice is updated
|
# this condions causes an infinite loop as the webhook is called when an invoice is updated
|
||||||
# TODO maybe add a cf_sync_confict flag to invoices
|
# TODO maybe add a cf_sync_confict flag to invoices
|
||||||
def self.compare_custom_fields(issue, invoice)
|
def self.compare_custom_fields(issue, invoice)
|
||||||
|
logger.debug "Comparing custom fields"
|
||||||
# TODO break if QboInvoice.find(invoice.id).cf_sync_confict
|
# TODO break if QboInvoice.find(invoice.id).cf_sync_confict
|
||||||
is_changed = false
|
is_changed = false
|
||||||
|
|
||||||
@@ -118,7 +119,7 @@ class QboInvoice < ActiveRecord::Base
|
|||||||
# Only update if blank to prevent infite loops
|
# Only update if blank to prevent infite loops
|
||||||
# TODO check cf_sync_confict flag once implemented
|
# TODO check cf_sync_confict flag once implemented
|
||||||
if cf.string_value.to_s.blank?
|
if cf.string_value.to_s.blank?
|
||||||
|
logger.debug " VIN was blank, updating the invoice vin in quickbooks"
|
||||||
vin = Vehicle.find(issue.vehicles_id).vin
|
vin = Vehicle.find(issue.vehicles_id).vin
|
||||||
break if vin.nil?
|
break if vin.nil?
|
||||||
if not cf.string_value.to_s.eql? vin
|
if not cf.string_value.to_s.eql? vin
|
||||||
|
|||||||
Reference in New Issue
Block a user