effective_orders 5.1.1 → 5.1.5

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: 78aa25d8f77169e21e2f05886c47479ac2f64d8de4657510b2723ab9d4246fbd
4
- data.tar.gz: 22f9fd8d7747c3975952fe6edfc6e221fe567ec0b287e619ba3afd861dcc2bfb
3
+ metadata.gz: 70fd6793f180e1b0106c700cef6aacc0363cf7b2e3c76389e53db1301e6bac4e
4
+ data.tar.gz: 9fca2375abb56fd3052d2c098324f0dd6eb3d675772700f8ee792a12e54b39a6
5
5
  SHA512:
6
- metadata.gz: 7c3d9e1dcc47b3f982be6bc41abbafde4ceae73b682704f0916b941aa06248d431b52420d472592e850919e518bc12b835be04fdee5292d9d72396ebe9b053fe
7
- data.tar.gz: 7ff135bb56772c9fdf3edf6d59dc4ef7e0dfade542b1db022b09db49fc2b9b7e9f7333ae5e705390b4b0f27a03127fb743c9ffb471b29dd74e4a6a3da75917d0
6
+ metadata.gz: 5c33291651b6c2e6789040feca6573827a2f61f64b1b6553692ebfc4b45382949f0814b5257bfa7fc3d65d461b8a36bf01051565acf06474638a9f9771268d4b
7
+ data.tar.gz: 51155ef9663bc5912b70c7c9be2232a55aa4d7565eeaf19eca83eea7f216b1d809d998259f347a2fc643755215792c323e3b7e8eb4ffd6c5b2f733899f407604
@@ -11,7 +11,7 @@ module Admin
11
11
 
12
12
  submit :save, 'Continue', redirect: :index
13
13
  submit :save, 'Add New', redirect: -> { effective_orders.new_admin_order_path(user_id: resource.user&.to_param) }
14
- submit :save, 'Duplicate', redirect: -> { effective_posts.new_admin_post_path(duplicate_id: resource.id) }
14
+ submit :save, 'Duplicate', redirect: -> { effective_orders.new_admin_order_path(duplicate_id: resource.to_param) }
15
15
  submit :save, 'Checkout', redirect: -> { effective_orders.checkout_admin_order_path(resource) }
16
16
 
17
17
  def create
@@ -225,7 +225,6 @@ module Effective
225
225
  retval.size == 1 ? retval.first : retval
226
226
  end
227
227
 
228
-
229
228
  def update_prices!
230
229
  raise('already purchased') if purchased?
231
230
  raise('must be pending or confirmed') unless pending? || confirmed?
@@ -24,14 +24,21 @@ module Effective
24
24
  @order = order
25
25
  @country_code = country_code
26
26
  @state_code = state_code
27
-
28
- raise 'expected an order, or a country and state code' unless (order || country_code)
29
- raise 'expected an order OR a country and state code. Not both.' if (order && country_code)
30
27
  end
31
28
 
32
29
  def tax_rate
33
- country = country_code || (order.billing_address.country_code if order.billing_address.present?)
34
- state = state_code || (order.billing_address.state_code if order.billing_address.present?)
30
+ country = country_code
31
+ state = state_code
32
+
33
+ if order.present? && order.billing_address.present?
34
+ country ||= order.billing_address.country_code
35
+ state ||= order.billing_address.state_code
36
+ end
37
+
38
+ if order.present? && order.user.respond_to?(:billing_address) && order.user.billing_address.present?
39
+ country ||= order.user.billing_address.country_code
40
+ state ||= order.user.billing_address.state_code
41
+ end
35
42
 
36
43
  rate = RATES[country]
37
44
  return rate if rate.kind_of?(Numeric)
@@ -8,7 +8,7 @@
8
8
  = f.email_cc_field :cc, hint: "Cc the above on any emailed receipts or payment requests."
9
9
 
10
10
  %h2 Order Items
11
- = f.has_many :order_items do |fc|
11
+ = f.has_many :order_items, remove: f.object.new_record? do |fc|
12
12
  = render 'order_item_fields', f: fc
13
13
 
14
14
  %hr
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '5.1.1'.freeze
2
+ VERSION = '5.1.5'.freeze
3
3
  end
@@ -107,7 +107,7 @@ module EffectiveOrders
107
107
 
108
108
  # The Effective::Order.payment_provider value must be in this collection
109
109
  def self.payment_providers
110
- [
110
+ @payment_providers ||= [
111
111
  ('cheque' if cheque?),
112
112
  ('credit card' if mark_as_paid?),
113
113
  ('free' if free?),
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: 5.1.1
4
+ version: 5.1.5
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: 2021-08-23 00:00:00.000000000 Z
11
+ date: 2021-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails