effective_orders 5.5.2 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 496c6b24100359c7121e1903130d345ed5b13fabf41cf1a1e78be20be3d638c8
4
- data.tar.gz: a2451ac65694daa46c2386dd13754d6ed43ae2e9b8b34ff16903ec6c9591e888
3
+ metadata.gz: ff78fd58ee1ed93581d8595a4696c6949cd034453b25a3aacc0202141cf5a1c0
4
+ data.tar.gz: ebb6df4bd158ed459c6be065b7974961f7090a4bc7505ff7d53ae62ed64b107e
5
5
  SHA512:
6
- metadata.gz: 24a8a97d2bc9c2b45680fc4e9f8c751245d5e83d69ff085a744f1e16709219cafb04c13c55fd88eda8a2b2707eaeea0dea48a2c9f66c682187720ef334aab1b7
7
- data.tar.gz: 14af91d8e9a56efe0e65d07348f4de7c2fc83a14df32d06b3e3cb40306b4469b575dfaf9c629a9f67369226da089b464d46c0be0cda1d3a5ca15a68b3693d6a4
6
+ metadata.gz: 29f6c8410a99510761e7c9ee258314d731c8d78b64adec91f42ecb89e99c4a26e949a29f987cf9e421d88071f0425da8ed1e4802d06d29c4167d1e5aa7076e49
7
+ data.tar.gz: c9bce8b4363d39ea49eb1d8f99a80c92893185dbd28ab860d17ca4035677d5b52b42ae84adf84249885c8c4bb7184eac9aaf21510739885f80a6d43b762ee0a9
@@ -14,38 +14,11 @@ module Admin
14
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
- def create
18
- @user = current_user.class.find_by_id(permitted_params[:user_id])
19
- @order = Effective::Order.new(user: @user)
20
-
21
- authorize_effective_order!
22
- error = nil
23
-
24
- Effective::Order.transaction do
25
- begin
26
- (permitted_params[:order_items_attributes] || {}).each do |_, item_attrs|
27
- purchasable = Effective::Product.new(item_attrs[:purchasable_attributes])
28
- @order.add(purchasable, quantity: item_attrs[:quantity])
29
- end
30
-
31
- @order.attributes = permitted_params.except(:order_items_attributes, :user_id)
32
- @order.pending!
33
-
34
- message = 'Successfully created order'
35
- message << ". A request for payment has been sent to #{@order.emails_send_to}" if @order.send_payment_request_to_buyer?
36
- flash[:success] = message
37
-
38
- redirect_to(admin_redirect_path) and return
39
- rescue => e
40
- error = e.message
41
- raise ActiveRecord::Rollback
42
- end
43
- end
44
-
45
- @page_title = 'New Order'
46
- flash.now[:danger] = flash_danger(@order) + error.to_s
47
- render :new
48
- end
17
+ submit :save, 'Save', success: -> {
18
+ message = flash_success(resource, params[:action])
19
+ message << ". A request for payment has been sent to #{resource.emails_send_to}" if resource.send_payment_request_to_buyer?
20
+ message
21
+ }
49
22
 
50
23
  # The show page posts to this action
51
24
  # See Effective::OrdersController checkout
@@ -58,21 +31,19 @@ module Admin
58
31
 
59
32
  if request.get?
60
33
  @order.assign_confirmed_if_valid!
61
- render :checkout and return
34
+ render(:checkout)
35
+ return
62
36
  end
63
37
 
64
- Effective::Order.transaction do
65
- begin
66
- @order.assign_attributes(checkout_params)
67
- @order.confirm!
68
- redirect_to(effective_orders.checkout_admin_order_path(@order)) and return
69
- rescue => e
70
- raise ActiveRecord::Rollback
71
- end
72
- end
38
+ # Otherwise a post
39
+ @order.assign_attributes(checkout_params)
73
40
 
74
- flash.now[:danger] = "Unable to proceed: #{flash_errors(@order)}. Please try again."
75
- render :checkout
41
+ if (@order.confirm! rescue false)
42
+ redirect_to(effective_orders.checkout_admin_order_path(@order))
43
+ else
44
+ flash.now[:danger] = "Unable to proceed: #{flash_errors(@order)}. Please try again."
45
+ render :checkout
46
+ end
76
47
  end
77
48
 
78
49
  def destroy
@@ -124,15 +95,7 @@ module Admin
124
95
  private
125
96
 
126
97
  def permitted_params
127
- params.require(:effective_order).permit(:user_id, :user_type, :cc,
128
- :send_payment_request_to_buyer, :note_internal, :note_to_buyer,
129
- :payment_provider, :payment_card, :payment, :send_mark_as_paid_email_to_buyer,
130
- order_items_attributes: [
131
- :quantity, :_destroy, purchasable_attributes: [
132
- :name, :qb_item_name, :price, :tax_exempt
133
- ]
134
- ]
135
- )
98
+ params.require(:effective_order).permit!
136
99
  end
137
100
 
138
101
  def checkout_params
@@ -143,17 +106,5 @@ module Admin
143
106
  EffectiveResources.authorize!(self, action_name.to_sym, @order || Effective::Order)
144
107
  end
145
108
 
146
- def admin_redirect_path
147
- case params[:commit].to_s
148
- when 'Save' ; effective_orders.admin_order_path(@order)
149
- when 'Continue' ; effective_orders.admin_orders_path
150
- when 'Add New' ; effective_orders.new_admin_order_path(user_id: @order.user.try(:to_param))
151
- when 'Duplicate' ; effective_orders.new_admin_order_path(duplicate_id: @order.to_param)
152
- when 'Checkout' ; effective_orders.checkout_admin_order_path(@order.to_param)
153
- else
154
- effective_orders.admin_order_path(@order)
155
- end
156
- end
157
-
158
109
  end
159
110
  end
@@ -30,10 +30,10 @@ module Effective
30
30
  belongs_to :parent, polymorphic: true, optional: true
31
31
 
32
32
  belongs_to :user, polymorphic: true, validate: false # This is the buyer/user of the order. We validate it below.
33
- has_many :order_items, -> { order(:id) }, inverse_of: :order, dependent: :delete_all
33
+ accepts_nested_attributes_for :user, allow_destroy: false, update_only: true
34
34
 
35
+ has_many :order_items, -> { order(:id) }, inverse_of: :order, dependent: :delete_all
35
36
  accepts_nested_attributes_for :order_items, allow_destroy: false, reject_if: :all_blank
36
- accepts_nested_attributes_for :user, allow_destroy: false, update_only: true
37
37
 
38
38
  # Attributes
39
39
  effective_resource do
@@ -63,18 +63,30 @@ module Effective
63
63
 
64
64
  serialize :payment, Hash
65
65
 
66
- before_validation { assign_order_totals }
67
- before_validation { assign_billing_name }
68
- before_validation { assign_email }
69
- before_validation { assign_user_address }
70
- before_validation { assign_last_address }
66
+ scope :deep, -> { includes(:addresses, :user, order_items: :purchasable) }
67
+ scope :sorted, -> { order(:id) }
68
+
69
+ scope :purchased, -> { where(state: EffectiveOrders::PURCHASED) }
70
+ scope :purchased_by, lambda { |user| purchased.where(user: user) }
71
+ scope :not_purchased, -> { where.not(state: EffectiveOrders::PURCHASED) }
72
+
73
+ scope :pending, -> { where(state: EffectiveOrders::PENDING) }
74
+ scope :confirmed, -> { where(state: EffectiveOrders::CONFIRMED) }
75
+ scope :deferred, -> { where(state: EffectiveOrders::DEFERRED) }
76
+ scope :declined, -> { where(state: EffectiveOrders::DECLINED) }
77
+ scope :abandoned, -> { where(state: EffectiveOrders::ABANDONED) }
78
+ scope :refunds, -> { purchased.where('total < ?', 0) }
71
79
 
72
- before_validation(if: -> { confirmed_checkout }) do
73
- assign_attributes(state: EffectiveOrders::CONFIRMED) if pending?
80
+ before_validation do
81
+ self.state ||= EffectiveOrders::PENDING
82
+ self.state = EffectiveOrders::CONFIRMED if pending? && confirmed_checkout
74
83
  end
75
84
 
76
- before_save(if: -> { state_was == EffectiveOrders::PURCHASED }) do
77
- raise EffectiveOrders::AlreadyPurchasedException.new('cannot unpurchase an order') unless purchased?
85
+ with_options(unless: -> { purchased? }) do
86
+ before_validation { assign_email }
87
+ before_validation { assign_user_address }
88
+ before_validation { assign_billing_name }
89
+ before_validation { assign_order_totals }
78
90
  end
79
91
 
80
92
  # Order validations
@@ -84,6 +96,8 @@ module Effective
84
96
 
85
97
  validates :order_items, presence: { message: 'No items are present. Please add additional items.' }
86
98
  validates :state, inclusion: { in: EffectiveOrders::STATES.keys }
99
+
100
+ # Price validations
87
101
  validates :subtotal, presence: true
88
102
 
89
103
  with_options(if: -> { EffectiveOrders.minimum_charge.to_i > 0 }) do
@@ -118,11 +132,6 @@ module Effective
118
132
  validates :payment, presence: true
119
133
 
120
134
  validates :payment_provider, presence: true
121
-
122
- validate do
123
- self.errors.add(:payment_provider, "unknown payment provider") unless (EffectiveOrders.payment_providers + EffectiveOrders.admin_payment_providers).include?(payment_provider)
124
- end
125
-
126
135
  validates :payment_card, presence: true
127
136
  end
128
137
 
@@ -134,19 +143,9 @@ module Effective
134
143
  end
135
144
  end
136
145
 
137
- scope :deep, -> { includes(:addresses, :user, order_items: :purchasable) }
138
- scope :sorted, -> { order(:id) }
139
-
140
- scope :purchased, -> { where(state: EffectiveOrders::PURCHASED) }
141
- scope :purchased_by, lambda { |user| purchased.where(user: user) }
142
- scope :not_purchased, -> { where.not(state: EffectiveOrders::PURCHASED) }
143
-
144
- scope :pending, -> { where(state: EffectiveOrders::PENDING) }
145
- scope :confirmed, -> { where(state: EffectiveOrders::CONFIRMED) }
146
- scope :deferred, -> { where(state: EffectiveOrders::DEFERRED) }
147
- scope :declined, -> { where(state: EffectiveOrders::DECLINED) }
148
- scope :abandoned, -> { where(state: EffectiveOrders::ABANDONED) }
149
- scope :refunds, -> { purchased.where('total < ?', 0) }
146
+ before_save(if: -> { state_was == EffectiveOrders::PURCHASED }) do
147
+ raise EffectiveOrders::AlreadyPurchasedException.new('cannot unpurchase an order') unless purchased?
148
+ end
150
149
 
151
150
  # Effective::Order.new()
152
151
  # Effective::Order.new(Product.first)
@@ -165,7 +164,7 @@ module Effective
165
164
  if atts.kind_of?(Hash)
166
165
  items = Array(atts[:item]) + Array(atts[:items])
167
166
 
168
- self.user = atts[:user] || (items.first.user if items.first.respond_to?(:user))
167
+ self.user = atts[:user] || items.first.try(:user)
169
168
 
170
169
  if (address = atts[:billing_address]).present?
171
170
  self.billing_address = address
@@ -280,7 +279,7 @@ module Effective
280
279
  if purchasable.blank? || purchasable.marked_for_destruction?
281
280
  item.mark_for_destruction
282
281
  else
283
- item.price = purchasable.price
282
+ item.assign_purchasable_attributes
284
283
  end
285
284
  end
286
285
 
@@ -386,6 +385,20 @@ module Effective
386
385
  state == EffectiveOrders::DEFERRED
387
386
  end
388
387
 
388
+ def in_progress?
389
+ pending? || confirmed? || deferred?
390
+ end
391
+
392
+ def done?
393
+ purchased? || declined?
394
+ end
395
+
396
+ # A custom order is one that was created by an admin
397
+ # We allow custom orders to have their order items updated
398
+ def custom_order?
399
+ order_items.all? { |oi| oi.purchasable_type == 'Effective::Product' }
400
+ end
401
+
389
402
  def purchased?(provider = nil)
390
403
  return false if (state != EffectiveOrders::PURCHASED)
391
404
  return true if provider.nil? || payment_provider == provider.to_s
@@ -548,6 +561,10 @@ module Effective
548
561
  true
549
562
  end
550
563
 
564
+ def skip_quickbooks!
565
+ sync_quickbooks!(skip: true)
566
+ end
567
+
551
568
  def defer!(provider: 'none', email: true)
552
569
  return false if purchased?
553
570
 
@@ -624,9 +641,6 @@ module Effective
624
641
  EffectiveOrders.send_email(:refund_notification_to_admin, self) if purchased? && refund?
625
642
  end
626
643
 
627
- def skip_qb_sync!
628
- EffectiveOrders.use_effective_qb_sync ? EffectiveQbSync.skip_order!(self) : true
629
- end
630
644
 
631
645
  protected
632
646
 
@@ -651,56 +665,42 @@ module Effective
651
665
  order_items.reject { |oi| oi.marked_for_destruction? }
652
666
  end
653
667
 
