effective_orders 2.2.4 → 3.0.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.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +124 -84
  4. data/app/assets/javascripts/effective_orders/customers.js.coffee +39 -0
  5. data/app/assets/javascripts/effective_orders/providers/{stripe_charges.js.coffee → stripe.js.coffee} +15 -13
  6. data/app/assets/javascripts/effective_orders/subscriptions.js.coffee +73 -0
  7. data/app/assets/stylesheets/effective_orders.scss +2 -1
  8. data/app/assets/stylesheets/effective_orders/_order.scss +16 -8
  9. data/app/assets/stylesheets/effective_orders/_subscriptions.scss +14 -0
  10. data/app/controllers/admin/customers_controller.rb +11 -8
  11. data/app/controllers/admin/order_items_controller.rb +4 -8
  12. data/app/controllers/admin/orders_controller.rb +133 -87
  13. data/app/controllers/effective/carts_controller.rb +18 -8
  14. data/app/controllers/effective/concerns/purchase.rb +39 -0
  15. data/app/controllers/effective/customers_controller.rb +43 -0
  16. data/app/controllers/effective/orders_controller.rb +73 -119
  17. data/app/controllers/effective/providers/app_checkout.rb +3 -1
  18. data/app/controllers/effective/providers/ccbill.rb +4 -6
  19. data/app/controllers/effective/providers/cheque.rb +20 -11
  20. data/app/controllers/effective/providers/free.rb +33 -0
  21. data/app/controllers/effective/providers/mark_as_paid.rb +33 -0
  22. data/app/controllers/effective/providers/moneris.rb +9 -17
  23. data/app/controllers/effective/providers/paypal.rb +4 -6
  24. data/app/controllers/effective/providers/pretend.rb +4 -4
  25. data/app/controllers/effective/providers/refund.rb +39 -0
  26. data/app/controllers/effective/providers/stripe.rb +19 -40
  27. data/app/controllers/effective/providers/stripe_connect.rb +2 -6
  28. data/app/controllers/effective/webhooks_controller.rb +44 -95
  29. data/app/datatables/effective_customers_datatable.rb +21 -29
  30. data/app/datatables/effective_order_items_datatable.rb +77 -79
  31. data/app/datatables/effective_orders_datatable.rb +67 -57
  32. data/app/helpers/effective_carts_helper.rb +17 -14
  33. data/app/helpers/effective_orders_helper.rb +40 -56
  34. data/app/helpers/effective_paypal_helper.rb +3 -3
  35. data/app/helpers/effective_stripe_helper.rb +47 -18
  36. data/app/helpers/effective_subscriptions_helper.rb +79 -0
  37. data/app/mailers/effective/orders_mailer.rb +125 -2
  38. data/app/models/concerns/acts_as_purchasable.rb +23 -33
  39. data/app/models/concerns/acts_as_subscribable.rb +68 -0
  40. data/app/models/concerns/acts_as_subscribable_buyer.rb +22 -0
  41. data/app/models/effective/cart.rb +53 -24
  42. data/app/models/effective/cart_item.rb +6 -12
  43. data/app/models/effective/customer.rb +51 -54
  44. data/app/models/effective/order.rb +160 -147
  45. data/app/models/effective/order_item.rb +18 -21
  46. data/app/models/effective/product.rb +7 -7
  47. data/app/models/effective/providers/ccbill_postback.rb +1 -1
  48. data/app/models/effective/providers/stripe_charge.rb +8 -19
  49. data/app/models/effective/subscripter.rb +230 -0
  50. data/app/models/effective/subscription.rb +27 -76
  51. data/app/models/effective/tax_rate_calculator.rb +10 -7
  52. data/app/views/admin/customers/_actions.html.haml +1 -2
  53. data/app/views/admin/customers/index.html.haml +1 -1
  54. data/app/views/admin/customers/show.html.haml +6 -0
  55. data/app/views/admin/orders/_actions.html.haml +9 -7
  56. data/app/views/admin/orders/_form.html.haml +11 -7
  57. data/app/views/admin/orders/_order_actions.html.haml +2 -1
  58. data/app/views/admin/orders/_order_item_fields.html.haml +1 -1
  59. data/app/views/admin/orders/edit.html.haml +4 -0
  60. data/app/views/admin/orders/index.html.haml +1 -4
  61. data/app/views/admin/orders/new.html.haml +1 -1
  62. data/app/views/admin/orders/show.html.haml +5 -6
  63. data/app/views/effective/carts/_cart.html.haml +2 -2
  64. data/app/views/effective/carts/show.html.haml +2 -2
  65. data/app/views/effective/customers/_customer.html.haml +152 -0
  66. data/app/views/effective/customers/_fields.html.haml +12 -0
  67. data/app/views/effective/customers/_form.html.haml +13 -0
  68. data/app/views/effective/customers/edit.html.haml +3 -0
  69. data/app/views/effective/orders/_checkout_step1.html.haml +8 -15
  70. data/app/views/effective/orders/_checkout_step2.html.haml +34 -21
  71. data/app/views/effective/orders/_order.html.haml +8 -9
  72. data/app/views/effective/orders/_order_actions.html.haml +7 -8
  73. data/app/views/effective/orders/_order_header.html.haml +1 -1
  74. data/app/views/effective/orders/_order_items.html.haml +11 -5
  75. data/app/views/effective/orders/_order_note.html.haml +4 -7
  76. data/app/views/effective/orders/_orders_table.html.haml +26 -26
  77. data/app/views/effective/orders/app_checkout/_form.html.haml +2 -2
  78. data/app/views/effective/orders/ccbill/_form.html.haml +1 -1
  79. data/app/views/effective/orders/cheque/_form.html.haml +3 -1
  80. data/app/views/effective/orders/declined.html.haml +1 -1
  81. data/app/views/effective/orders/{checkout_step1.html.haml → edit.html.haml} +0 -0
  82. data/app/views/effective/orders/free/_form.html.haml +4 -0
  83. data/app/views/effective/orders/index.html.haml +2 -4
  84. data/app/views/effective/orders/mark_as_paid/_form.html.haml +32 -0
  85. data/app/views/effective/orders/moneris/_form.html.haml +6 -6
  86. data/app/views/effective/orders/{checkout_step2.html.haml → new.html.haml} +1 -1
  87. data/app/views/effective/orders/paypal/_form.html.haml +2 -2
  88. data/app/views/effective/orders/pretend/_form.html.haml +2 -2
  89. data/app/views/effective/orders/purchased.html.haml +3 -0
  90. data/app/views/effective/orders/refund/_form.html.haml +32 -0
  91. data/app/views/effective/orders/show.html.haml +4 -1
  92. data/app/views/effective/orders/stripe/_form.html.haml +5 -5
  93. data/app/views/effective/orders_mailer/subscription_canceled.html.haml +9 -0
  94. data/app/views/effective/orders_mailer/subscription_payment_failed.html.haml +9 -0
  95. data/app/views/effective/orders_mailer/subscription_payment_succeeded.html.haml +9 -0
  96. data/app/views/effective/orders_mailer/subscription_trial_expired.html.haml +5 -0
  97. data/app/views/effective/orders_mailer/subscription_trial_expiring.html.haml +7 -0
  98. data/app/views/effective/subscriptions/_fields.html.haml +16 -0
  99. data/app/views/effective/subscriptions/_plan.html.haml +21 -0
  100. data/app/views/layouts/effective_orders_mailer_layout.html.haml +6 -8
  101. data/config/effective_orders.rb +41 -20
  102. data/config/routes.rb +48 -48
  103. data/db/migrate/01_create_effective_orders.rb.erb +19 -5
  104. data/lib/effective_orders.rb +78 -42
  105. data/lib/effective_orders/engine.rb +36 -82
  106. data/lib/effective_orders/version.rb +1 -1
  107. data/lib/generators/effective_orders/install_generator.rb +2 -2
  108. data/lib/generators/templates/effective_orders_mailer_preview.rb +39 -4
  109. data/lib/tasks/effective_orders_tasks.rake +42 -0
  110. data/spec/controllers/carts_controller_spec.rb +1 -1
  111. data/spec/controllers/moneris_orders_controller_spec.rb +4 -4
  112. data/spec/controllers/orders_controller_spec.rb +4 -4
  113. data/spec/controllers/stripe_orders_controller_spec.rb +2 -2
  114. data/spec/controllers/webhooks_controller_spec.rb +1 -1
  115. data/spec/dummy/config/initializers/effective_orders.rb +1 -7
  116. data/spec/dummy/db/schema.rb +1 -0
  117. data/spec/dummy/db/test.sqlite3 +0 -0
  118. data/spec/dummy/log/test.log +3 -0
  119. data/spec/models/acts_as_purchasable_spec.rb +0 -56
  120. data/spec/models/customer_spec.rb +3 -3
  121. data/spec/models/order_spec.rb +2 -2
  122. data/spec/spec_helper.rb +1 -1
  123. data/spec/support/factories.rb +2 -1
  124. metadata +37 -49
  125. data/active_admin/effective_carts.rb +0 -14
  126. data/active_admin/effective_orders.rb +0 -112
  127. data/app/assets/javascripts/effective_orders/providers/stripe_subscriptions.js.coffee +0 -28
  128. data/app/controllers/concerns/acts_as_active_admin_controller.rb +0 -69
  129. data/app/controllers/effective/subscriptions_controller.rb +0 -126
  130. data/app/models/effective/datatables/customers.rb +0 -40
  131. data/app/models/effective/datatables/order_items.rb +0 -101
  132. data/app/models/effective/datatables/orders.rb +0 -91
  133. data/app/models/inputs/price_field.rb +0 -63
  134. data/app/models/inputs/price_form_input.rb +0 -7
  135. data/app/models/inputs/price_formtastic_input.rb +0 -9
  136. data/app/models/inputs/price_input.rb +0 -19
  137. data/app/models/inputs/price_simple_form_input.rb +0 -8
  138. data/app/views/admin/orders/_form_mark_as_paid.html.haml +0 -33
  139. data/app/views/admin/orders/_order_payment_details.html.haml +0 -5
  140. data/app/views/admin/orders/mark_as_paid.html.haml +0 -7
  141. data/app/views/effective/orders/stripe/_subscription_fields.html.haml +0 -7
  142. data/app/views/effective/subscriptions/index.html.haml +0 -22
  143. data/app/views/effective/subscriptions/new.html.haml +0 -9
  144. data/app/views/effective/subscriptions/show.html.haml +0 -49
  145. data/db/upgrade/02_upgrade_effective_orders_from03x.rb.erb +0 -29
  146. data/db/upgrade/03_upgrade_effective_orders_from1x.rb.erb +0 -98
  147. data/db/upgrade/upgrade_price_column_on_table.rb.erb +0 -17
  148. data/lib/generators/effective_orders/upgrade_from03x_generator.rb +0 -31
  149. data/lib/generators/effective_orders/upgrade_from1x_generator.rb +0 -27
  150. data/lib/generators/effective_orders/upgrade_price_column_generator.rb +0 -30
@@ -46,6 +46,7 @@ ActiveRecord::Schema.define(:version => 4) do
46
46
 
47
47
  create_table "carts", :force => true do |t|
48
48
  t.integer "user_id"
49
+ t.integer "cart_items_count"
49
50
  t.datetime "created_at", :null => false
50
51
  t.datetime "updated_at", :null => false
51
52
  end
Binary file
@@ -55,3 +55,6 @@
55
55
   (0.2ms) SELECT MAX("orders"."id") FROM "orders"
56
56
   (0.1ms) SELECT MAX("orders"."id") FROM "orders"
57
57
   (0.1ms) SELECT MAX("orders"."id") FROM "orders"
58
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
59
+  (0.2ms) SELECT MAX("orders"."id") FROM "orders"
60
+  (0.1ms) SELECT MAX("orders"."id") FROM "orders"
@@ -55,32 +55,6 @@ describe Product do
55
55
  end
56
56
  end
57
57
 
58
- describe 'float prices' do
59
- it 'should automatically convert float prices to integer' do
60
- product_with_float_price.price = 20.00
61
- product_with_float_price.tax_exempt = true
62
-
63
- order = Effective::Order.new(product_with_float_price, user: user)
64
- order.billing_address = FactoryGirl.create(:address, state_code: 'AB')
65
-
66
- order.subtotal.should eq 2000
67
- order.tax.should eq 0
68
- order.total.should eq 2000
69
- end
70
-
71
- it 'should automatically convert tax floats to integers' do
72
- product_with_float_price.price = 20.00
73
- product_with_float_price.tax_exempt = false
74
-
75
- order = Effective::Order.new(product_with_float_price, user: user)
76
- order.billing_address = FactoryGirl.create(:address, state_code: 'AB')
77
-
78
- order.subtotal.should eq 2000
79
- order.tax.should eq 100
80
- order.total.should eq 2100
81
- end
82
- end
83
-
84
58
  describe 'price=' do
85
59
  it 'should accept an integer price' do
86
60
  product = Product.new()
@@ -96,36 +70,6 @@ describe Product do
96
70
  product.price.should eq 1250
97
71
  end
98
72
 
99
- it 'should convert a String that looks like a Float' do
100
- product = Product.new()
101
- product.price = '12.50'
102
-
103
- product.price.should eq 1250
104
- end
105
-
106
- it 'should convert from a Float' do
107
- product = Product.new()
108
- product.price = 12.50
109
- product.price.should eq 1250
110
-
111
- product.price = Float(12.50)
112
- product.price.should eq 1250
113
- end
114
-
115
- it 'should convert from a BigDecimal' do
116
- product = Product.new()
117
- product.price = BigDecimal.new(12.5, 4)
118
-
119
- product.price.should eq 1250
120
- end
121
-
122
- it 'should treat nil as a zero' do
123
- product = Product.new()
124
- product.price = nil
125
-
126
- product.price.should eq 0
127
- end
128
-
129
73
  end
130
74
 
131
75
  end
@@ -7,9 +7,9 @@ describe Effective::Customer do
7
7
  let(:customer) { FactoryGirl.create(:customer) }
8
8
  let(:user) { FactoryGirl.create(:user) }
9
9
 
10
- describe 'Customer.for_user' do
10
+ describe 'Customer.for' do
11
11
  it 'creates a new Customer when passed a new user' do
12
- c = Effective::Customer.for_user(user)
12
+ c = Effective::Customer.for_buyer(user)
13
13
 
14
14
  c.kind_of?(Effective::Customer).should eq true
15
15
  c.persisted?.should eq true
@@ -18,7 +18,7 @@ describe Effective::Customer do
18
18
  end
19
19
 
20
20
  it 'returns an existing Customer when passed an existing user' do
21
- c = Effective::Customer.for_user(customer.user)
21
+ c = Effective::Customer.for_buyer(customer.user)
22
22
  c.should eq customer
23
23
  end
24
24
  end
@@ -47,8 +47,8 @@ describe Effective::Order, type: :model do
47
47
  order_item.quantity.should eq 1
48
48
  end
49
49
 
50
- it 'throws an ArgumentError when passed something unexpected' do
51
- expect { Effective::Order.new(Object.new()) }.to raise_error(ArgumentError)
50
+ it 'throws an Exception when passed something unexpected' do
51
+ expect { Effective::Order.new(Object.new()) }.to raise_error(Exception)
52
52
  end
53
53
  end
54
54
 
data/spec/spec_helper.rb CHANGED
@@ -15,7 +15,7 @@ Dir[Rails.root.join("../../spec/support/**/*.rb")].each {|f| require f }
15
15
  RSpec.configure do |config|
16
16
  config.fixture_path = "#{::Rails.root}/spec/fixtures"
17
17
 
