solidus-returnly 0.5.0.rc1 → 0.5.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: d0378de242c83b1090100232a64079f636aac6d6
4
- data.tar.gz: a8a53e96a4ee82075fa58cbcae02b4e3cbf48ece
3
+ metadata.gz: a9edf2b667482113a215f7917d02a5e0cf9cd8dd
4
+ data.tar.gz: 5ef6fc23050351bebe96e0709d7799f321755700
5
5
  SHA512:
6
- metadata.gz: 8cb73efb7d1ff47ccde5a81e79a8f1adf881a2f4895d2e43ee25f4f2f69414fcc822cbf77350f23efdfa778fbbd1aa66d537c0d663c8d586705418ecdbf81901
7
- data.tar.gz: 40173c56054f424e3021add1e74dea276db3583e53887f57d413d646c0b0eff9bc24257c706ba743f9143e3a98362565a08d96fed26ced6e0984e77180d86de5
6
+ metadata.gz: d8d04617201af5df391a32f9f64b1232be810b696e3a9a2f50d3d821db8ce08acb9000dfe55c2bf02070370def937422818195d2b44cf28e4d7fdb891edfe668
7
+ data.tar.gz: 1695d8f7d61946f15bc7d80fa2a45805a284a80bb12a55591c855240aa4c5b631931283fbfe43aa4c7b41a5830c572e26409e99e18a83d4a845413d656b689f1
@@ -2,3 +2,8 @@ require 'returnly/engine'
2
2
  require 'returnly/refunds_configuration'
3
3
  require 'returnly/refunder'
4
4
  require 'returnly/refund_calculator'
5
+
6
+ require 'returnly/version'
7
+ require 'returnly/refund/amount_calculator'
8
+ require 'returnly/refund/return_item_restock_policy'
9
+ require 'returnly/refund_presenter'
@@ -55,7 +55,7 @@ module Returnly
55
55
  def returnable_inventory_units
56
56
  @_inventory_units ||= order.inventory_units.includes(:line_item)
57
57
  .where(line_item_id: requested_line_items)
58
- .where('state is not "returned"')
58
+ .where('state != ?', 'returned')
59
59
  end
60
60
 
61
61
  def returnable_line_items
@@ -10,15 +10,17 @@ module Returnly
10
10
  sub_total += Money.from_amount return_item.pre_tax_amount
11
11
  end
12
12
 
13
+ total_refund_amount = total - calculator.order.promo_total
14
+ shipping_tax = calculator.shipping_tax
13
15
  {
14
- product_amount: sub_total.to_f,
15
- tax_amount: (total - sub_total).to_f,
16
- discount_amount: calculator.order.promo_total.to_f,
17
- total_refund_amount: (total - calculator.order.promo_total).to_f,
18
- refundable_shipping_amount: calculator.order.shipment_total.to_f,
19
- refundable_shipping_tax_amount: calculator.shipping_tax.to_f,
20
- max_refundable_amount: calculator.order.total.to_f,
21
- refunds_by_payment_method: refunds_by_payment(calculator.order)
16
+ product_amount: sub_total.to_f,
17
+ tax_amount: (total - sub_total).to_f,
18
+ discount_amount: calculator.order.promo_total.to_f,
19
+ total_refund_amount: total_refund_amount.to_f,
20
+ refundable_shipping_amount: calculator.order.shipment_total.to_f,
21
+ refundable_shipping_tax_amount: shipping_tax.to_f,
22
+ max_refundable_amount: calculator.order.total.to_f,
23
+ refunds_by_payment_method: refunds_by_payment(calculator.order, total_refund_amount.to_d + calculator.order.shipment_total + shipping_tax)
22
24
  }
23
25
  end
24
26
 
@@ -65,11 +67,14 @@ module Returnly
65
67
  }
66
68
  end
67
69
 
68
- private_class_method def self.refunds_by_payment(order)
69
- order.payments.each_with_object([]) do |payment, payments|
70
+ private_class_method def self.refunds_by_payment(order, amount)
71
+ completed_payments = order.payments.completed
72
+ payment_amount = amount / completed_payments.count
73
+
74
+ completed_payments.each_with_object([]) do |payment, payments|
70
75
  payments << {
71
76
  code: payment.source_type.constantize.model_name.human,
72
- amount: (order.item_total + order.adjustment_total).to_f,
77
+ amount: payment_amount.to_f,
73
78
  original_transaction_id: ''
74
79
  }
75
80
  end
@@ -1,5 +1,5 @@
1
1
  module Returnly
2
- VERSION = '0.5.0.rc1'
2
+ VERSION = '0.5.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.5.0.rc1
4
+ version: 0.5.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-08-24 00:00:00.000000000 Z
11
+ date: 2017-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_auth_devise
@@ -360,9 +360,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
360
360
  version: '0'
361
361
  required_rubygems_version: !ruby/object:Gem::Requirement
362
362
  requirements:
363
- - - ">"
363
+ - - ">="
364
364
  - !ruby/object:Gem::Version
365
- version: 1.3.1
365
+ version: '0'
366
366
  requirements: []
367
367
  rubyforge_project:
368
368
  rubygems_version: 2.6.11