effective_qb_online 0.2.0 → 0.3.0
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: f761163092d4217a1ba74cbc4903332f914c4ebb87f8cb5400d0801062aec74f
|
4
|
+
data.tar.gz: '0529a8121cd5ad7fdd16349c7643539f47d09c8420da35312575558d9ca93fd6'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08195220d727d8b4229a00a54d5b331b825836e4a45aebe1a921ad5b0e31a0d2e8e9628b6310fd896d6c737013f97b9fa7b1db333032a1146f0946c27244d1bd'
|
7
|
+
data.tar.gz: 2f950c7623f4f195b4615fc85b393d720b5c92c3e5a63d8332057df2b7cff76c0cb38ee74c6361cb60f0564aa9ad6dcbb3800a373a52f9ffa47e26b0d47ad274
|
@@ -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.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.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: 2022-
|
11
|
+
date: 2022-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|