18
- config.include Devise::TestHelpers, :type => :controller
18
+ config.include Devise::Test::ControllerHelpers, :type => :controller
19
19
  config.include Shoulda::Matchers::ActiveModel, :type => :model
20
20
 
21
21
  Rails.logger.level = 4 # Output only minimal stuff to test.log
@@ -51,9 +51,10 @@ FactoryGirl.define do
51
51
 
52
52
  factory :cart, class: Effective::Cart do
53
53
  association :user
54
+ cart_items_count 0
54
55
 
55
56
  before(:create) do |cart|
56
- 3.times { cart.cart_items << FactoryGirl.create(:cart_item, cart: cart) }
57
+ 3.times { cart.cart_items << FactoryGirl.build(:cart_item, cart: cart) }
57
58
  end
58
59
  end
59
60
 
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: 2.2.4
4
+ version: 3.0.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: 2017-06-08 00:00:00.000000000 Z
11
+ date: 2018-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: jquery-rails
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: devise
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +53,7 @@ dependencies:
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
- name: sass-rails
56
+ name: jquery-rails
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="
@@ -81,7 +67,7 @@ dependencies:
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
- name: simple_form
70
+ name: sass-rails
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - ">="
@@ -114,14 +100,14 @@ dependencies:
114
100
  requirements:
115
101
  - - ">="
116
102
  - !ruby/object:Gem::Version
117
- version: 2.0.0
103
+ version: 3.0.0
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
108
  - - ">="
123
109
  - !ruby/object:Gem::Version
124
- version: 2.0.0
110
+ version: 3.0.0
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: stripe-ruby-mock
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -259,29 +245,32 @@ files:
259
245
  - MIT-LICENSE
260
246
  - README.md
261
247
  - Rakefile
262
- - active_admin/effective_carts.rb
263
- - active_admin/effective_orders.rb
264
248
  - app/assets/images/effective_orders/stripe_connect.png
265
249
  - app/assets/javascripts/effective_orders.js
266
- - app/assets/javascripts/effective_orders/providers/stripe_charges.js.coffee
267
- - app/assets/javascripts/effective_orders/providers/stripe_subscriptions.js.coffee
250
+ - app/assets/javascripts/effective_orders/customers.js.coffee
251
+ - app/assets/javascripts/effective_orders/providers/stripe.js.coffee
252
+ - app/assets/javascripts/effective_orders/subscriptions.js.coffee
268
253
  - app/assets/stylesheets/effective_orders.scss
269
254
  - app/assets/stylesheets/effective_orders/_order.scss
255
+ - app/assets/stylesheets/effective_orders/_subscriptions.scss
270
256
  - app/controllers/admin/customers_controller.rb
271
257
  - app/controllers/admin/order_items_controller.rb
272
258
  - app/controllers/admin/orders_controller.rb
273
- - app/controllers/concerns/acts_as_active_admin_controller.rb
274
259
  - app/controllers/effective/carts_controller.rb
260
+ - app/controllers/effective/concerns/purchase.rb
261
+ - app/controllers/effective/customers_controller.rb
275
262
  - app/controllers/effective/orders_controller.rb
276
263
  - app/controllers/effective/providers/app_checkout.rb
277
264
  - app/controllers/effective/providers/ccbill.rb
278
265
  - app/controllers/effective/providers/cheque.rb
266
+ - app/controllers/effective/providers/free.rb
267
+ - app/controllers/effective/providers/mark_as_paid.rb
279
268
  - app/controllers/effective/providers/moneris.rb
280
269
  - app/controllers/effective/providers/paypal.rb
281
270
  - app/controllers/effective/providers/pretend.rb
271
+ - app/controllers/effective/providers/refund.rb
282
272
  - app/controllers/effective/providers/stripe.rb
283
273
  - app/controllers/effective/providers/stripe_connect.rb
284
- - app/controllers/effective/subscriptions_controller.rb
285
274
  - app/controllers/effective/webhooks_controller.rb
286
275
  - app/datatables/effective_customers_datatable.rb
287
276
  - app/datatables/effective_order_items_datatable.rb
@@ -291,45 +280,44 @@ files:
291
280
  - app/helpers/effective_orders_helper.rb
292
281
  - app/helpers/effective_paypal_helper.rb
293
282
  - app/helpers/effective_stripe_helper.rb
283
+ - app/helpers/effective_subscriptions_helper.rb
294
284
  - app/mailers/effective/orders_mailer.rb
295
285
  - app/models/concerns/acts_as_purchasable.rb
286
+ - app/models/concerns/acts_as_subscribable.rb
287
+ - app/models/concerns/acts_as_subscribable_buyer.rb
296
288
  - app/models/effective/access_denied.rb
297
289
  - app/models/effective/cart.rb
298
290
  - app/models/effective/cart_item.rb
299
291
  - app/models/effective/customer.rb
300
- - app/models/effective/datatables/customers.rb
301
- - app/models/effective/datatables/order_items.rb
302
- - app/models/effective/datatables/orders.rb
303
292
  - app/models/effective/order.rb
304
293
  - app/models/effective/order_item.rb
305
294
  - app/models/effective/product.rb
306
295
  - app/models/effective/providers/ccbill_postback.rb
307
296
  - app/models/effective/providers/stripe_charge.rb
297
+ - app/models/effective/subscripter.rb
308
298
  - app/models/effective/subscription.rb
309
299
  - app/models/effective/tax_rate_calculator.rb
310
- - app/models/inputs/price_field.rb
311
- - app/models/inputs/price_form_input.rb
312
- - app/models/inputs/price_formtastic_input.rb
313
- - app/models/inputs/price_input.rb
314
- - app/models/inputs/price_simple_form_input.rb
315
300
  - app/models/validators/effective/sold_out_validator.rb
316
301
  - app/views/admin/customers/_actions.html.haml
317
302
  - app/views/admin/customers/index.html.haml
303
+ - app/views/admin/customers/show.html.haml
318
304
  - app/views/admin/order_items/index.html.haml
319
305
  - app/views/admin/orders/_actions.html.haml
320
306
  - app/views/admin/orders/_form.html.haml
321
- - app/views/admin/orders/_form_mark_as_paid.html.haml
322
307
  - app/views/admin/orders/_form_note_internal.html.haml
323
308
  - app/views/admin/orders/_order_actions.html.haml
324
309
  - app/views/admin/orders/_order_item_fields.html.haml
325
- - app/views/admin/orders/_order_payment_details.html.haml
310
+ - app/views/admin/orders/edit.html.haml
326
311
  - app/views/admin/orders/index.html.haml
327
- - app/views/admin/orders/mark_as_paid.html.haml
328
312
  - app/views/admin/orders/new.html.haml
329
313
  - app/views/admin/orders/show.html.haml
330
314
  - app/views/effective/carts/_cart.html.haml
331
315
  - app/views/effective/carts/_cart_actions.html.haml
332
316
  - app/views/effective/carts/show.html.haml
317
+ - app/views/effective/customers/_customer.html.haml
318
+ - app/views/effective/customers/_fields.html.haml
319
+ - app/views/effective/customers/_form.html.haml
320
+ - app/views/effective/customers/edit.html.haml
333
321
  - app/views/effective/orders/_checkout_step1.html.haml
334
322
  - app/views/effective/orders/_checkout_step2.html.haml
335
323
  - app/views/effective/orders/_order.html.haml
@@ -347,45 +335,45 @@ files:
347
335
  - app/views/effective/orders/_orders_table.html.haml
348
336
  - app/views/effective/orders/app_checkout/_form.html.haml
349
337
  - app/views/effective/orders/ccbill/_form.html.haml
350
- - app/views/effective/orders/checkout_step1.html.haml
351
- - app/views/effective/orders/checkout_step2.html.haml
352
338
  - app/views/effective/orders/cheque/_form.html.haml
353
339
  - app/views/effective/orders/cheque/pay_by_cheque.html.haml
354
340
  - app/views/effective/orders/declined.html.haml
341
+ - app/views/effective/orders/edit.html.haml
342
+ - app/views/effective/orders/free/_form.html.haml
355
343
  - app/views/effective/orders/index.html.haml
344
+ - app/views/effective/orders/mark_as_paid/_form.html.haml
356
345
  - app/views/effective/orders/moneris/_form.html.haml
357
346
  - app/views/effective/orders/my_purchases.html.haml
358
347
  - app/views/effective/orders/my_sales.html.haml
348
+ - app/views/effective/orders/new.html.haml
359
349
  - app/views/effective/orders/paypal/_form.html.haml
360
350
  - app/views/effective/orders/pretend/_form.html.haml
361
351
  - app/views/effective/orders/purchased.html.haml
352
+ - app/views/effective/orders/refund/_form.html.haml
362
353
  - app/views/effective/orders/show.html.haml
363
354
  - app/views/effective/orders/stripe/_form.html.haml
364
- - app/views/effective/orders/stripe/_subscription_fields.html.haml
365
355
  - app/views/effective/orders_mailer/order_error.html.haml
366
356
  - app/views/effective/orders_mailer/order_receipt_to_admin.html.haml
367
357
  - app/views/effective/orders_mailer/order_receipt_to_buyer.html.haml
368
358
  - app/views/effective/orders_mailer/order_receipt_to_seller.html.haml
369
359
  - app/views/effective/orders_mailer/payment_request_to_buyer.html.haml
370
360
  - app/views/effective/orders_mailer/pending_order_invoice_to_buyer.html.haml
371
- - app/views/effective/subscriptions/index.html.haml
372
- - app/views/effective/subscriptions/new.html.haml
373
- - app/views/effective/subscriptions/show.html.haml
361
+ - app/views/effective/orders_mailer/subscription_canceled.html.haml
362
+ - app/views/effective/orders_mailer/subscription_payment_failed.html.haml
363
+ - app/views/effective/orders_mailer/subscription_payment_succeeded.html.haml
364
+ - app/views/effective/orders_mailer/subscription_trial_expired.html.haml
365
+ - app/views/effective/orders_mailer/subscription_trial_expiring.html.haml
366
+ - app/views/effective/subscriptions/_fields.html.haml
367
+ - app/views/effective/subscriptions/_plan.html.haml
374
368
  - app/views/layouts/effective_orders_mailer_layout.html.haml
375
369
  - config/effective_orders.rb
376
370
  - config/routes.rb
377
371
  - db/migrate/01_create_effective_orders.rb.erb
378
- - db/upgrade/02_upgrade_effective_orders_from03x.rb.erb
379
- - db/upgrade/03_upgrade_effective_orders_from1x.rb.erb
380
- - db/upgrade/upgrade_price_column_on_table.rb.erb
381
372
  - lib/effective_orders.rb
382
373
  - lib/effective_orders/app_checkout_service.rb
383
374
  - lib/effective_orders/engine.rb
384
375
  - lib/effective_orders/version.rb
385
376
  - lib/generators/effective_orders/install_generator.rb
386
- - lib/generators/effective_orders/upgrade_from03x_generator.rb
387
- - lib/generators/effective_orders/upgrade_from1x_generator.rb
388
- - lib/generators/effective_orders/upgrade_price_column_generator.rb
389
377
  - lib/generators/templates/effective_orders_mailer_preview.rb
390
378
  - lib/tasks/effective_orders_tasks.rake
391
379
  - spec/controllers/admin/orders_controller_spec.rb
@@ -1,14 +0,0 @@
1
- if defined?(ActiveAdmin)
2
- ActiveAdmin.register Effective::Cart, namespace: EffectiveOrders.active_admin_namespace, as: 'Carts' do
3
- menu label: 'My Cart', if: proc { (authorized?(:manage, Effective::Cart.new(user: current_user)) rescue false) }
4
-
5
- actions :index
6
-
7
- controller do
8
- def index
9
- redirect_to(effective_orders.cart_path)
10
- end
11
- end
12
-
13
- end
14
- end
@@ -1,112 +0,0 @@
1
- if defined?(ActiveAdmin)
2
- require 'csv'
3
-
4
- ActiveAdmin.register Effective::Order, namespace: EffectiveOrders.active_admin_namespace, as: 'Orders' do
5
- menu label: 'Orders', if: proc { (authorized?(:manage, Effective::Order.new(user: current_user)) rescue false) }
6
-
7
- actions :index
8
-
9
- filter :id, label: 'Order Number'
10
- filter :user
11
- filter :created_at, label: 'Order Date'
12
- filter :payment
13
-
14
- scope :purchased, default: true do |objs| objs.purchased end
15
- scope :all
16
-
17
- controller do
18
- include EffectiveOrdersHelper
19
-
20
- def scoped_collection
21
- scoped = end_of_association_chain.includes(:user).includes(order_items: :purchasable)
22
-
23
- if EffectiveOrders.orders_collection_scope.respond_to?(:call)
24
- scoped = EffectiveOrders.orders_collection_scope.call(scoped)
25
- end
26
-
27
- scoped = scoped.where(user: current_user) if !authorized?(:admin, :effective_orders)
28
- scoped
29
- end
30
- end
31
-
32
- sidebar :export, :only => :index do
33
- export_csv_path = ['export_csv', EffectiveOrders.active_admin_namespace.presence, 'orders_path'].compact.join('_')
34
- link_to "Export Orders to .csv", public_send(export_csv_path)
35
- end
36
-
37
- index :download_links => false do
38
- column :purchased_at
39
-
40
- column 'Order', :sortable => :id do |order|
41
- link_to "##{order.to_param}", effective_orders.order_path(order)
42
- end
43
-
44
- column 'Buyer Email' do |order|
45
- mail_to order.user.email
46
- end
47
-
48
- column 'Buyer Name', :sortable => :user_id do |order|
49
- user_path = [EffectiveOrders.active_admin_namespace.presence, 'user_path'].compact.join('_')
50
- link_to order.user, (public_send(user_path, order.user) rescue '#')
51
- end
52
-
53
- column 'Order Items' do |order|
54
- content_tag(:ul) do
55
- (order.order_items).map { |oi| content_tag(:li, oi.to_s.html_safe) }.join.html_safe
56
- end
57
- end
58
-
59
- column 'Total' do |order|
60
- price_to_currency(order.total)
61
- end
62
-
63
- column :payment_provider do |order|
64
- order.payment_provider
65
- end
66
-
67
- column :payment_card do |order|
68
- order.payment_card
69
- end
70
-
71
- column do |order|
72
- link_to('View Receipt', effective_orders.order_path(order), class: 'member_link view_link') if order.purchased?
73
- end
74
-
75
- end
76
-
77
- collection_action :export_csv do
78
- @orders = Effective::Order.purchased.includes(:addresses)
79
-
80
- col_headers = []
81
- col_headers << "Order"
82
- col_headers << "Purchased at"
83
- col_headers << "Email"
84
- col_headers << "Full Name"
85
- col_headers << "Subtotal"
86
- col_headers << "Tax"
87
- col_headers << "Total"
88
- col_headers << 'Payment provider'
89
- col_headers << 'Payment card'
90
-
91
- csv_string = CSV.generate do |csv|
92
- csv << col_headers
93
-
94
- @orders.each do |order|
95
- csv << [
96
- order.to_param,
97
- order.purchased_at.strftime("%Y-%m-%d %H:%M:%S %z"),
98
- order.user.try(:email),
99
- (order.try(:billing_address).try(:full_name) || order.user.to_s),
100
- (order.subtotal / 100.0).round(2),
101
- (order.tax / 100.0).round(2),
102
- (order.total / 100.0).round(2),
103
- order.payment_provider,
104
- order.payment_card
105
- ]
106
- end
107
- end
108
-
109
- send_data(csv_string, :type => 'text/csv; charset=utf-8; header=present', :filename => "orders-export.csv")
110
- end
111
- end
112
- end