effective_qb_online 0.2.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20091c462c42fe7c361cc24f430c7ac8050b5fd101db4d18b0dd96730b1d7e8f
4
- data.tar.gz: 86db22b8febd131c30659676ad3a39edb1d6ee8c3cf84fda9055d12c1fab6658
3
+ metadata.gz: 708e4ea3c01bb95426e9510b340fbc6502a95641fa632a410a23c9cf055b5eb0
4
+ data.tar.gz: c2c281898e1dd857b878f04a3b0e91c714984cb48a34a3c999e2bd5cdd8d3fad
5
5
  SHA512:
6
- metadata.gz: fda907556a72911aedbfa905ea2faef422f6ef4f7a78e0591353f655ffc3b0f3b66a3fc024381f2de0a143315f32f80c567c63bba47b5453471731d733f97708
7
- data.tar.gz: b37c30a31998a33d7f4fc5e50256f2c09b4833a541384717473edf90b11bd692c8a7082ec000acf3e184e22c872346fad7b9f85509c023d20e9d452cc8378429
6
+ metadata.gz: c4c1e3b37d577e13e520c82851992d5830b526d00265c48533cfe3f31e08209666206621b12eed0ceae5b2fbb0d7c2d3224bc8b5503977ac908ae8051f6f5945
7
+ data.tar.gz: e649a27a72668157f8b7298f70ed6729ccd42007b4e13ccaebea40c2a4a3d172ce2f31158cdb371aa7bc236b51160777837dc8e72ad5f19b95faf444f13ebb61
@@ -25,6 +25,19 @@ module Effective
25
25
  # Find and validate items
26
26
  items = api.items()
27
27
 
28
+ # Credit card surcharge item
29
+ surcharge_item = if EffectiveOrders.try(:credit_card_surcharge_qb_item_name).present?
30
+ name = EffectiveOrders.credit_card_surcharge_qb_item_name
31
+
32
+ item = items.find do |item|
33
+ [scrub(item.id), scrub(item.name), scrub(item.fully_qualified_name)].include?(scrub(name))
34
+ end
35
+
36
+ raise("Missing Credit Card Surcharge item #{name}. Please add this to your Quickbooks items.") unless item.present?
37
+
38
+ item
39
+ end
40
+
28
41
  receipt.qb_receipt_items.each do |receipt_item|
29
42
  purchasable = receipt_item.order_item.purchasable
30
43
  raise("Expected a purchasable for Effective::OrderItem #{receipt_item.order_item.id}") unless purchasable.present?
@@ -98,6 +111,23 @@ module Effective
98
111
  sales_receipt.line_items << line_item
99
112
  end
100
113
 
114
+ # Add Credit Card Surcharge
115
+ if order.try(:surcharge).to_i != 0
116
+ 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?
117
+
118
+ line_item = Quickbooks::Model::Line.new(amount: api.price_to_amount(order.surcharge), description: 'Credit Card Surcharge')
119
+
120
+ line_item.sales_item! do |line|
121
+ line.item_id = surcharge_item.id
122
+ line.tax_code_id = tax_code.id # Surcharge is taxed at same rate as items
123
+
124
+ line.unit_price = api.price_to_amount(order.surcharge)
125
+ line.quantity = 1
126
+ end
127
+
128
+ sales_receipt.line_items << line_item
129
+ end
130
+
101
131
  # Double check
102
132
  raise("Invalid SalesReceipt generated for Effective::Order #{order.id}") unless sales_receipt.valid?
103
133
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveQbOnline
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.1'.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.2.0
4
+ version: 0.3.1
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: 2022-06-06 00:00:00.000000000 Z
11
+ date: 2022-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails