Updated comments

This commit is contained in:
2026-03-12 17:53:06 -04:00
parent 40f7a3335c
commit beb4a66a93

View File

@@ -55,7 +55,7 @@ class QboBaseModel < ActiveRecord::Base
end end
end end
# Repsonds to missing methods by delegating to the QBO customer details object if the method is defined there. # Repsonds to missing methods by delegating to the QBO entity calss if the method is defined there.
# This allows for dynamic access to any attributes or methods of the QBO customer without having to explicitly define them in the Subclass model, providing flexibility and reducing boilerplate code. # This allows for dynamic access to any attributes or methods of the QBO customer without having to explicitly define them in the Subclass model, providing flexibility and reducing boilerplate code.
def respond_to_missing?(method_name, include_private = false) def respond_to_missing?(method_name, include_private = false)
qbo_model_class.method_defined?(method_name) || super qbo_model_class.method_defined?(method_name) || super
@@ -73,12 +73,15 @@ class QboBaseModel < ActiveRecord::Base
job.perform_later(id: id) job.perform_later(id: id)
end end
# Flag used to update local without pushing to QBO.
# This is used to prevent loops with the webhook
def skip_qbo_push? def skip_qbo_push?
!!skip_qbo_push !!skip_qbo_push
end end
private private
# Log messages with a standarized prefix
def log(msg) def log(msg)
Rails.logger.info "[#{model_name.name}] #{msg}" Rails.logger.info "[#{model_name.name}] #{msg}"
end end
@@ -90,6 +93,7 @@ class QboBaseModel < ActiveRecord::Base
service_class.new(qbo: qbo, local: self).pull() service_class.new(qbo: qbo, local: self).pull()
end end
# Pushs the entity's details from QuickBooks Online.
def push_to_qbo def push_to_qbo
log "Starting push for #{model_name.name} ##{id}..." log "Starting push for #{model_name.name} ##{id}..."
qbo = QboConnectionService.current! qbo = QboConnectionService.current!
@@ -98,10 +102,12 @@ class QboBaseModel < ActiveRecord::Base
return reslut return reslut
end end
# Dynamically get the Quickbooks Model Class
def qbo_model_class def qbo_model_class
@qbo_model_class ||= "Quickbooks::Model::#{model_name.name}".constantize @qbo_model_class ||= "Quickbooks::Model::#{model_name.name}".constantize
end end
# Dynamically get the Service Class
def service_class def service_class
@service_class ||= "#{model_name.name}Service".constantize @service_class ||= "#{model_name.name}Service".constantize
end end