solidus-returnly 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -14
- data/app/controllers/spree/api/returnly/refunds_controller.rb +1 -0
- data/app/models/reimbursement_type/original_payment_no_items.rb +17 -0
- data/lib/returnly/refund_presenter.rb +2 -2
- data/lib/returnly/refunder.rb +16 -0
- data/lib/returnly/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '083e914f59852fdd042dcb656a7586374fe4f780'
|
4
|
+
data.tar.gz: e99474dab16979ca9aa30dce9a1fa814dd1002c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93c7c301d731ad1a45c41caefb37cd42d343af2413ec8466ad2b580b8c81c6d7fe45d7391cb7b182f7a5dc484384003d73ca5de182dc447af9ed37e317e44392
|
7
|
+
data.tar.gz: b650b812d349d35541d116fed203d3400da769610e716a2c91286d9da516a09ddd676578c830dfd09a205ceae93509b3ee161af3e90b2d46d097b0a952a45ef6
|
data/README.md
CHANGED
@@ -164,23 +164,23 @@ Overriding Refund Logic
|
|
164
164
|
|
165
165
|
Is possible to override the default behavior of the Refund Gem by extending the following classes
|
166
166
|
|
167
|
-
`lib/
|
167
|
+
`lib/returnly/refund/return_item_restock_policy.rb`
|
168
168
|
|
169
169
|
```ruby
|
170
170
|
class CustomReturnItemRestockPolicy < ReturnItemRestockPolicy
|
171
|
-
|
172
|
-
|
173
|
-
|
171
|
+
def should_return_item?(return_item)
|
172
|
+
return_item.cost > 1
|
173
|
+
end
|
174
174
|
end
|
175
175
|
```
|
176
176
|
|
177
|
-
`lib/
|
177
|
+
`lib/returnly/refund/amount_calculator.rb`
|
178
178
|
|
179
179
|
```ruby
|
180
180
|
class CustomAmountCalculator < AmountCalculator
|
181
|
-
|
182
|
-
|
183
|
-
|
181
|
+
def return_item_refund_amount(return_item)
|
182
|
+
default_amount(return_item) - 5.0
|
183
|
+
end
|
184
184
|
end
|
185
185
|
```
|
186
186
|
|
@@ -188,12 +188,13 @@ to set your custom classes to the returns process just
|
|
188
188
|
add an initializer file: `cofnig/initializers/returnly.rb`
|
189
189
|
|
190
190
|
```ruby
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
191
|
+
Returnly.configure do |config|
|
192
|
+
config.return_item_amount_calculator = CustomAmountCalculator
|
193
|
+
config.return_item_restock_policy = CustomReturnItemRestockPolicy
|
194
|
+
config.refunder = CustomRefunder
|
195
|
+
config.refund_calculator = CustomRefunderCalculator
|
196
|
+
config.reimbursement_type_no_items = CustomOriginalPaymentNoItems
|
197
|
+
end
|
197
198
|
```
|
198
199
|
|
199
200
|
Copyright (c) 2017 Returnly Technologies, Inc
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ReimbursementType
|
2
|
+
class OriginalPaymentNoItems < Spree::ReimbursementType
|
3
|
+
extend Spree::ReimbursementType::ReimbursementHelpers
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def reimburse(reimbursement, _return_items, simulate)
|
7
|
+
unpaid_amount = reimbursement.total.round(2, :down)
|
8
|
+
payments = reimbursement.order.payments.completed
|
9
|
+
|
10
|
+
refund_list, _unpaid_amount = create_refunds(reimbursement, payments, unpaid_amount, simulate)
|
11
|
+
reimbursement.update(total: refund_list.sum(&:amount))
|
12
|
+
refund_list
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -19,7 +19,7 @@ module Returnly
|
|
19
19
|
total_refund_amount: total_refund_amount.to_f,
|
20
20
|
refundable_shipping_amount: calculator.order.shipment_total.to_f,
|
21
21
|
refundable_shipping_tax_amount: shipping_tax.to_f,
|
22
|
-
max_refundable_amount: calculator.order.total.to_f,
|
22
|
+
max_refundable_amount: (calculator.order.total - calculator.order.refunds.sum(&:amount)).to_f,
|
23
23
|
refunds_by_payment_method: refunds_by_payment(calculator.order, total_refund_amount.to_d + calculator.order.shipment_total + shipping_tax)
|
24
24
|
}
|
25
25
|
end
|
@@ -50,7 +50,7 @@ module Returnly
|
|
50
50
|
customer_return = refunder.customer_return
|
51
51
|
|
52
52
|
{
|
53
|
-
refund_id:
|
53
|
+
refund_id: refunder.order.refunds.last.try(:id),
|
54
54
|
line_items: customer_return.return_items.group_by { |ri| ri.inventory_unit.line_item.id }.map do |_, return_items|
|
55
55
|
first_return_item = return_items.first
|
56
56
|
{
|
data/lib/returnly/refunder.rb
CHANGED
@@ -29,6 +29,7 @@ module Returnly
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def proceed!
|
32
|
+
return proceed_without_line_items if line_items.empty?
|
32
33
|
process_return_items
|
33
34
|
|
34
35
|
if customer_return.save!
|
@@ -57,11 +58,26 @@ module Returnly
|
|
57
58
|
self.refund_calculator = refund_calculator_class.new(order, line_items)
|
58
59
|
end
|
59
60
|
|
61
|
+
def proceed_without_line_items
|
62
|
+
reimburse_without_items!
|
63
|
+
RefundPresenter.present_refund(self)
|
64
|
+
end
|
65
|
+
|
60
66
|
def perform_reimbursement
|
61
67
|
reimbursement.save!
|
62
68
|
reimbursement.perform!
|
63
69
|
end
|
64
70
|
|
71
|
+
def reimburse_without_items!
|
72
|
+
reimbursement_total = product_refund_amount.to_d + shipping_refund_amount.to_d
|
73
|
+
@_reimbursement = Spree::Reimbursement.new(
|
74
|
+
order: order,
|
75
|
+
total: reimbursement_total.round(2, :down)
|
76
|
+
)
|
77
|
+
reimbursement.save!
|
78
|
+
::ReimbursementType::OriginalPaymentNoItems.reimburse(reimbursement, nil, false)
|
79
|
+
end
|
80
|
+
|
65
81
|
def each_return_item
|
66
82
|
customer_return.return_items = refund_calculator.line_items_return_items.values.flatten
|
67
83
|
customer_return.return_items.each do |return_item|
|
data/lib/returnly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus-returnly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Returnly Technologies, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus
|
@@ -330,6 +330,7 @@ files:
|
|
330
330
|
- app/controllers/spree/api/returnly/api_controller.rb
|
331
331
|
- app/controllers/spree/api/returnly/refunds_controller.rb
|
332
332
|
- app/controllers/spree/api/returnly/version_controller.rb
|
333
|
+
- app/models/reimbursement_type/original_payment_no_items.rb
|
333
334
|
- app/models/spree/return_item_decorator.rb
|
334
335
|
- config/locales/en.yml
|
335
336
|
- config/routes.rb
|