effective_qb_online 0.8.5 → 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: 00ddf30ebad25aed4701012dc46d99f3b058b0923667d92f2133e388f37d91f9
4
- data.tar.gz: 1e1f8ee36db0242718778a44380dcb96f39dd388d74b77aec23288ef0423c876
3
+ metadata.gz: 53c398fd9e21d6dcb8c277ad502a76da91dabc6df2ee6b0a38c1322b3403e507
4
+ data.tar.gz: 50db2f4854ca87c45e1f035285345b0888fe0257e6fdee1ef8d3bd245262bf4a
5
5
  SHA512:
6
- metadata.gz: d152cbc83ed643d51f03d01a43deb684cb0fecc07ce9519a3ceb7254868986b9ccef55fd6aaf389092d7256b83718edb613a252abe013c3c39dd59e560e09291
7
- data.tar.gz: 28b6f1227299d67063c0d5a1a28fbf4345a7e017378e17dd49c7f04287224c9504e2f2b4f4a3d6526dd92b7e6f6970367b5b056008f8ba51790ac0705e6648a7
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
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module EffectiveQbOnline
2
- VERSION = '0.8.5'.freeze
2
+ VERSION = '0.9.0'.freeze
3
3
  end
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.5
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-10 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