effective_orders 5.6.1 → 5.6.2

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: 9916dc95644358778cbf90e9fd1901470b4212af2e17dc57bbc417d56c6d68bd
4
- data.tar.gz: 59ee98077944da2d2b2d60f017b605ddc232828d141480e607e6594643dc72a7
3
+ metadata.gz: 4e419a31818cf5abba11e1330c5cf38e7637f144d9eacade387f919de7433973
4
+ data.tar.gz: 12a61662d772982f6ddff6f00bd990dfdab017a33ce011b55caf7f4507715010
5
5
  SHA512:
6
- metadata.gz: cae30e352a619e635506bc5c94f941f76b0b7d7bfa9d60a289fc7f1315bb9bcdf5959e0f6d05e35687152bfe5085bf44cfb3b875f819bac75464c70b5e61cf56
7
- data.tar.gz: 6f00eced041af3ba59e122676059845cad7728cac6b08404dfd09fea324c37bc6e62435a981eb7cc32a0787e0e90a30c2584361008d07cea5aa71a5009428b2f
6
+ metadata.gz: abc379d14277eb75eef1c315ad05d49bbd801211c8f4781951249421c6433f9e1fef5b5ff5e0348859ccab4a185bc4439ae0a06f0ba8e1bdc9b6bf9199f912ce
7
+ data.tar.gz: b189c07ee57a22ba4f3fb314da7078b7cf7d8f9d25ab85f3d37e6be74c8924cdc6ccac516053bf2ee0bbc182f8c80f1b4b82505cdd310a6d6bde02b0fff17dd2
@@ -82,7 +82,7 @@ module Effective
82
82
  self.state = EffectiveOrders::CONFIRMED if pending? && confirmed_checkout
83
83
  end
84
84
 
85
- with_options(unless: -> { purchased? }) do
85
+ with_options(unless: -> { done? }) do
86
86
  before_validation { assign_email }
87
87
  before_validation { assign_user_address }
88
88
  before_validation { assign_billing_name }
@@ -105,7 +105,7 @@ module Effective
105
105
 
106
106
  validate(unless: -> { (free? && EffectiveOrders.free?) || (refund? && EffectiveOrders.refund?) }) do
107
107
  if total.present? && total < EffectiveOrders.minimum_charge
108
- self.errors.add(:total, "must be $#{'%0.2f' % (EffectiveOrders.minimum_charge.to_i / 100.0)} or more. Please add additional items.")
108
+ errors.add(:total, "must be $#{'%0.2f' % (EffectiveOrders.minimum_charge.to_i / 100.0)} or more. Please add additional items.")
109
109
  end
110
110
  end
111
111
  end
@@ -139,7 +139,7 @@ module Effective
139
139
  validates :payment_provider, presence: true
140
140
 
141
141
  validate do
142
- self.errors.add(:payment_provider, "unknown deferred payment provider") unless EffectiveOrders.deferred_providers.include?(payment_provider)
142
+ errors.add(:payment_provider, "unknown deferred payment provider") unless EffectiveOrders.deferred_providers.include?(payment_provider)
143
143
  end
144
144
  end
145
145
 
@@ -147,6 +147,10 @@ module Effective
147
147
  raise EffectiveOrders::AlreadyPurchasedException.new('cannot unpurchase an order') unless purchased?
148
148
  end
149
149
 
150
+ before_save(if: -> { done? }) do
151
+ raise('cannot change total of a purchased order') if changes[:total].present?
152
+ end
153
+
150
154
  # Effective::Order.new()
151
155
  # Effective::Order.new(Product.first)
152
156
  # Effective::Order.new(current_cart)
@@ -390,7 +394,7 @@ module Effective
390
394
  end
391
395
 
392
396
  def done?
393
- purchased? || declined?
397
+ persisted? && (purchased? || declined?)
394
398
  end
395
399
 
396
400
  # A custom order is one that was created by an admin
@@ -641,7 +645,6 @@ module Effective
641
645
  EffectiveOrders.send_email(:refund_notification_to_admin, self) if purchased? && refund?
642
646
  end
643
647
 
644
-
645
648
  protected
646
649
 
647
650
  def get_tax_rate
@@ -666,11 +669,11 @@ module Effective
666
669
  end
667
670
 
668
671
  def assign_billing_name
669
- self.billing_name ||= billing_address.try(:full_name).presence || user.to_s.presence
672
+ self.billing_name = billing_address.try(:full_name).presence || user.to_s.presence
670
673
  end
671
674
 
672
675
  def assign_email
673
- self.email ||= user.try(:email)
676
+ self.email = user.email if user.try(:email).present?
674
677
  end
675
678
 
676
679
  def assign_user_address
@@ -690,9 +693,9 @@ module Effective
690
693
  # This overwrites the prices, taxes, etc on every save.
691
694
  def assign_order_totals
692
695
  # Copies prices from purchasable into order items
693
- present_order_items.each { |oi| oi.assign_purchasable_attributes() }
696
+ present_order_items.each { |oi| oi.assign_purchasable_attributes }
694
697
 
695
- # The subtotal
698
+ # Sum of order item subtotals
696
699
  subtotal = present_order_items.map { |oi| oi.subtotal }.sum
697
700
 
698
701
  self.subtotal = subtotal
@@ -1,8 +1,8 @@
1
1
  %h1.effective-admin-heading= @page_title
2
2
 
3
- = render 'effective/orders/order_actions', order: @order
3
+ - if @order.custom_order? && @order.in_progress?
4
+ = render 'effective/orders/order_actions', order: @order
4
5
 
5
- - if @order.custom_order?
6
6
  .mb-4
7
7
  = collapse('show order') do
8
8
  = render 'effective/orders/order', order: @order, no_order_actions: true
@@ -10,4 +10,6 @@
10
10
  = render 'admin/orders/form', order: @order
11
11
 
12
12
  - else
13
+ - # Same as the show action
13
14
  = render 'effective/orders/order', order: @order
15
+ = render 'admin/orders/form_note_internal', order: @order
@@ -7,17 +7,18 @@
7
7
  class: 'btn btn-secondary',
8
8
  data: { method: :post, confirm: "Send receipt to #{order.emails_send_to}?" }
9
9
 
10
- - if order.persisted? && order.in_progress? && EffectiveResources.authorized?(controller, :admin, :effective_orders)
11
- - if params[:action] == 'show'
12
- = link_to('Edit', effective_orders.edit_admin_order_path(order), class: 'btn btn-primary')
10
+ - if controller_path.include?('admin/') && (EffectiveResources.authorized?(controller, :admin, :effective_orders) rescue false)
11
+ - if order.persisted? && order.in_progress?
12
+ - if params[:action] == 'show'
13
+ = link_to('Edit', effective_orders.edit_admin_order_path(order), class: 'btn btn-primary')
13
14
 
14
- - if params[:action] == 'edit'
15
- = link_to('Show', effective_orders.admin_order_path(order), class: 'btn btn-primary')
15
+ - if params[:action] == 'edit'
16
+ = link_to('Show', effective_orders.admin_order_path(order), class: 'btn btn-primary')
16
17
 
17
- = link_to 'Email request for payment to buyer', effective_orders.send_payment_request_admin_order_path(order),
18
- class: 'btn btn-secondary',
19
- data: { method: :post, confirm: "Send request for payment to #{order.emails_send_to}?" }
18
+ = link_to 'Email request for payment to buyer', effective_orders.send_payment_request_admin_order_path(order),
19
+ class: 'btn btn-secondary',
20
+ data: { method: :post, confirm: "Send request for payment to #{order.emails_send_to}?" }
20
21
 
21
- = link_to 'Delete', effective_orders.admin_order_path(order),
22
- class: 'btn btn-danger',
23
- data: { method: :delete, confirm: "Really delete #{order}?" }
22
+ = link_to 'Delete', effective_orders.admin_order_path(order),
23
+ class: 'btn btn-danger',
24
+ data: { method: :delete, confirm: "Really delete #{order}?" }
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '5.6.1'.freeze
2
+ VERSION = '5.6.2'.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: 5.6.1
4
+ version: 5.6.2
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: 2022-05-25 00:00:00.000000000 Z
11
+ date: 2022-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails