effective_orders 4.5.11 → 4.6.3

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
  SHA256:
3
- metadata.gz: f1e00998a7bf70939f686faf24ecf1ad4248f232bca18bfd1abb1074cadf4881
4
- data.tar.gz: 2ee502e056f89522b4a88480fe2d4a8995a70d6bcbeb7abecfd41a09a85f6862
3
+ metadata.gz: '0619b2dc6fc02860fcf6100f107133d2bb47133cb43eb03e60905a1932acca06'
4
+ data.tar.gz: a2cb49a3e9fba575b7f95941b64f58b02bd81e4030b4ddb14130ea2fb3f041f3
5
5
  SHA512:
6
- metadata.gz: 0f0b25a0e32aea32cd5b66a521509181b347ce58c4a6e858064de8fc7192796456d1ac49c5e96515a8b442d8958e7398490ffbc165fb4cc853c83ab1650eba8b
7
- data.tar.gz: 6ef0bedaa012be759e8645296eb6c0aae894b815c92ec7964e5d6dc712eb9139bab52c0d9a9bcee0f661a174fcb7c8c9d1754e5a9f817742020f68b9d07f7043
6
+ metadata.gz: 8b39ed3047b11b55ddb153a4465c3c31e11304cef618eb70ed1eb237f522e1ddd7267cd1507b7a2c25ee737dc3f31654940c676a9ef4419565f7b776f4a5622c
7
+ data.tar.gz: 36a94c2eb539e2beb23996fb97d14b2befe62ae9154cd1cd578cac1bf9f886f0a9c3eca05f453b92d4bd4fdf6c17f84c621cce270732e70360cb272ee1db6ddd
@@ -64,13 +64,13 @@ module Effective
64
64
 
65
65
  # Always step1
66
66
  def edit
67
- @order ||= Effective::Order.find(params[:id])
67
+ @order ||= Effective::Order.not_purchased.find(params[:id])
68
68
  EffectiveOrders.authorize!(self, :edit, @order)
69
69
  end
70
70
 
71
71
  # Confirms the order from existing order
72
72
  def update
73
- @order ||= Effective::Order.find(params[:id])
73
+ @order ||= Effective::Order.not_purchased.find(params[:id])
74
74
  EffectiveOrders.authorize!(self, :update, @order)
75
75
 
76
76
  @order.assign_attributes(checkout_params)
@@ -106,7 +106,7 @@ module Effective
106
106
  end
107
107
 
108
108
  def send_buyer_receipt
109
- @order = Effective::Order.find(params[:id])
109
+ @order = Effective::Order.purchased.find(params[:id])
110
110
  EffectiveOrders.authorize!(self, :show, @order)
111
111
 
112
112
  if @order.send_order_receipt_to_buyer!
@@ -17,7 +17,7 @@ module EffectiveSubscriptionsHelper
17
17
  raise 'form object must be an acts_as_subscribable object' unless subscribable.respond_to?(:subscripter)
18
18
 
19
19
  subscripter = subscribable.subscripter
20
- raise 'subscribable.subscribable_buyer must match current_user' unless subscripter.user == current_user
20
+ # raise 'subscribable.subscribable_buyer must match current_user' unless subscripter.user == current_user
21
21
 
22
22
  render('effective/subscripter/form', subscripter: subscripter)
23
23
  end
@@ -72,6 +72,10 @@ module Effective
72
72
  self.state = EffectiveOrders::CONFIRMED if pending?
73
73
  end
74
74
 
75
+ before_save(if: -> { state_was == EffectiveOrders::PURCHASED }) do
76
+ raise EffectiveOrders::AlreadyPurchasedException.new('cannot unpurchase an order') unless purchased?
77
+ end
78
+
75
79
  # Order validations
76
80
  validates :user_id, presence: true
77
81
  validates :email, presence: true, email: true # email and cc validators are from effective_resources
@@ -326,6 +330,8 @@ module Effective
326
330
  # It skips any address or bad user validations
327
331
  # It's basically the same as save! on a new order, except it might send the payment request to buyer
328
332
  def pending!
333
+ return false if purchased?
334
+
329
335
  self.state = EffectiveOrders::PENDING
330
336
  self.addresses.clear if addresses.any? { |address| address.valid? == false }
331
337
  save!
@@ -336,6 +342,7 @@ module Effective
336
342
 
337
343
  # Used by admin checkout only
338
344
  def confirm!
345
+ return false if purchased?
339
346
  update!(state: EffectiveOrders::CONFIRMED)
340
347
  end
341
348
 
@@ -31,7 +31,7 @@ module Effective
31
31
  end
32
32
 
33
33
  def customer
34
- @customer ||= Effective::Customer.deep.where(user: user).first_or_initialize
34
+ @customer ||= Effective::Customer.deep.where(user: subscribable&.subscribable_buyer || user).first_or_initialize
35
35
  end
36
36
 
37
37
  def current_user=(user)
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '4.5.11'.freeze
2
+ VERSION = '4.6.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.11
4
+ version: 4.6.3
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: 2020-09-04 00:00:00.000000000 Z
11
+ date: 2021-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails