effective_orders 3.2.3 → 4.0.0beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +5 -5
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +11 -99
  4. data/app/assets/stylesheets/effective_orders.scss +1 -0
  5. data/app/assets/stylesheets/effective_orders/_cart.scss +4 -0
  6. data/app/assets/stylesheets/effective_orders/_order.scss +6 -2
  7. data/app/controllers/admin/orders_controller.rb +17 -17
  8. data/app/controllers/effective/carts_controller.rb +4 -2
  9. data/app/controllers/effective/orders_controller.rb +50 -105
  10. data/app/controllers/effective/providers/cheque.rb +1 -1
  11. data/app/controllers/effective/providers/moneris.rb +17 -23
  12. data/app/controllers/effective/providers/stripe.rb +2 -37
  13. data/app/datatables/effective_customers_datatable.rb +1 -5
  14. data/app/datatables/effective_order_items_datatable.rb +10 -10
  15. data/app/datatables/effective_orders_datatable.rb +23 -46
  16. data/app/helpers/effective_carts_helper.rb +5 -25
  17. data/app/helpers/effective_orders_helper.rb +29 -61
  18. data/app/helpers/effective_paypal_helper.rb +10 -8
  19. data/app/helpers/effective_stripe_helper.rb +2 -33
  20. data/app/models/concerns/acts_as_purchasable.rb +26 -37
  21. data/app/models/concerns/acts_as_subscribable.rb +1 -1
  22. data/app/models/effective/cart.rb +4 -5
  23. data/app/models/effective/customer.rb +1 -4
  24. data/app/models/effective/order.rb +132 -163
  25. data/app/models/effective/order_item.rb +2 -21
  26. data/app/models/{effective → validators/effective}/sold_out_validator.rb +0 -0
  27. data/app/views/admin/customers/index.html.haml +1 -4
  28. data/app/views/admin/order_items/index.html.haml +1 -4
  29. data/app/views/admin/orders/_actions.html.haml +18 -9
  30. data/app/views/admin/orders/_form.html.haml +12 -14
  31. data/app/views/admin/orders/_form_note_internal.html.haml +2 -2
  32. data/app/views/admin/orders/_order_actions.html.haml +8 -5
  33. data/app/views/admin/orders/_order_item_fields.html.haml +9 -8
  34. data/app/views/admin/orders/checkout.html.haml +3 -0
  35. data/app/views/admin/orders/edit.html.haml +3 -1
  36. data/app/views/admin/orders/new.html.haml +2 -1
  37. data/app/views/admin/orders/show.html.haml +2 -5
  38. data/app/views/effective/carts/_cart.html.haml +1 -1
  39. data/app/views/effective/carts/_cart_actions.html.haml +3 -4
  40. data/app/views/effective/carts/show.html.haml +4 -4
  41. data/app/views/effective/orders/_checkout_actions.html.haml +3 -0
  42. data/app/views/effective/orders/_checkout_step1.html.haml +20 -27
  43. data/app/views/effective/orders/_checkout_step2.html.haml +26 -30
  44. data/app/views/effective/orders/_order.html.haml +1 -2
  45. data/app/views/effective/orders/_order_actions.html.haml +14 -6
  46. data/app/views/effective/orders/_order_header.html.haml +2 -2
  47. data/app/views/effective/orders/_order_note_fields.html.haml +6 -4
  48. data/app/views/effective/orders/_order_notes.html.haml +15 -0
  49. data/app/views/effective/orders/_order_payment_details.html.haml +1 -1
  50. data/app/views/effective/orders/_order_shipping.html.haml +6 -6
  51. data/app/views/effective/orders/_order_terms_and_conditions_fields.html.haml +5 -6
  52. data/app/views/effective/orders/_order_user_fields.html.haml +5 -11
  53. data/app/views/effective/orders/_orders_table.html.haml +2 -6
  54. data/app/views/effective/orders/index.html.haml +2 -1
  55. data/app/views/effective/orders/mark_as_paid/_form.html.haml +8 -14
  56. data/app/views/effective/orders/moneris/_form.html.haml +43 -4
  57. data/app/views/effective/orders/pretend/_form.html.haml +1 -3
  58. data/app/views/effective/orders/refund/_form.html.haml +8 -12
  59. data/app/views/effective/orders/show.html.haml +2 -2
  60. data/app/views/effective/orders/stripe/_form.html.haml +4 -4
  61. data/app/views/effective/orders_mailer/payment_request_to_buyer.html.haml +1 -1
  62. data/app/views/effective/orders_mailer/pending_order_invoice_to_buyer.html.haml +1 -1
  63. data/config/effective_orders.rb +116 -182
  64. data/config/routes.rb +16 -27
  65. data/db/migrate/01_create_effective_orders.rb.erb +6 -5
  66. data/lib/effective_orders.rb +72 -76
  67. data/lib/effective_orders/engine.rb +8 -80
  68. data/lib/effective_orders/version.rb +1 -1
  69. data/lib/generators/templates/effective_orders_mailer_preview.rb +4 -4
  70. metadata +26 -38
  71. data/Rakefile +0 -21
  72. data/app/assets/config/effective_orders_manifest.js +0 -3
  73. data/app/assets/images/effective_orders/stripe_connect.png +0 -0
  74. data/app/controllers/effective/providers/app_checkout.rb +0 -38
  75. data/app/controllers/effective/providers/ccbill.rb +0 -34
  76. data/app/controllers/effective/providers/stripe_connect.rb +0 -47
  77. data/app/helpers/effective_ccbill_helper.rb +0 -25
  78. data/app/models/effective/providers/ccbill_postback.rb +0 -85
  79. data/app/models/effective/providers/moneris_charge.rb +0 -115
  80. data/app/views/effective/orders/_order_note.html.haml +0 -5
  81. data/app/views/effective/orders/_order_note_to_buyer.html.haml +0 -9
  82. data/app/views/effective/orders/app_checkout/_form.html.haml +0 -2
  83. data/app/views/effective/orders/ccbill/_form.html.haml +0 -24
  84. data/app/views/effective/orders/my_purchases.html.haml +0 -3
  85. data/app/views/effective/orders/my_sales.html.haml +0 -25
  86. data/app/views/effective/orders_mailer/order_receipt_to_seller.html.haml +0 -25
  87. data/lib/effective_orders/app_checkout_service.rb +0 -26
@@ -4,7 +4,6 @@ module Effective
4
4
 
5
5
  belongs_to :order, class_name: 'Effective::Order'
6
6
  belongs_to :purchasable, polymorphic: true
7
- belongs_to :seller, class_name: 'User', optional: true
8
7
 
9
8
  delegate :purchased_download_url, to: :purchasable
10
9
  delegate :purchased?, :declined?, to: :order
@@ -24,9 +23,7 @@ module Effective
24
23
  validates :price, presence: true
25
24
  validates :tax_exempt, inclusion: { in: [true, false] }
26
25
 
27
- validates :seller_id, presence: true, if: -> { EffectiveOrders.stripe_connect_enabled }
28
-
29
- scope :sold, -> { joins(:order).where(orders: { purchase_state: EffectiveOrders::PURCHASED }) }
26
+ scope :sold, -> { joins(:order).where(orders: { state: EffectiveOrders::PURCHASED }) }
30
27
  scope :sold_by, lambda { |user| sold().where(seller_id: user.id) }
31
28
 
32
29
  def to_s
@@ -52,26 +49,10 @@ module Effective
52
49
  def price=(value)
53
50
  if value.kind_of?(Integer)
54
51
  super
55
- elsif value.kind_of?(String) && !value.include?('.') # Looks like an integer
56
- super
57
- else # Could be Float, BigDecimal, or String like 9.99
52
+ else
58
53
  raise 'expected price to be an Integer representing the number of cents.'
59
54
  end
60
55
  end
61
56
 
62
- # This is going to return an Effective::Customer object that matches the purchasable.user
63
- # And is the Customer representing who is selling the product
64
- # This is really only used for StripeConnect
65
- def seller
66
- @seller ||= Effective::Customer.for_buyer(purchasable.seller)
67
- end
68
-
69
- def stripe_connect_application_fee
70
- @stripe_connect_application_fee ||= (
71
- self.instance_exec(self, &EffectiveOrders.stripe_connect_application_fee_method).to_i.tap do |fee|
72
- raise "expected EffectiveOrders.stripe_connect_application_fee_method to return a value between 0 and the order_item total (#{self.total}). Received #{fee}." if (fee > total || fee < 0)
73
- end
74
- )
75
- end
76
57
  end
77
58
  end
@@ -3,7 +3,4 @@
3
3
  %p.text-right.effective-admin-actions
4
4
  = link_to 'Stripe Customers', "https://dashboard.stripe.com/#{'test/' if Rails.env.development?}customers", class: 'btn btn-primary'
5
5
 
6
- - if @datatable.present?
7
- = render_datatable @datatable
8
- - else
9
- %p There are no customers present
6
+ = render_datatable(@datatable)
@@ -1,6 +1,3 @@
1
1
  %h1.effective-admin-heading= @page_title
2
2
 
3
- - if @datatable.present?
4
- = render_datatable @datatable
5
- - else
6
- %p There are no order items present
3
+ = render_datatable(@datatable)
@@ -1,11 +1,20 @@
1
- - if datatable.admin_namespace?
2
- - if order.purchased? == false
3
- = link_to effective_orders.admin_order_path(order), title: 'Checkout' do
4
- %span.glyphicon.glyphicon-usd
1
+ = dropdown(variation: :dropleft) do
2
+ - if datatable.admin_namespace?
3
+ = dropdown_link_to 'View', effective_orders.admin_order_path(order)
4
+ = dropdown_link_to 'Edit', effective_orders.edit_admin_order_path(order)
5
5
 
6
- = link_to effective_orders.edit_admin_order_path(order), title: 'Edit' do
7
- %span.glyphicon.glyphicon-edit
6
+ - if order.purchased?
7
+ = dropdown_link_to 'Email receipt to buyer', effective_orders.send_buyer_receipt_order_path(order),
8
+ data: { confirm: "Send receipt to #{order.user.email}?" }
8
9
 
9
- - else
10
- = link_to effective_orders.order_path(order), title: 'View' do
11
- %span.glyphicon.glyphicon-eye-open
10
+ - if order.pending? || order.confirmed?
11
+ = dropdown_link_to 'Email request for payment to buyer', effective_orders.send_payment_request_admin_order_path(order),
12
+ data: { method: :post, confirm: "Send request for payment to #{order.user.email}?" }
13
+
14
+ = dropdown_link_to 'Admin: Checkout', effective_orders.checkout_admin_order_path(order)
15
+
16
+ = dropdown_link_to "Delete #{order}", effective_orders.admin_order_path(order),
17
+ data: { method: :delete, confirm: "Really delete #{order}?" }
18
+
19
+ - else
20
+ = dropdown_link_to 'View', effective_orders.order_path(order)
@@ -1,33 +1,31 @@
1
- = simple_form_for [:admin, order], (EffectiveOrders.admin_simple_form_options || {}).merge(url: (order.persisted? ? effective_orders.admin_order_path(order) : effective_orders.admin_orders_path)) do |f|
1
+ = effective_form_with(model: [:admin, order], url: (order.persisted? ? effective_orders.admin_order_path(order) : effective_orders.admin_orders_path)) do |f|
2
2
  - if f.object.new_record?
3
- = f.association :user,
4
- label: 'Buyer',
5
- required: true,
6
- as: :effective_select,
7
- collection: @users || User.all.to_a.sort { |user1, user2| user1.to_s <=> user2.to_s }
3
+ = f.select :user_id, @users || User.all.to_a.sort { |user1, user2| user1.to_s <=> user2.to_s }, label: 'Buyer', required: true
8
4
 
9
5
  %h2 Order Items
10
6
  .order_items
11
7
  - f.object.order_items.build unless f.object.order_items.present?
12
- = f.simple_fields_for :order_items do |order_item|
8
+ = f.fields_for :order_items, f.object.order_items do |order_item|
13
9
  = render 'order_item_fields', f: order_item
14
10
 
15
11
  .links
16
- = link_to_add_association '+ Add line item', f, :order_items, partial: 'order_item_fields'
12
+ = link_to_add_association "Add line item".html_safe, f, :order_items, class: 'btn btn-success', partial: 'order_item_fields'
17
13
 
18
- = f.input :send_payment_request_to_buyer,
19
- as: :boolean,
14
+ %hr
15
+
16
+ = f.check_box :send_payment_request_to_buyer,
20
17
  label: 'Yes, send a payment request email to the buyer.',
21
18
  value: (f.object.send_payment_request_to_buyer.nil? ? EffectiveOrders.mailer[:send_payment_request_to_buyer] : f.object.send_payment_request_to_buyer?)
22
19
 
23
20
  .row
24
- .col-sm-6.effective-order-note-to-buyer
21
+ .col-md-6.effective-order-note-to-buyer
25
22
  %h2 Note to Buyer
26
- = f.input :note_to_buyer, disabled: f.object.purchased?, label: false,
23
+ = f.text_area :note_to_buyer, disabled: f.object.purchased?, label: false,
27
24
  hint: (f.object.purchased? ? 'This message was displayed to the buyer during checkout and appears on the receipt.' : 'This message will be displayed to the buyer during checkout and will appear on the receipt.')
28
25
 
29
- .col-sm-6.effective-order-internal-note
26
+ .col-md-6.effective-order-internal-note
30
27
  %h2 Internal Note
31
- = f.input :note_internal, label: false, hint: 'For internal admin use only. This note will never be displayed to the buyer.'
28
+ = f.text_area :note_internal, label: false,
29
+ hint: 'For internal admin use only. This note will never be displayed to the buyer.'
32
30
 
33
31
  = render partial: '/admin/orders/order_actions', locals: { order: @order, form: f, f: f }
@@ -1,7 +1,7 @@
1
1
  .effective-order-internal-note-form
2
2
  %h2 Internal Note
3
3
 
4
- = simple_form_for [:admin, order], (EffectiveOrders.admin_simple_form_options || {}).merge(url: effective_orders.admin_order_path(order)) do |f|
5
- = f.input :note_internal, label: false, hint: 'For internal admin use only. This note will never be displayed to the buyer.'
4
+ = effective_form_with(model: [:admin, order] ,url: effective_orders.admin_order_path(order)) do |f|
5
+ = f.text_area :note_internal, label: false, hint: 'For internal admin use only. This note will never be displayed to the buyer.'
6
6
 
7
7
  = render partial: '/admin/orders/order_actions', locals: { order: @order, form: f, f: f }
@@ -1,5 +1,8 @@
1
- %p.text-right
2
- = form.button :submit, 'Save', data: { disable_with: 'Saving...' }
3
- = form.button :submit, 'Save and Continue', data: { disable_with: 'Saving...' }
4
- = form.button :submit, 'Save and Add New', data: { disable_with: 'Saving...' }
5
- = form.button :submit, 'Save and Duplicate', data: { disable_with: 'Saving...' }
1
+ = effective_save(form) do
2
+ = form.save 'Save', class: 'btn btn-primary'
3
+ = form.save 'Duplicate', class: 'btn btn-primary'
4
+ - unless form.object.purchased?
5
+ = form.save 'Checkout', class: 'btn btn-success'
6
+
7
+ = form.save 'Continue', class: 'btn btn-secondary'
8
+ = form.save 'Add New', class: 'btn btn-secondary'
@@ -1,9 +1,10 @@
1
1
  .nested-fields.order-item
2
- .row
3
- - f.object.purchasable ||= Effective::Product.new
4
- = f.simple_fields_for :purchasable do |purchasable|
5
- .col-sm-2= f.input :quantity, input_html: { value: f.object.quantity || 1, min: 1 }
6
- .col-sm-4= purchasable.input :title, input_html: { maxlength: 255 }
7
- .col-sm-2= purchasable.input :price, as: :effective_price
8
- .col-sm-2= purchasable.input :tax_exempt, label: 'Tax Exempt', input_html: { title: 'When checked, tax will not be applied to this item' }
9
- .col-sm-2.remove-nested-fields= link_to_remove_association('Remove line item', f)
2
+ .row.align-items-center
3
+ = f.fields_for :purchasable, (f.object.purchasable || Effective::Product.new) do |pf|
4
+ .col-md-1= f.number_field :quantity, input_html: { value: f.object.quantity || 1, min: 1 }
5
+ .col-md-5= pf.text_field :title, maxlength: 255
6
+ .col-md-2= pf.price_field :price
7
+ .col-md-2.mt-4= pf.check_box :tax_exempt, label: "Tax&nbsp;Exempt", title: 'When checked, tax will not be applied to this item'
8
+ .col-md-1.mt-4
9
+ = link_to_remove_association(f, 'data-confirm': 'Really remove this item?') do
10
+ = icon('x', class: 'btn-danger')
@@ -0,0 +1,3 @@
1
+ %h1.effective-admin-heading= @page_title
2
+
3
+ = render_checkout(@order, namespace: :admin, purchased_url: effective_orders.admin_order_path(@order), declined_url: effective_orders.admin_order_path(@order))
@@ -1,4 +1,6 @@
1
1
  %h1.effective-admin-heading= @page_title
2
2
 
3
3
  = render partial: 'effective/orders/order', locals: { order: @order }
4
- .effective-order= render partial: 'form', locals: { order: @order }
4
+
5
+ .effective-order
6
+ = render partial: 'form', locals: { order: @order }
@@ -1,3 +1,4 @@
1
1
  %h1.effective-admin-heading= @page_title
2
2
 
3
- .effective-order= render partial: 'form', locals: { order: @order }
3
+ .effective-order
4
+ = render partial: 'form', locals: { order: @order }
@@ -1,7 +1,4 @@
1
1
  %h1.effective-admin-heading= @page_title
2
2
 
3
- - if @order.purchased?
4
- = render partial: 'effective/orders/order', locals: { order: @order }
5
- = render partial: 'admin/orders/form_note_internal', locals: { order: @order }
6
- - else
7
- = render_checkout_step2(@order, namespace: :admin, purchased_url: effective_orders.admin_order_path(@order), declined_url: effective_orders.admin_order_path(@order))
3
+ = render partial: 'effective/orders/order', locals: { order: @order }
4
+ = render partial: 'admin/orders/form_note_internal', locals: { order: @order }
@@ -1,4 +1,4 @@
1
- .effective-order
1
+ .effective-cart
2
2
  %table.table
3
3
  %thead
4
4
  %tr
@@ -1,4 +1,3 @@
1
- .effective-order-actions.pull-right
2
- %p
3
- = link_to_checkout
4
- = link_to_empty_cart
1
+ .effective-cart-actions.form-actions
2
+ = link_to_checkout
3
+ = link_to_empty_cart
@@ -2,16 +2,16 @@
2
2
 
3
3
  - if @cart.blank?
4
4
  %p No items in cart.
5
- - else
5
+
6
+ - if @cart.present?
6
7
  %p Your cart has #{@cart.cart_items.length} items.
7
8
 
8
9
  = render_cart(@cart)
9
- %hr
10
10
  = render partial: '/effective/carts/cart_actions', locals: { cart: @cart }
11
11
 
12
12
  - if @pending_orders.present?
13
13
  %h2 Pending Orders
14
14
  = render_orders(@pending_orders)
15
15
 
16
- - if EffectiveOrders.show_order_history_button
17
- = link_to_my_purchases(label: 'Order History')
16
+ - if @cart.user && Effective::Order.purchased.where(user: @cart.user).exists?
17
+ = link_to 'Order History', effective_orders.orders_path, rel: :nofollow, class: 'btn btn-secondary'
@@ -0,0 +1,3 @@
1
+ - if (order.pending? || order.confirmed?) && current_cart.present? && order.user == current_user
2
+ .effective-order-change-items
3
+ = link_to 'Change Items', effective_orders.cart_path, rel: :nofollow, class: 'btn btn-secondary'
@@ -1,35 +1,29 @@
1
1
  .effective-order
2
- = simple_form_for(order, (EffectiveOrders.simple_form_options || {}).merge(url: checkout_step1_form_url(order, namespace))) do |f|
3
- = hidden_field_tag(:purchased_url, purchased_url) if defined?(:purchased_url)
4
- = hidden_field_tag(:declined_url, declined_url) if defined?(:declined_url)
2
+ = effective_form_with(model: order, url: checkout_step1_form_url(order, namespace)) do |f|
3
+ = render partial: 'effective/orders/order_notes', locals: { order: order }
4
+ = render partial: 'effective/orders/order_items', locals: { order: order }
5
5
 
6
- = render partial: 'effective/orders/order_items', locals: { order: order, form: f }
6
+ - if current_cart.present?
7
+ .effective-order-change-items
8
+ = link_to 'Change Items', effective_orders.cart_path, rel: :nofollow, class: 'btn btn-secondary'
7
9
 
8
- - unless f.object.pending? || (current_cart && current_cart.blank?)
9
- = link_to 'Change Items', effective_orders.cart_path, rel: :nofollow, class: 'btn btn-default'
10
-
11
- - if order.errors[:order_items].present?
12
- %p.inline-errors= order.errors[:order_items].first
13
-
14
- - if order.errors[:total].present?
15
- %p.inline-errors= order.errors[:total].first
16
-
17
- - if EffectiveOrders.collect_user_fields.present? && (f.object.user rescue nil).present?
10
+ - if EffectiveOrders.collect_user_fields.present? && f.object.user.present?
18
11
  = render partial: 'effective/orders/order_user_fields', locals: { form: f, user: f.object.user }
19
12
 
20
- - num_addresses = [EffectiveOrders.require_billing_address, EffectiveOrders.require_shipping_address].count(true)
13
+ - num_addresses = [EffectiveOrders.billing_address, EffectiveOrders.shipping_address].count(true)
21
14
 
22
15
  - if num_addresses > 0
23
- .row
24
- - if EffectiveOrders.require_billing_address
25
- %div{class: "col-sm-#{12 / num_addresses}"}
26
- %h2 Billing Address
27
- = effective_address_fields(f, :billing_address)
28
-
29
- - if EffectiveOrders.require_shipping_address
30
- %div{class: "col-sm-#{12 / num_addresses}"}
31
- %h2 Shipping Address
32
- = effective_address_fields(f, :shipping_address)
16
+ .effective-order-addresses
17
+ .row
18
+ - if EffectiveOrders.billing_address
19
+ %div{class: "col-md-#{12 / num_addresses}"}
20
+ %h2 Billing Address
21
+ = effective_address_fields(f, :billing_address)
22
+
23
+ - if EffectiveOrders.shipping_address
24
+ %div{class: "col-md-#{12 / num_addresses}"}
25
+ %h2 Shipping Address
26
+ = effective_address_fields(f, :shipping_address)
33
27
 
34
28
  - if EffectiveOrders.collect_note
35
29
  = render partial: 'effective/orders/order_note_fields', locals: { form: f }
@@ -37,5 +31,4 @@
37
31
  - if EffectiveOrders.terms_and_conditions
38
32
  = render partial: 'effective/orders/order_terms_and_conditions_fields', locals: { form: f }
39
33
 
40
- %p.text-right
41
- = f.submit 'Save and Continue', class: 'btn btn-primary', rel: :nofollow, data: { disable_with: 'Saving...' }
34
+ = effective_save(f, 'Proceed to Checkout')
@@ -1,47 +1,43 @@
1
1
  = render partial: 'effective/orders/order', locals: { order: order }
2
- - form_locals = { order: order, purchased_url: purchased_url, declined_url: declined_url }
3
2
 
4
- .effective-order.effective-order-purchase-actions
5
- - if EffectiveOrders.allow_free_orders && order.free?
6
- = render partial: '/effective/orders/free/form', locals: form_locals
3
+ - if order.persisted? && order.user == current_user
4
+ .effective-order-change-items
5
+ = link_to 'Change Addresses', effective_orders.edit_order_path(order), rel: :nofollow, class: 'btn btn-secondary'
7
6
 
8
- - elsif EffectiveOrders.allow_refunds && order.refund?
9
- -# Nothing
10
-
11
- - else
12
- - if EffectiveOrders.allow_pretend_purchase_in_development && !Rails.env.production?
13
- = render partial: '/effective/orders/pretend/form', locals: form_locals
7
+ .effective-order.effective-order-purchase-actions.form-actions
8
+ - provider_locals = { order: order, purchased_url: purchased_url, declined_url: declined_url }
14
9
 
15
- - if EffectiveOrders.allow_pretend_purchase_in_production && Rails.env.production?
16
- = render partial: '/effective/orders/pretend/form', locals: form_locals
10
+ - if EffectiveOrders.free? && order.free?
11
+ = render partial: '/effective/orders/free/form', locals: provider_locals
17
12
 
18
- - if EffectiveOrders.moneris_enabled
19
- = render partial: '/effective/orders/moneris/form', locals: form_locals
13
+ - elsif EffectiveOrders.refunds? && order.refund?
14
+ -# Nothing
20
15
 
21
- - if EffectiveOrders.paypal_enabled
22
- = render partial: '/effective/orders/paypal/form', locals: form_locals
16
+ - else
17
+ - if EffectiveOrders.pretend?
18
+ = render partial: '/effective/orders/pretend/form', locals: provider_locals
23
19
 
24
- - if EffectiveOrders.stripe_enabled
25
- = render partial: '/effective/orders/stripe/form', locals: form_locals
20
+ - if EffectiveOrders.moneris?
21
+ = render partial: '/effective/orders/moneris/form', locals: provider_locals
26
22
 
27
- - if EffectiveOrders.ccbill_enabled
28
- = render partial: '/effective/orders/ccbill/form', locals: form_locals
23
+ - if EffectiveOrders.paypal?
24
+ = render partial: '/effective/orders/paypal/form', locals: provider_locals
29
25
 
30
- - if EffectiveOrders.app_checkout_enabled && EffectiveOrders.authorized?(controller, :app_checkout, order)
31
- = render partial: '/effective/orders/app_checkout/form', locals: form_locals
26
+ - if EffectiveOrders.stripe?
27
+ = render partial: '/effective/orders/stripe/form', locals: provider_locals
32
28
 
33
- - if EffectiveOrders.cheque_enabled && order.user == current_user
34
- = render partial: '/effective/orders/cheque/form', locals: form_locals
29
+ - if EffectiveOrders.cheque? && order.user == current_user
30
+ = render partial: '/effective/orders/cheque/form', locals: provider_locals
35
31
 
36
- - if EffectiveOrders.allow_pretend_purchase_in_production && Rails.env.production? && EffectiveOrders.allow_pretend_purchase_in_production_message.present?
32
+ - if EffectiveOrders.pretend? && Rails.env.production? && EffectiveOrders.pretend_purchase_in_production_message.present?
37
33
  %br
38
- %p= EffectiveOrders.allow_pretend_purchase_in_production_message
34
+ %p= EffectiveOrders.pretend_purchase_in_production_message
39
35
 
40
36
  - if EffectiveOrders.authorized?(controller, :admin, :effective_orders) && order.user != current_user
41
- - if EffectiveOrders.allow_refunds && order.refund?
37
+ - if EffectiveOrders.refunds? && order.refund?
42
38
  .effective-order.effective-order-admin-purchase-actions
43
- = render partial: '/effective/orders/refund/form', locals: form_locals
44
- - elsif EffectiveOrders.mark_as_paid_enabled
39
+ = render partial: '/effective/orders/refund/form', locals: provider_locals
40
+ - elsif EffectiveOrders.mark_as_paid?
45
41
  .effective-order.effective-order-admin-purchase-actions
46
- = render partial: '/effective/orders/mark_as_paid/form', locals: form_locals
42
+ = render partial: '/effective/orders/mark_as_paid/form', locals: provider_locals
47
43
 
@@ -4,8 +4,7 @@
4
4
 
5
5
  = render partial: 'effective/orders/order_header', locals: { order: order }
6
6
  = render partial: 'effective/orders/order_shipping', locals: { order: order }
7
- = render partial: 'effective/orders/order_note', locals: { order: order }
8
- = render partial: 'effective/orders/order_note_to_buyer', locals: { order: order }
7
+ = render partial: 'effective/orders/order_notes', locals: { order: order }
9
8
  = render partial: 'effective/orders/order_items', locals: { order: order }
10
9
  = render partial: 'effective/orders/order_payment_details', locals: { order: order }
11
10
  = render partial: 'effective/orders/order_footer', locals: { order: order }
@@ -1,10 +1,18 @@
1
1
  .effective-order-actions
2
- = link_to 'Print', '#', class: 'btn btn-default print-button', data: { role: 'print-button' }, onClick: 'window.print(); false;'
2
+ - if order.persisted?
3
+ = link_to 'Print', '#', class: 'btn btn-primary print-button', data: { role: 'print-button' }, onClick: 'window.print(); false;'
3
4
 
4
5
  - if order.purchased?
5
- = link_to 'Resend Receipt', effective_orders.send_buyer_receipt_order_path(order), class: 'btn btn-default', data: { confirm: 'This action will email the buyer a copy of the original email receipt. Send receipt now?', disable_with: 'Resending...' }
6
+ = link_to 'Email receipt to buyer', effective_orders.send_buyer_receipt_order_path(order),
7
+ class: 'btn btn-secondary',
8
+ data: { confirm: "Send receipt to #{order.user.email}?" }
6
9
 
7
- - elsif EffectiveOrders.authorized?(controller, :admin, :effective_orders) && order.user != current_user
8
- - if order.pending?
9
- = link_to 'Admin: Send Payment Request', effective_orders.send_payment_request_admin_order_path(order), class: 'btn btn-default', data: { method: :post, confirm: 'This action will email buyer a payment request. Send it now?', disable_with: 'Sending...' }
10
- = link_to 'Admin: Delete', effective_orders.admin_order_path(order), class: 'btn btn-default', data: { method: :delete, confirm: 'Are you sure you want to delete? This cannot be undone.', disable_with: 'Deleting...' }
10
+ - if order.persisted? && EffectiveOrders.authorized?(controller, :admin, :effective_orders)
11
+ - if order.pending? || order.confirmed?
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.user.email}?" }
15
+
16
+ = link_to 'Delete', effective_orders.admin_order_path(order),
17
+ class: 'btn btn-danger',
18
+ data: { method: :delete, confirm: "Really delete #{order}?" }
@@ -14,7 +14,7 @@
14
14
  .col-sm-6
15
15
  - if order.purchased?
16
16
  %p Receipt: ##{order.to_param}
17
- %p Purchased at: #{order.purchased_at.strftime("%Y-%m-%d %H:%M")}
17
+ %p Purchased at: #{order.purchased_at.strftime("%F %H:%M")}
18
18
  - elsif order.persisted?
19
19
  %p Order: ##{order.to_param}
20
- %p Date: #{Time.zone.now.strftime("%Y-%m-%d %H:%M")}
20
+ %p Date: #{Time.zone.now.strftime("%F %H:%M")}