solidus-returnly 0.7.1 → 0.8.0

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
  SHA1:
3
- metadata.gz: 75f8eee45930bec292d27a3b6fb876f21361b0df
4
- data.tar.gz: 425e7dbb0fed050f6762c4b5c766d7e77ac89bbc
3
+ metadata.gz: bb8d06cd851a7ea78575686899bba9bacc2b341c
4
+ data.tar.gz: 6b1f367725053816fa4bee8b03fb385cc118a1b4
5
5
  SHA512:
6
- metadata.gz: 90d55e4b55a56af2737040bc1c9826fe9ab80269a724a48dd43f133a33152bc7056b101180461959735ec1f9ff12efb8205075b269c1392625569f3c35144b37
7
- data.tar.gz: ceeb5f3e0c0f472a213b3e736ed92e86d1b44dc35c56fb475a1e26c99cd87138b3c2d3caebf6a5d71e4db5ae3010d15067fb9ea49d177237236e3b1eb3721c84
6
+ metadata.gz: e9f4a0a0feafea3e45a61bc6d894b26233f9f2c7ccfabe7a624988664605dee31b9b81243a605e65ce5518cd8d9de88abe432dfbd18ef59f327e53cf11e5a017
7
+ data.tar.gz: 1e6eb5e42d0d8f5e5c3513590a89574a40f9e8f258b4415b7e93532cf993869219cd8a2084d479293102ea21a3bcb2367f12899465587b5ff3a3a65dc3add577
@@ -71,6 +71,21 @@ module Returnly
71
71
  }
72
72
  end
73
73
 
74
+ def self.present_refund_with_zero_amount(refunder)
75
+ {
76
+ refund_id: '',
77
+ line_items: refunder.line_items.map do |line_item|
78
+ {
79
+ refund_line_item_id: '',
80
+ order_line_item_id: line_item[:order_line_item_id].to_s,
81
+ units: line_item[:units].to_i,
82
+ restock: !!(line_item[:restock].to_s =~ /true/)
83
+ }
84
+ end,
85
+ transactions: []
86
+ }
87
+ end
88
+
74
89
  private_class_method def self.refunds_by_payment(order, payment_amount)
75
90
  ::RefundPayments.new(order).perform!(payment_amount)
76
91
  end
@@ -31,6 +31,7 @@ module Returnly
31
31
 
32
32
  def proceed!
33
33
  return proceed_without_line_items if line_items.empty?
34
+ return proceed_with_product_zero_amount if product_refund_amount.to_d.zero?
34
35
  process_return_items
35
36
 
36
37
  if customer_return.save!
@@ -73,6 +74,11 @@ module Returnly
73
74
  RefundPresenter.present_refund(self)
74
75
  end
75
76
 
77
+ def proceed_with_product_zero_amount
78
+ Returnly::Services::MarkItemsAsReturned.new(order, line_items).perform!
79
+ RefundPresenter.present_refund_with_zero_amount(self)
80
+ end
81
+
76
82
  def perform_reimbursement
77
83
  Returnly::Services::CreateReimbursement.new(reimbursement).perform!
78
84
  add_shipping_amount!
@@ -0,0 +1,25 @@
1
+ module Returnly
2
+ module Services
3
+ class MarkItemsAsReturned
4
+ attr_accessor :order, :line_items
5
+
6
+ def initialize(order, line_items)
7
+ @order = order
8
+ @line_items = line_items
9
+ end
10
+
11
+ def perform!
12
+ line_items.each do |line_item|
13
+ quantity = line_item[:units].to_i
14
+ inventory_units_by(line_item[:order_line_item_id]).take(quantity).each(&:return)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def inventory_units_by(line_item_id)
21
+ order.inventory_units.where(line_item_id: line_item_id)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  module Returnly
2
- VERSION = '0.7.1'
2
+ VERSION = '0.8.0'
3
3
 
4
4
  def platform_version
5
5
  defined?(Solidus)
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.7.1
4
+ version: 0.8.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-10-25 00:00:00.000000000 Z
11
+ date: 2017-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus
@@ -350,6 +350,7 @@ files:
350
350
  - lib/returnly/refunder.rb
351
351
  - lib/returnly/refunds_configuration.rb
352
352
  - lib/returnly/services/create_reimbursement.rb
353
+ - lib/returnly/services/mark_items_as_returned.rb
353
354
  - lib/returnly/version.rb
354
355
  - lib/solidus-returnly.rb
355
356
  - lib/spree-returnly.rb