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 +4 -4
- data/app/models/effective/qb_sales_receipt.rb +30 -0
- data/lib/effective_qb_online/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 708e4ea3c01bb95426e9510b340fbc6502a95641fa632a410a23c9cf055b5eb0
|
4
|
+
data.tar.gz: c2c281898e1dd857b878f04a3b0e91c714984cb48a34a3c999e2bd5cdd8d3fad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
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.
|
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-
|
11
|
+
date: 2022-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|