654
- def assign_order_totals
655
- self.subtotal = present_order_items.map { |oi| oi.subtotal }.sum
656
- self.tax_rate = get_tax_rate()
657
- self.tax = get_tax()
658
- self.total = subtotal + (tax || 0)
659
- end
660
-
661
668
  def assign_billing_name
662
- self.billing_name = [(billing_address.full_name.presence if billing_address.present?), (user.to_s.presence)].compact.first
669
+ self.billing_name ||= billing_address.try(:full_name).presence || user.to_s.presence
663
670
  end
664
671
 
665
672
  def assign_email
666
- self.email = user&.email if user&.email.present?
667
- end
668
-
669
- def assign_last_address
670
- return unless user.present?
671
- return unless (EffectiveOrders.billing_address || EffectiveOrders.shipping_address)
672
- return if EffectiveOrders.billing_address && billing_address.present?
673
- return if EffectiveOrders.shipping_address && shipping_address.present?
674
-
675
- last_order = Effective::Order.sorted.where(user: user).last
676
- return unless last_order.present?
677
-
678
- if EffectiveOrders.billing_address && last_order.billing_address.present?
679
- self.billing_address = last_order.billing_address
680
- end
681
-
682
- if EffectiveOrders.shipping_address && last_order.shipping_address.present?
683
- self.shipping_address = last_order.shipping_address
684
- end
673
+ self.email ||= user.try(:email)
685
674
  end
686
675
 
687
676
  def assign_user_address
688
677
  return unless user.present?
689
- return unless (EffectiveOrders.billing_address || EffectiveOrders.shipping_address)
690
- return if EffectiveOrders.billing_address && billing_address.present?
691
- return if EffectiveOrders.shipping_address && shipping_address.present?
692
678
 
693
- if billing_address.blank? && user.respond_to?(:billing_address) && user.billing_address.present?
679
+ if EffectiveOrders.billing_address && billing_address.blank? && user.try(:billing_address).present?
694
680
  self.billing_address = user.billing_address
695
681
  self.billing_address.full_name ||= user.to_s.presence
696
682
  end
697
683
 
698
- if shipping_address.blank? && user.respond_to?(:shipping_address) && user.shipping_address.present?
684
+ if EffectiveOrders.shipping_address && shipping_address.blank? && user.try(:shipping_address).present?
699
685
  self.shipping_address = user.shipping_address
700
686
  self.shipping_address.full_name ||= user.to_s.presence
701
687
  end
702
688
  end
703
689
 
690
+ # This overwrites the prices, taxes, etc on every save.
691
+ def assign_order_totals
692
+ # Copies prices from purchasable into order items
693
+ present_order_items.each { |oi| oi.assign_purchasable_attributes() }
694
+
695
+ # The subtotal
696
+ subtotal = present_order_items.map { |oi| oi.subtotal }.sum
697
+
698
+ self.subtotal = subtotal
699
+ self.tax_rate = get_tax_rate()
700
+ self.tax = get_tax()
701
+ self.total = subtotal + (tax || 0)
702
+ end
703
+
704
704
  def update_purchasables_purchased_order!
705
705
  order_items.each { |oi| oi.purchasable&.update_column(:purchased_order_id, self.id) }
706
706
  end
@@ -3,7 +3,9 @@ module Effective
3
3
  self.table_name = EffectiveOrders.order_items_table_name.to_s
4
4
 
5
5
  belongs_to :order
6
+
6
7
  belongs_to :purchasable, polymorphic: true
8
+ accepts_nested_attributes_for :purchasable, allow_destroy: false
7
9
 
8
10
  if defined?(EffectiveQbSync)
9
11
  has_one :qb_order_item
@@ -18,21 +20,27 @@ module Effective
18
20
  timestamps
19
21
  end
20
22
 
21
- validates :purchasable, associated: true, presence: true
22
- accepts_nested_attributes_for :purchasable
23
+ scope :purchased, -> { where(order_id: Effective::Order.purchased) }
24
+ scope :purchased_by, lambda { |user| where(order_id: Effective::Order.purchased_by(user)) }
23
25
 
24
26
  validates :name, presence: true
25
27
  validates :quantity, presence: true, numericality: { greater_than: 0 }
26
28
  validates :price, presence: true
27
29
  validates :tax_exempt, inclusion: { in: [true, false] }
28
30
 
29
- scope :purchased, -> { where(order_id: Effective::Order.purchased) }
30
- scope :purchased_by, lambda { |user| where(order_id: Effective::Order.purchased_by(user)) }
31
-
32
31
  def to_s
33
32
  ((quantity || 0) > 1 ? "#{quantity}x #{name}" : name) || 'order item'
34
33
  end
35
34
 
35
+ # This method is called in a before_validation in order.assign_order_totals()
36
+ def assign_purchasable_attributes
37
+ assign_attributes(name: purchasable.name, price: purchasable.price, tax_exempt: purchasable.tax_exempt?) if purchasable
38
+ end
39
+
40
+ def build_purchasable(atts = {})
41
+ (self.purchasable ||= Effective::Product.new).tap { |purchasable| purchasable.assign_attributes(atts) }
42
+ end
43
+
36
44
  def purchased_download_url
37
45
  purchasable&.purchased_download_url
38
46
  end
@@ -58,16 +66,13 @@ module Effective
58
66
  end
59
67
 
60
68
  def price=(value)
61
- if value.kind_of?(Integer)
62
- super
63
- else
64
- raise 'expected price to be an Integer representing the number of cents.'
65
- end
69
+ raise 'expected price to be an Integer representing the number of cents.' unless value.kind_of?(Integer)
70
+ super
66
71
  end
67
72
 
68
73
  # first or build
69
74
  def qb_item_name
70
- raise('expected EffectiveQbSync gem') unless defined?(EffectiveQbSync)
75
+ raise('expected Effective Quickbooks gem') unless defined?(EffectiveQbSync) || defined?(EffectiveQbOnline)
71
76
  (qb_order_item || build_qb_order_item(name: purchasable&.qb_item_name)).name
72
77
  end
73
78
 
@@ -4,7 +4,7 @@ module Effective
4
4
 
5
5
  acts_as_purchasable
6
6
 
7
- # belongs_to :purchased_order_id
7
+ has_many :order_items, as: :purchasable
8
8
 
9
9
  effective_resource do
10
10
  name :string
@@ -1,22 +1,24 @@
1
- = effective_form_with(model: [:admin, order], url: (order.persisted? ? effective_orders.admin_order_path(order) : effective_orders.admin_orders_path)) do |f|
2
- - if f.object.new_record?
3
- - user_collection = current_user.class.respond_to?(:sorted) ? current_user.class.sorted : current_user.class.all
4
-
5
- = f.select :user_id, (@users || user_collection),
6
- label: 'Buyer', required: true, hint: 'The user that should purchase this order.'
1
+ = effective_form_with(model: [:admin, order], engine: true) do |f|
2
+ = f.hidden_field :user_type, value: (f.object.user || current_user).class.name
7
3
 
8
- = f.email_cc_field :cc, hint: "Cc the above on any emailed receipts or payment requests."
4
+ - collection = (@users || current_user.class.try(:sorted) || current_user.class.all)
5
+ = f.select :user_id, collection, label: 'Buyer', required: true, hint: 'The user that should purchase this order.'
9
6
 
10
- %h2 Order Items
11
- = f.has_many :order_items, remove: f.object.new_record? do |fc|
12
- = render 'order_item_fields', f: fc
13
-
14
- %hr
7
+ = f.email_cc_field :cc, hint: "Cc the above on any emailed receipts or payment requests."
15
8
 
9
+ - if f.object.new_record?
16
10
  = f.check_box :send_payment_request_to_buyer,
17
11
  label: 'Yes, send a payment request email to the buyer and any cc.',
18
12
  value: (f.object.send_payment_request_to_buyer.nil? ? EffectiveOrders.send_payment_request_to_buyer : f.object.send_payment_request_to_buyer?)
19
13
 
14
+ %hr
15
+
16
+ %h2 Order Items
17
+ = f.has_many :order_items, remove: true do |fc|
18
+ = render 'order_item_fields', f: fc
19
+
20
+ %hr
21
+
20
22
  .row
21
23
  .col-md-6.effective-order-note-to-buyer
22
24
  %h2 Note to Buyer
@@ -1,10 +1,19 @@
1
1
  .row.align-items-center
2
- = f.fields_for :purchasable, (f.object.purchasable || Effective::Product.new) do |pf|
3
- .col= f.number_field :quantity, input_html: { value: f.object.quantity || 1, min: 1 }
4
- .col= pf.text_field :name
2
+ = f.fields_for :purchasable, (f.object.purchasable || f.object.build_purchasable) do |pf|
3
+ -# Order item fields
4
+ .col
5
+ = f.hidden_field :purchasable_id
6
+ = f.hidden_field :purchasable_type
7
+ = f.number_field :quantity, input_html: { value: f.object.quantity || 1, min: 1 }
8
+
9
+ -# Purchasable fields
10
+ .col
11
+ = pf.hidden_field :id
12
+ = pf.text_field :name
13
+
5
14
  .col= pf.price_field :price
6
15
 
7
- - if EffectiveOrders.use_effective_qb_sync
16
+ - if EffectiveOrders.qb_sync? || EffectiveOrders.qb_online?
8
17
  .col= pf.text_field :qb_item_name, label: 'Quickbooks Item'
9
18
 
10
19
  .col= pf.check_box :tax_exempt, label: "Tax&nbsp;Exempt", title: 'When checked, tax will not be applied to this item'
@@ -1,6 +1,13 @@
1
1
  %h1.effective-admin-heading= @page_title
2
2
 
3
- = render partial: 'effective/orders/order', locals: { order: @order }
3
+ = render 'effective/orders/order_actions', order: @order
4
4
 
5
- .effective-order
6
- = render partial: 'form', locals: { order: @order }
5
+ - if @order.custom_order?
6
+ .mb-4
7
+ = collapse('show order') do
8
+ = render 'effective/orders/order', order: @order, no_order_actions: true
9
+
10
+ = render 'admin/orders/form', order: @order
11
+
12
+ - else
13
+ = render 'effective/orders/order', order: @order
@@ -1,4 +1,3 @@
1
1
  %h1.effective-admin-heading= @page_title
2
2
 
3
- .effective-order
4
- = render partial: 'form', locals: { order: @order }
3
+ = render 'admin/orders/form', order: @order
@@ -1,4 +1,4 @@
1
1
  %h1.effective-admin-heading= @page_title
2
2
 
3
- = render partial: 'effective/orders/order', locals: { order: @order }
4
- = render partial: 'admin/orders/form_note_internal', locals: { order: @order }
3
+ = render 'effective/orders/order', order: @order
4
+ = render 'admin/orders/form_note_internal', order: @order
@@ -7,12 +7,17 @@
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? && EffectiveResources.authorized?(controller, :admin, :effective_orders)
11
- - if order.pending? || order.confirmed? || order.deferred?
12
- = link_to 'Email request for payment to buyer', effective_orders.send_payment_request_admin_order_path(order),
13
- class: 'btn btn-secondary',
14
- data: { method: :post, confirm: "Send request for payment to #{order.emails_send_to}?" }
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')
15
13
 
16
- = link_to 'Delete', effective_orders.admin_order_path(order),
17
- class: 'btn btn-danger',
18
- data: { method: :delete, confirm: "Really delete #{order}?" }
14
+ - if params[:action] == 'edit'
15
+ = link_to('Show', effective_orders.admin_order_path(order), class: 'btn btn-primary')
16
+
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}?" }
20
+
21
+ = link_to 'Delete', effective_orders.admin_order_path(order),
22
+ class: 'btn btn-danger',
23
+ data: { method: :delete, confirm: "Really delete #{order}?" }
@@ -13,15 +13,15 @@
13
13
  label: 'Payment card type, cheque or transaction number',
14
14
  hint: 'Do not enter credit card numbers here, or anywhere.'
15
15
 
16
+ = f.check_box :send_mark_as_paid_email_to_buyer,
17
+ label: 'Yes, send a receipt email to the buyer.',
18
+ input_html: { checked: (f.object.send_mark_as_paid_email_to_buyer.nil? ? EffectiveOrders.send_order_receipts_when_mark_as_paid : f.object.send_mark_as_paid_email_to_buyer?) }
19
+
20
+
16
21
  .row
17
22
  .col
18
23
  = f.text_area :note_to_buyer, hint: 'This message will be displayed to the buyer on the receipt.'
19
24
  .col
20
25
  = f.text_area :note_internal, hint: 'For or internal admin use only. This note will never be displayed to the buyer.'
21
26
 
22
- = f.check_box :send_mark_as_paid_email_to_buyer,
23
- label: 'Yes, send a receipt email to the buyer.',
24
- input_html: { checked: (f.object.send_mark_as_paid_email_to_buyer.nil? ? EffectiveOrders.send_order_receipts_when_mark_as_paid : f.object.send_mark_as_paid_email_to_buyer?) }
25
-
26
-
27
27
  = f.submit order_checkout_label(order.refund? ? :refund : :mark_as_paid)
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '5.5.2'.freeze
2
+ VERSION = '5.6.0'.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.5.2
4
+ version: 5.6.0
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-16 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails