effective_orders 5.4.0 → 5.4.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: 2781d889611f7bc0c7f5c09002b62ae45ad2ac4d271cd8f641cef63e1692fcc4
4
- data.tar.gz: 5f8584ed6065c4caecec5b3699e9bbcd0c54c3a50fce1820bd7c10ef41c3cca9
3
+ metadata.gz: 93201b2a28d118f01d4404c0a1b1e7ce9cfccfa17e5449923d827f804297146f
4
+ data.tar.gz: 33c7e7c0b13f149bbea2c46d4f3aa70dbf3d4157c73be9dfe0b84f965e17bd13
5
5
  SHA512:
6
- metadata.gz: f14479b485a00ad66b28544d2123d8fa504c6abef82669df4b91d844cf25163b29e8bc38b3ad9d468c0514833f7b68c9d4b5be9263d3df3b40c3c94ec7b0a376
7
- data.tar.gz: d88561b37c3ffa64ecc3a79a20084dcbbb08bc0304d7213717fd06d0dcfa7f43bc6b480c3a36e164c45d9c6637e068a1069d7af6eb941f7319d434cf45c6071d
6
+ metadata.gz: b6e7b680b06ac025f6b4b8bad7845f95f92f04ab952479ee8cc66025b55da853a4c8871c910f322fdb4062860c66695fb8f9c3b52b3e56bc041bc243078d076b
7
+ data.tar.gz: 4750b01b2d298736a05e6f9290146695816f9c0a15dcd80701c2c0a04c1516cf4ebedd790ec334674aaf335abc77a7f58241274b1812897bc6b5b408650dff80
@@ -46,7 +46,7 @@ form.new_effective_order {
46
46
  }
47
47
 
48
48
  .effective-moneris-checkout {
49
- height: 640px;
49
+ height: 720px;
50
50
  }
51
51
 
52
52
  @media print {
@@ -15,7 +15,7 @@ module Admin
15
15
  submit :save, 'Checkout', redirect: -> { effective_orders.checkout_admin_order_path(resource) }
16
16
 
17
17
  def create
18
- @user = current_user.class.find_by_id(order_params[:user_id])
18
+ @user = current_user.class.find_by_id(permitted_params[:user_id])
19
19
  @order = Effective::Order.new(user: @user)
20
20
 
21
21
  authorize_effective_order!
@@ -23,12 +23,12 @@ module Admin
23
23
 
24
24
  Effective::Order.transaction do
25
25
  begin
26
- (order_params[:order_items_attributes] || {}).each do |_, item_attrs|
26
+ (permitted_params[:order_items_attributes] || {}).each do |_, item_attrs|
27
27
  purchasable = Effective::Product.new(item_attrs[:purchasable_attributes])
28
28
  @order.add(purchasable, quantity: item_attrs[:quantity])
29
29
  end
30
30
 
31
- @order.attributes = order_params.except(:order_items_attributes, :user_id)
31
+ @order.attributes = permitted_params.except(:order_items_attributes, :user_id)
32
32
  @order.pending!
33
33
 
34
34
  message = 'Successfully created order'
@@ -123,7 +123,7 @@ module Admin
123
123
 
124
124
  private
125
125
 
126
- def order_params
126
+ def permitted_params
127
127
  params.require(:effective_order).permit(:user_id, :user_type, :cc,
128
128
  :send_payment_request_to_buyer, :note_internal, :note_to_buyer,
129
129
  :payment_provider, :payment_card, :payment, :send_mark_as_paid_email_to_buyer,
@@ -26,7 +26,7 @@ module Effective
26
26
  def mark_as_paid_params
27
27
  params.require(:effective_order).permit(
28
28
  :purchased_at, :payment, :payment_provider, :payment_card,
29
- :note_to_buyer, :send_mark_as_paid_email_to_buyer
29
+ :note_to_buyer, :note_internal, :send_mark_as_paid_email_to_buyer
30
30
  )
31
31
  end
32
32
 
@@ -72,7 +72,7 @@ class Admin::EffectiveOrdersDatatable < Effective::Datatable
72
72
 
73
73
  col :total, as: :price
74
74
 
75
- col :payment_provider, label: 'Provider', visible: false, search: { collection: EffectiveOrders.payment_providers }
75
+ col :payment_provider, label: 'Provider', visible: false, search: { collection: EffectiveOrders.admin_payment_providers }
76
76
  col :payment_card, label: 'Card', visible: false
77
77
 
78
78
  if EffectiveOrders.collect_note
@@ -49,7 +49,7 @@ module Effective
49
49
  end
50
50
 
51
51
  # This is sent to admin when someone Accepts Refund
52
- def refund_notification_to_admin(order, opts = {})
52
+ def refund_notification_to_admin(resource, opts = {})
53
53
  raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order)
54
54
 
55
55
  @order = resource
@@ -120,7 +120,7 @@ module Effective
120
120
  validates :payment_provider, presence: true
121
121
 
122
122
  validate do
123
- self.errors.add(:payment_provider, "unknown payment provider") unless EffectiveOrders.payment_providers.include?(payment_provider)
123
+ self.errors.add(:payment_provider, "unknown payment provider") unless (EffectiveOrders.payment_providers + EffectiveOrders.admin_payment_providers).include?(payment_provider)
124
124
  end
125
125
 
126
126
  validates :payment_card, presence: true
@@ -323,6 +323,8 @@ module Effective
323
323
  def payment_method
324
324
  return nil unless purchased?
325
325
 
326
+ provider = payment_provider if ['cheque', 'phone'].include?(payment_provider)
327
+
326
328
  # Normalize payment card
327
329
  card = case payment_card.to_s.downcase.gsub(' ', '').strip
328
330
  when '' then nil
@@ -331,7 +333,7 @@ module Effective
331
333
  when 'a', 'ax', 'american', 'americanexpress' then 'American Express'
332
334
  when 'd', 'discover' then 'Discover'
333
335
  else payment_card.to_s
334
- end unless payment_provider == 'free'
336
+ end
335
337
 
336
338
  last4 = if payment[:active_card] && payment[:active_card].include?('**** **** ****')
337
339
  payment[:active_card][15,4]
@@ -340,7 +342,7 @@ module Effective
340
342
  # stripe, moneris, moneris_checkout
341
343
  last4 ||= (payment['f4l4'] || payment['first6last4']).to_s.last(4)
342
344
 
343
- [card, '-', last4].compact.join(' ')
345
+ [provider.presence, card.presence, last4.presence].compact.join(' - ')
344
346
  end
345
347
 
346
348
  def duplicate
@@ -7,20 +7,21 @@
7
7
  = effective_form_with(model: order, url: effective_orders.mark_as_paid_order_path(order), method: :post) do |f|
8
8
  = f.hidden_field :purchased_at, value: Time.zone.now
9
9
 
10
- = f.select :payment_provider, EffectiveOrders.payment_providers, required: true
10
+ = f.select :payment_provider, EffectiveOrders.admin_payment_providers, required: true
11
11
 
12
12
  = f.text_field :payment_card,
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.text_area :payment,
17
- label: 'Additional payment details',
18
- input_html: { value: f.object.payment.kind_of?(Hash) ? f.object.payment[:details] : f.object.payment.presence }
16
+ .row
17
+ .col
18
+ = f.text_area :note_to_buyer, hint: 'This message will be displayed to the buyer on the receipt.'
19
+ .col
20
+ = f.text_area :note_internal, hint: 'For or internal admin use only. This note will never be displayed to the buyer.'
19
21
 
20
22
  = f.check_box :send_mark_as_paid_email_to_buyer,
21
23
  label: 'Yes, send a receipt email to the buyer.',
22
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?) }
23
25
 
24
- = f.text_area :note_to_buyer, hint: 'This message will be displayed on the receipt.'
25
26
 
26
- = f.submit 'Admin: ' + order_checkout_label(order.refund? ? :refund : :mark_as_paid)
27
+ = f.submit order_checkout_label(order.refund? ? :refund : :mark_as_paid)
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '5.4.0'.freeze
2
+ VERSION = '5.4.3'.freeze
3
3
  end
@@ -142,6 +142,24 @@ module EffectiveOrders
142
142
  ].compact
143
143
  end
144
144
 
145
+ # For the Admin Mark as Paid screen
146
+ def self.admin_payment_providers
147
+ [
148
+ ('cheque' if mark_as_paid?),
149
+ ('credit card' if mark_as_paid?),
150
+ #('free' if free?),
151
+ ('moneris' if moneris?),
152
+ ('moneris_checkout' if moneris_checkout?),
153
+ ('paypal' if paypal?),
154
+ ('phone' if mark_as_paid?),
155
+ #('pretend' if pretend?),
156
+ #('refund' if refund?),
157
+ ('stripe' if stripe?),
158
+ ('other' if mark_as_paid?),
159
+ 'none'
160
+ ].compact
161
+ end
162
+
145
163
  def self.deferred_providers
146
164
  [('cheque' if cheque?), ('phone' if phone?)].compact
147
165
  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.4.0
4
+ version: 5.4.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: 2022-03-04 00:00:00.000000000 Z
11
+ date: 2022-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails