Class: QuickbooksCustomerByCompanyResolver
- Inherits:
-
Object
- Object
- QuickbooksCustomerByCompanyResolver
- Includes:
- QuickbooksCustomerHelper
- Defined in:
- app/resolver/quickbooks_customer_by_company_resolver.rb
Overview
QuickbooksCustomerByCompanyResolver handles the creation, updating, and integration of QuickBooks customer data with the application’s CustomerByCompany records. This resolver processes customer data from QuickBooks API and maintains company-specific customer settings and relationships.
The resolver handles three primary scenarios:
-
Finding and updating existing integrated CustomerByCompany records
-
Finding matching non-integrated CustomerByCompany records and integrating them
-
Creating new CustomerByCompany records when no match is found
CustomerByCompany records store company-specific settings for customers, such as payment terms, currency preferences, and active status.
Defined Under Namespace
Classes: Actions
Constant Summary collapse
- USER_NAME =
'SYSTEM'
Instance Attribute Summary collapse
-
#company_id ⇒ Object
readonly
Returns the value of attribute company_id.
-
#customer_id ⇒ Object
readonly
Returns the value of attribute customer_id.
-
#quickbooks_customer ⇒ Object
readonly
Returns the value of attribute quickbooks_customer.
Instance Method Summary collapse
-
#initialize(company_id:, customer_id:, quickbooks_customer:) ⇒ QuickbooksCustomerByCompanyResolver
constructor
Initializes a new QuickbooksCustomerByCompanyResolver.
-
#resolve ⇒ Hash
Processes the QuickBooks customer data and performs the necessary actions to integrate it with the application’s CustomerByCompany data model.
Methods included from QuickbooksCustomerHelper
#check_and_create_member_customer, #check_and_set_customer_hierarchy, #external_reference_code, #extract_shipping_address_from_quickbooks_customer, #find_currency_id, #find_payment_term_id, #find_type, #format_known_as, #formatted_code
Methods included from CustomerHierarchyManagement
#assign_customer_hierarchy, #billing_shipping_addresses_match?, #create_dc_customer_for_shipping_address, #create_member_customer_for_shipping_address, #determine_hierarchy_attributes, #find_customer_with_same_address, #shipping_address_valid?
Methods included from AddressHelper
#canadian_postal_code?, #clean_city, #normalize_postal_code, #parse_address_line, #parse_address_parts, #us_zip_code?, #valid_city?, #valid_state?
Constructor Details
#initialize(company_id:, customer_id:, quickbooks_customer:) ⇒ QuickbooksCustomerByCompanyResolver
Initializes a new QuickbooksCustomerByCompanyResolver
44 45 46 47 48 |
# File 'app/resolver/quickbooks_customer_by_company_resolver.rb', line 44 def initialize(company_id:, customer_id:, quickbooks_customer:) @company_id = company_id @customer_id = customer_id @quickbooks_customer = quickbooks_customer.with_indifferent_access end |
Instance Attribute Details
#company_id ⇒ Object (readonly)
Returns the value of attribute company_id.
36 37 38 |
# File 'app/resolver/quickbooks_customer_by_company_resolver.rb', line 36 def company_id @company_id end |
#customer_id ⇒ Object (readonly)
Returns the value of attribute customer_id.
36 37 38 |
# File 'app/resolver/quickbooks_customer_by_company_resolver.rb', line 36 def customer_id @customer_id end |
#quickbooks_customer ⇒ Object (readonly)
Returns the value of attribute quickbooks_customer.
36 37 38 |
# File 'app/resolver/quickbooks_customer_by_company_resolver.rb', line 36 def quickbooks_customer @quickbooks_customer end |
Instance Method Details
#resolve ⇒ Hash
Processes the QuickBooks customer data and performs the necessary actions to integrate it with the application’s CustomerByCompany data model
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/resolver/quickbooks_customer_by_company_resolver.rb', line 55 def resolve ActiveRecord::Base.transaction do if find_integrated_customer_by_company update_customer_by_company { action: Actions::UPDATE, customer_by_company: @customer_by_company } elsif find_customer_by_company_to_integrate integrate_customer_by_company update_customer_by_company { action: Actions::INTEGRATE, customer_by_company: @customer_by_company } elsif create_customer_by_company integrate_customer_by_company { action: Actions::CREATE, customer_by_company: @customer_by_company } end end rescue StandardError => e Rails.logger.error "QuickBooks CustomerByCompany resolve failed: #{e.}" raise e end |