Added logging

This commit is contained in:
2022-02-21 08:51:01 -05:00
parent 9dfb27f0a4
commit 19acfbc76f
3 changed files with 10 additions and 6 deletions

View File

@@ -92,7 +92,7 @@ class QboController < ApplicationController
# Quickbooks Webhook Callback
def qbo_webhook
logger.debug "Quickbooks is calling webhook"
logger.info "Quickbooks is calling webhook"
# check the payload
signature = request.headers['intuit-signature']
@@ -149,14 +149,14 @@ class QboController < ApplicationController
render nothing: true, status: 400
end
logger.debug "Quickbooks webhook complete"
logger.info "Quickbooks webhook complete"
end
#
# Synchronizes the QboCustomer table with QBO
#
def sync
logger.debug "Syncing EVERYTHING"
logger.info "Syncing EVERYTHING"
# Update info in background
Thread.new do
if Qbo.exists?

View File

@@ -23,7 +23,8 @@ class QboEstimate < ActiveRecord::Base
end
# sync all estimates
def self.sync
def self.sync
logger.debug "Syncing ALL estimates"
estimates = get_base.all
estimates.each { |estimate|
process_estimate(estimate)
@@ -35,6 +36,7 @@ class QboEstimate < ActiveRecord::Base
# sync only one estimate
def self.sync_by_id(id)
logger.debug "Syncing estimate #{id}"
process_estimate(get_base.fetch_by_id(id))
end
@@ -49,6 +51,7 @@ class QboEstimate < ActiveRecord::Base
# process an estimate into the database
def self.process_estimate(estimate)
logger.info "Processing estimate #{estimate.id}"
qbo_estimate = find_or_create_by(id: estimate.id)
qbo_estimate.doc_number = estimate.doc_number
qbo_estimate.customer_id = estimate.customer_ref.value

View File

@@ -71,7 +71,7 @@ class QboInvoice < ActiveRecord::Base
# processes the invoice into the database
def self.process_invoice(invoice)
logger.debug "Processing invoice"
logger.info "Processing invoice #{invoice.id}"
# Load the invoice into the database
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
# TODO maybe add a cf_sync_confict flag to invoices
def self.compare_custom_fields(issue, invoice)
logger.debug "Comparing custom fields"
# TODO break if QboInvoice.find(invoice.id).cf_sync_confict
is_changed = false
@@ -118,7 +119,7 @@ class QboInvoice < ActiveRecord::Base
# Only update if blank to prevent infite loops
# TODO check cf_sync_confict flag once implemented
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
break if vin.nil?
if not cf.string_value.to_s.eql? vin