effective_qb_online 0.8.4 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4a6e26114f3805b82bdbcbc34318059adb74df98bb512ae0615e007afbd51ea
4
- data.tar.gz: f53a3c1ce92f2c00173b9c6f546f73c857aee00727804cd58e92dcfef51b6f2f
3
+ metadata.gz: 53c398fd9e21d6dcb8c277ad502a76da91dabc6df2ee6b0a38c1322b3403e507
4
+ data.tar.gz: 50db2f4854ca87c45e1f035285345b0888fe0257e6fdee1ef8d3bd245262bf4a
5
5
  SHA512:
6
- metadata.gz: 87d0bebfa848203a06341107077234f66d1c3a54aa749c210c270770af4d42d2e66b258c181dc33cc142e3441e6fab7aab32c938317266f16f1725f8f95d84ee
7
- data.tar.gz: 6470e477febff32df0df7a648df3521f6ea65f1433f244f99ce095a56c1f76f1e1d68ed58b2abd32ad8a3a00f98980cdeb8c459bf751359b1f50a307c111758f
6
+ metadata.gz: dd41e817c114d6604feaa1428b76e912b0ce314fc464dbd6fd696a45f70a256f29cfcbbf2fb0bec6c4df070c74e2eb0dbd599f20a6f0bf8b6aafc8ae3a6909b7
7
+ data.tar.gz: cb2aea9a98f24849cfad8e0b8f91c080ac4947fbbe351690571809ef005963ee01c826016cedb270647b27df8d402b8b0b8d8cd8f9c4ecc9e2cb038a49c8f7af
@@ -3,7 +3,6 @@ module Admin
3
3
  datatable do
4
4
  order :updated_at
5
5
 
6
- col :updated_at, visible: false
7
6
  col :created_at, visible: false
8
7
  col :id, visible: false
9
8
 
@@ -9,10 +9,12 @@ module Effective
9
9
  @order = resource.order
10
10
 
11
11
  to = EffectiveOrders.qb_online_sync_error_recipients.presence || EffectiveOrders.mailer_admin
12
+ cc = EffectiveQbOnline.sync_error_cc_recipients.presence
13
+
12
14
  subject = subject_for(__method__, "Quickbooks Sync Error - Order ##{@order.to_param}", resource, opts)
13
15
  headers = headers_for(resource, opts)
14
16
 
15
- mail(to: to, subject: subject, **headers)
17
+ mail(to: to, cc: cc, subject: subject, **headers)
16
18
  end
17
19
 
18
20
  end
@@ -36,7 +36,7 @@ module Effective
36
36
  line3: address.try(:address3),
37
37
  city: address.city,
38
38
  country: address.country,
39
- country_sub_division_code: address.country_code,
39
+ country_sub_division_code: address.state_code,
40
40
  postal_code: address.postal_code
41
41
  )
42
42
  end
@@ -185,7 +185,7 @@ module Effective
185
185
  [rate.rate_value.to_s, code] if rate && (exempt.blank? || rate.rate_value.to_f > 0.0)
186
186
  end
187
187
 
188
- (Array(exempt) + tax_codes.uniq { |key, _| key }.compact).to_h
188
+ (Array(exempt) + tax_codes.compact.uniq { |key, _| key }).to_h
189
189
  end
190
190
 
191
191
  def with_service(name, &block)
@@ -67,12 +67,18 @@ module Effective
67
67
  sales_receipt = api.create_sales_receipt(sales_receipt: sales_receipt)
68
68
 
69
69
  # Sanity check
70
- if EffectiveOrders.try(:credit_card_surcharge_qb_item_name).present?
70
+ if EffectiveOrders.try(:credit_card_surcharge_qb_item_name).present? && !EffectiveOrders.try(:fee_saver?)
71
71
  if (expected = api.price_to_amount(order.total)) != sales_receipt.total
72
72
  raise("A QuickBooks Online Sales Receipt has been created with an unexpected total. QuickBooks total is #{sales_receipt.total} but we expected #{expected}. Please adjust the Sales Receipt on QuickBooks")
73
73
  end
74
74
  end
75
75
 
76
+ if EffectiveOrders.try(:credit_card_surcharge_qb_item_name).present? && EffectiveOrders.try(:fee_saver?)
77
+ if (expected = api.price_to_amount(order.amount_owing) - order.surcharge.to_i) != sales_receipt.total
78
+ raise("A QuickBooks Online Sales Receipt has been created with an unexpected total. QuickBooks total is #{sales_receipt.total} but we expected #{expected}. Please adjust the Sales Receipt on QuickBooks")
79
+ end
80
+ end
81
+
76
82
  if EffectiveOrders.try(:credit_card_surcharge_qb_item_name).blank?
77
83
  if (expected = api.price_to_amount(order.amount_owing)) != sales_receipt.total
78
84
  raise("A QuickBooks Online Sales Receipt has been created with an unexpected total. QuickBooks total is #{sales_receipt.total} but we expected #{expected}. Please adjust the Sales Receipt on QuickBooks")
@@ -114,7 +114,7 @@ module Effective
114
114
  end
115
115
 
116
116
  # Add Credit Card Surcharge if we collect it ourselves. This does not add a Helcim Convenience Fee
117
- if EffectiveOrders.try(:credit_card_surcharge_qb_item_name).present? && order.try(:surcharge).to_i != 0
117
+ if !EffectiveOrders.try(:fee_saver?) && EffectiveOrders.try(:credit_card_surcharge_qb_item_name).present? && order.try(:surcharge).to_i != 0
118
118
  raise("Expected a Credit Card Surcharge QuickBooks item to exist for Effective::Order #{order.id} with non-zero surcharge amount. Please check your configuration.") unless surcharge_item.present?
119
119
 
120
120
  line_item = Quickbooks::Model::Line.new(amount: api.price_to_amount(order.surcharge), description: 'Credit Card Surcharge')
@@ -130,6 +130,26 @@ module Effective
130
130
  sales_receipt.line_items << line_item
131
131
  end
132
132
 
133
+ # Add negative Convenience Fee line item when Helcim fee saver is enabled
134
+ # The payment processor adds the convenience fee, so we record a negative amount to offset it in QuickBooks
135
+ if EffectiveOrders.try(:fee_saver?) && EffectiveOrders.try(:credit_card_surcharge_qb_item_name).present? && order.try(:surcharge).to_i != 0
136
+ raise("Expected a Credit Card Surcharge QuickBooks item to exist for Effective::Order #{order.id} with non-zero surcharge amount. Please check your configuration.") unless surcharge_item.present?
137
+
138
+ amount = api.price_to_amount(order.surcharge * -1)
139
+
140
+ line_item = Quickbooks::Model::Line.new(amount: amount, description: 'Helcim Convenience Fee')
141
+
142
+ line_item.sales_item! do |line|
143
+ line.item_id = surcharge_item.id
144
+ line.tax_code_id = tax_exempt.id # Convenience fee is not taxed
145
+
146
+ line.unit_price = amount
147
+ line.quantity = 1
148
+ end
149
+
150
+ sales_receipt.line_items << line_item
151
+ end
152
+
133
153
  # Double check
134
154
  raise("Invalid SalesReceipt generated for Effective::Order #{order.id}") unless sales_receipt.valid?
135
155
 
@@ -137,8 +157,6 @@ module Effective
137
157
  sales_receipt
138
158
  end
139
159
 
140
- private
141
-
142
160
  def self.scrub(value)
143
161
  value.to_s.downcase.strip
144
162
  end
@@ -12,6 +12,12 @@ EffectiveQbOnline.setup do |config|
12
12
  # https://github.com/ruckus/quickbooks-ruby
13
13
  Quickbooks.sandbox_mode = (ENV['QUICKBOOKS_ONLINE_SANDBOX'].to_s == 'true')
14
14
 
15
+ # Sync Error Email
16
+ # When a sync error occurs, an email is sent to the following addresses:
17
+ # EffectiveOrders.qb_online_sync_error_recipients or EffectiveOrders.mailer_admin
18
+ # You can also specify a list of additional recipients to be cc'd on the email by setting:
19
+ # config.sync_error_cc_recipients = ['"Errors" <errors@example.com>']
20
+
15
21
  # Mailer Settings
16
22
  # Please see config/initializers/effective_resources.rb for default effective_* gem mailer settings
17
23
  #
@@ -1,3 +1,3 @@
1
1
  module EffectiveQbOnline
2
- VERSION = '0.8.4'.freeze
2
+ VERSION = '0.9.0'.freeze
3
3
  end
@@ -10,7 +10,7 @@ module EffectiveQbOnline
10
10
  :qb_realms_table_name, :qb_receipts_table_name, :qb_receipt_items_table_name,
11
11
  :mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :mailer_subject,
12
12
  :oauth_client_id, :oauth_client_secret,
13
- :layout
13
+ :layout, :sync_error_cc_recipients
14
14
  ]
15
15
  end
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_qb_online
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-09 00:00:00.000000000 Z
11
+ date: 2026-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails