effective_orders 1.8.1 → 2.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 (115) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +150 -60
  4. data/Rakefile +0 -3
  5. data/active_admin/effective_orders.rb +14 -9
  6. data/app/assets/javascripts/effective_orders.js +2 -0
  7. data/app/assets/javascripts/effective_orders/{stripe_charges.js.coffee → providers/stripe_charges.js.coffee} +1 -1
  8. data/app/assets/javascripts/effective_orders/{stripe_subscriptions.js.coffee → providers/stripe_subscriptions.js.coffee} +1 -1
  9. data/app/assets/stylesheets/effective_orders/_order.scss +9 -3
  10. data/app/controllers/admin/orders_controller.rb +87 -3
  11. data/app/controllers/concerns/acts_as_active_admin_controller.rb +2 -1
  12. data/app/controllers/effective/carts_controller.rb +4 -2
  13. data/app/controllers/effective/orders_controller.rb +101 -60
  14. data/app/controllers/effective/providers/app_checkout.rb +10 -2
  15. data/app/controllers/effective/providers/ccbill.rb +34 -0
  16. data/app/controllers/effective/providers/cheque.rb +30 -0
  17. data/app/controllers/effective/providers/moneris.rb +7 -7
  18. data/app/controllers/effective/providers/paypal.rb +7 -5
  19. data/app/controllers/effective/providers/pretend.rb +22 -0
  20. data/app/controllers/effective/providers/stripe.rb +26 -24
  21. data/app/controllers/effective/webhooks_controller.rb +1 -1
  22. data/app/helpers/effective_carts_helper.rb +59 -29
  23. data/app/helpers/effective_ccbill_helper.rb +25 -0
  24. data/app/helpers/effective_orders_helper.rb +50 -41
  25. data/app/helpers/effective_paypal_helper.rb +11 -11
  26. data/app/mailers/effective/orders_mailer.rb +95 -20
  27. data/app/models/concerns/acts_as_purchasable.rb +14 -22
  28. data/app/models/effective/cart.rb +9 -15
  29. data/app/models/effective/cart_item.rb +15 -13
  30. data/app/models/effective/customer.rb +9 -9
  31. data/app/models/effective/datatables/order_items.rb +14 -8
  32. data/app/models/effective/datatables/orders.rb +56 -69
  33. data/app/models/effective/order.rb +250 -139
  34. data/app/models/effective/order_item.rb +23 -16
  35. data/app/models/effective/product.rb +23 -0
  36. data/app/models/effective/providers/ccbill_postback.rb +85 -0
  37. data/app/models/effective/{stripe_charge.rb → providers/stripe_charge.rb} +1 -1
  38. data/app/models/effective/subscription.rb +16 -12
  39. data/app/models/effective/tax_rate_calculator.rb +45 -0
  40. data/app/views/admin/customers/index.html.haml +2 -5
  41. data/app/views/admin/order_items/index.html.haml +2 -5
  42. data/app/views/admin/orders/_actions.html.haml +2 -0
  43. data/app/views/admin/orders/_form.html.haml +28 -0
  44. data/app/views/admin/orders/_order_item_fields.html.haml +9 -0
  45. data/app/views/admin/orders/index.html.haml +9 -5
  46. data/app/views/admin/orders/new.html.haml +3 -0
  47. data/app/views/effective/carts/_cart.html.haml +3 -12
  48. data/app/views/effective/carts/_cart_actions.html.haml +4 -0
  49. data/app/views/effective/carts/show.html.haml +10 -12
  50. data/app/views/effective/orders/_checkout_step1.html.haml +46 -0
  51. data/app/views/effective/orders/_checkout_step2.html.haml +33 -0
  52. data/app/views/effective/orders/_order.html.haml +2 -0
  53. data/app/views/effective/orders/_order_actions.html.haml +10 -5
  54. data/app/views/effective/orders/_order_footer.html.haml +1 -0
  55. data/app/views/effective/orders/_order_items.html.haml +11 -9
  56. data/app/views/effective/orders/_order_note.html.haml +8 -0
  57. data/app/views/effective/orders/_order_note_fields.html.haml +5 -0
  58. data/app/views/effective/orders/_order_shipping.html.haml +4 -4
  59. data/app/views/effective/orders/_order_user_fields.html.haml +1 -0
  60. data/app/views/effective/orders/_orders_table.html.haml +27 -0
  61. data/app/views/effective/orders/ccbill/_form.html.haml +24 -0
  62. data/app/views/effective/orders/checkout_step1.html.haml +3 -0
  63. data/app/views/effective/orders/checkout_step2.html.haml +3 -0
  64. data/app/views/effective/orders/cheque/_form.html.haml +2 -0
  65. data/app/views/effective/orders/cheque/pay_by_cheque.html.haml +9 -0
  66. data/app/views/effective/orders/declined.html.haml +4 -2
  67. data/app/views/effective/orders/my_purchases.html.haml +1 -1
  68. data/app/views/effective/orders/my_sales.html.haml +1 -1
  69. data/app/views/effective/orders/purchased.html.haml +3 -2
  70. data/app/views/effective/orders/show.html.haml +1 -1
  71. data/app/views/effective/orders/stripe/_form.html.haml +5 -5
  72. data/app/views/effective/orders_mailer/order_error.html.haml +11 -0
  73. data/app/views/effective/orders_mailer/payment_request_to_buyer.html.haml +13 -0
  74. data/app/views/effective/orders_mailer/pending_order_invoice_to_buyer.html.haml +13 -0
  75. data/app/views/layouts/effective_orders_mailer_layout.html.haml +7 -7
  76. data/config/routes.rb +39 -24
  77. data/db/migrate/01_create_effective_orders.rb.erb +20 -1
  78. data/db/upgrade/03_upgrade_effective_orders_from1x.rb.erb +95 -0
  79. data/lib/effective_orders.rb +67 -9
  80. data/lib/effective_orders/app_checkout_service.rb +1 -2
  81. data/lib/effective_orders/engine.rb +46 -14
  82. data/lib/effective_orders/version.rb +1 -1
  83. data/lib/generators/effective_orders/install_generator.rb +1 -0
  84. data/lib/generators/effective_orders/upgrade_from03x_generator.rb +1 -0
  85. data/lib/generators/effective_orders/upgrade_from1x_generator.rb +31 -0
  86. data/lib/generators/templates/effective_orders.rb +131 -66
  87. data/lib/generators/templates/effective_orders_mailer_preview.rb +28 -13
  88. data/spec/controllers/admin/orders_controller_spec.rb +242 -0
  89. data/spec/controllers/ccbill_orders_controller_spec.rb +103 -0
  90. data/spec/controllers/moneris_orders_controller_spec.rb +23 -23
  91. data/spec/controllers/orders_controller_spec.rb +167 -79
  92. data/spec/controllers/stripe_orders_controller_spec.rb +7 -7
  93. data/spec/dummy/app/models/product.rb +0 -8
  94. data/spec/dummy/app/models/product_with_float_price.rb +0 -8
  95. data/spec/dummy/app/models/user.rb +2 -19
  96. data/spec/dummy/config/application.rb +2 -1
  97. data/spec/dummy/config/environments/test.rb +1 -0
  98. data/spec/dummy/config/initializers/effective_orders.rb +109 -64
  99. data/spec/dummy/db/schema.rb +15 -2
  100. data/spec/dummy/db/test.sqlite3 +0 -0
  101. data/spec/dummy/log/test.log +0 -258
  102. data/spec/models/acts_as_purchasable_spec.rb +8 -6
  103. data/spec/models/factories_spec.rb +7 -1
  104. data/spec/models/order_item_spec.rb +1 -1
  105. data/spec/models/order_spec.rb +165 -46
  106. data/spec/models/stripe_charge_spec.rb +5 -5
  107. data/spec/spec_helper.rb +2 -0
  108. data/spec/support/factories.rb +49 -33
  109. metadata +47 -64
  110. data/app/views/effective/orders/_checkout_step_1.html.haml +0 -43
  111. data/app/views/effective/orders/_checkout_step_2.html.haml +0 -25
  112. data/app/views/effective/orders/_my_purchases.html.haml +0 -17
  113. data/app/views/effective/orders/checkout.html.haml +0 -3
  114. data/app/views/effective/orders/new.html.haml +0 -4
  115. data/spec/dummy/log/development.log +0 -82
@@ -1,43 +0,0 @@
1
- .effective-order
2
- = simple_form_for(order, (EffectiveOrders.simple_form_options || {}).merge(:url => effective_orders.orders_path)) do |f|
3
- = render :partial => 'effective/orders/order_items', :locals => {:order => order, :form => f}
4
-
5
- - if order.errors[:order_items].present?
6
- %p.inline-errors= order.errors[:order_items].first
7
-
8
- - if order.errors[:total].present?
9
- %p.inline-errors= order.errors[:total].first.gsub(EffectiveOrders.minimum_charge.to_i.to_s, price_to_currency(EffectiveOrders.minimum_charge.to_i))
10
-
11
- - if EffectiveOrders.collect_user_fields.present? && (f.object.user rescue nil).present?
12
- %h3 User Information
13
- = render :partial => 'effective/orders/order_user_fields', :locals => {:form => f, :user => f.object.user }
14
-
15
- - num_addresses = [EffectiveOrders.require_billing_address, EffectiveOrders.require_shipping_address].count(true)
16
-
17
- - if num_addresses > 0
18
- .row
19
- - if EffectiveOrders.require_billing_address
20
- %div{:class => "col-sm-#{12 / num_addresses}"}
21
- %h3 Billing Address
22
- = effective_address_fields(f, :billing_address)
23
- - if order.save_billing_address != nil
24
- = f.input :save_billing_address, :as => :boolean, :label => 'Save as my default Billing Address'
25
-
26
- - if EffectiveOrders.require_shipping_address
27
- %div{:class => "col-sm-#{12 / num_addresses}"}
28
- %h3 Shipping Address
29
- - if EffectiveOrders.require_billing_address && EffectiveOrders.require_shipping_address
30
- .shipping_address_fields{:style => (f.object.shipping_address_same_as_billing? && (f.object.errors[:shipping_address] || []).blank?) ? 'display: none;' : 'display: block;'}
31
- = effective_address_fields(f, :shipping_address)
32
- - if order.save_shipping_address != nil
33
- = f.input :save_shipping_address, :as => :boolean, :label => 'Save as my default Shipping Address'
34
-
35
- = f.input :shipping_address_same_as_billing, :as => :boolean, :label => 'My Shipping address is the same as my Billing address'
36
-
37
- = link_to_current_cart :label => 'Change Items', :class => 'btn btn-default'
38
-
39
- .text-right
40
- - if order.total == 0 && EffectiveOrders.allow_free_orders
41
- = f.submit order_checkout_label(:free), :class => 'btn btn-primary pull-right', :rel => :nofollow, :data => {'disable_with' => 'Processing...' }
42
- - else
43
- = f.submit 'Save and Continue', :class => 'btn btn-primary pull-right', :rel => :nofollow, :data => {'disable_with' => 'Saving...' }
@@ -1,25 +0,0 @@
1
- = render order
2
-
3
- .effective-order.effective-order-purchase-actions
4
- - if (Rails.env.production? == false && EffectiveOrders.allow_pretend_purchase_in_development)
5
- = render :partial => '/effective/orders/pretend/form', locals: {order: order, purchased_redirect_url: purchased_redirect_url, declined_redirect_url: declined_redirect_url}
6
-
7
- - if (Rails.env.production? == true && EffectiveOrders.allow_pretend_purchase_in_production)
8
- = render :partial => '/effective/orders/pretend/form', locals: {order: order, purchased_redirect_url: purchased_redirect_url, declined_redirect_url: declined_redirect_url}
9
-
10
- - if EffectiveOrders.moneris_enabled
11
- = render :partial => '/effective/orders/moneris/form', locals: {order: order, purchased_redirect_url: purchased_redirect_url, declined_redirect_url: declined_redirect_url}
12
-
13
- - if EffectiveOrders.paypal_enabled
14
- = render :partial => '/effective/orders/paypal/form', locals: {order: order}
15
-
16
- - if EffectiveOrders.stripe_enabled
17
- = render :partial => '/effective/orders/stripe/form', locals: {order: order}
18
-
19
- - if EffectiveOrders.authorized?(controller, :app_checkout, order)
20
- - if EffectiveOrders.app_checkout_enabled
21
- = render :partial => '/effective/orders/app_checkout/form', locals: {order: order}
22
-
23
- - if (Rails.env.production? == true && EffectiveOrders.allow_pretend_purchase_in_production)
24
- %p= EffectiveOrders.allow_pretend_purchase_in_production_message
25
-
@@ -1,17 +0,0 @@
1
- %table.table
2
- %thead
3
- %tr
4
- %th Order
5
- %th Date of Purchase
6
- %th Description
7
- %th
8
- %tbody
9
- - orders.each do |order|
10
- %tr
11
- %td= order.to_param
12
- %td= order.purchased_at.strftime("%Y-%m-%d %H:%M")
13
- %td= order_summary(order)
14
- %td= link_to 'View', order_path.gsub(':id', order.to_param)
15
-
16
- - unless orders.present?
17
- %p You have no purchased orders
@@ -1,3 +0,0 @@
1
- %h2.effective-orders-page-title Checkout
2
-
3
- = render_checkout(@order)
@@ -1,4 +0,0 @@
1
- %h2.effective-orders-page-title Checkout
2
-
3
- = render_checkout(@order)
4
-
@@ -1,82 +0,0 @@
1
-  (1.2ms) CREATE TABLE "addresses" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "addressable_type" varchar, "addressable_id" integer, "category" varchar(64), "full_name" varchar, "address1" varchar, "address2" varchar, "city" varchar, "state_code" varchar, "country_code" varchar, "postal_code" varchar, "updated_at" datetime, "created_at" datetime) 
2
-  (0.1ms) select sqlite_version(*)
3
-  (0.8ms) CREATE INDEX "index_addresses_on_addressable_id" ON "addresses" ("addressable_id")
4
-  (0.2ms) SELECT sql
5
- FROM sqlite_master
6
- WHERE name='index_addresses_on_addressable_id' AND type='index'
7
- UNION ALL
8
- SELECT sql
9
- FROM sqlite_temp_master
10
- WHERE name='index_addresses_on_addressable_id' AND type='index'
11
-
12
-  (0.9ms) CREATE INDEX "index_addresses_on_addressable_type_and_addressable_id" ON "addresses" ("addressable_type", "addressable_id")
13
-  (1.0ms) CREATE TABLE "cart_items" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "cart_id" integer, "purchasable_type" varchar, "purchasable_id" integer, "quantity" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
14
-  (1.0ms) CREATE INDEX "index_cart_items_on_cart_id" ON "cart_items" ("cart_id")
15
-  (0.1ms) SELECT sql
16
- FROM sqlite_master
17
- WHERE name='index_cart_items_on_cart_id' AND type='index'
18
- UNION ALL
19
- SELECT sql
20
- FROM sqlite_temp_master
21
- WHERE name='index_cart_items_on_cart_id' AND type='index'
22
-
23
-  (1.0ms) CREATE INDEX "index_cart_items_on_purchasable_id" ON "cart_items" ("purchasable_id")
24
-  (0.1ms) SELECT sql
25
- FROM sqlite_master
26
- WHERE name='index_cart_items_on_purchasable_id' AND type='index'
27
- UNION ALL
28
- SELECT sql
29
- FROM sqlite_temp_master
30
- WHERE name='index_cart_items_on_purchasable_id' AND type='index'
31
-
32
-  (0.1ms)  SELECT sql
33
- FROM sqlite_master
34
- WHERE name='index_cart_items_on_cart_id' AND type='index'
35
- UNION ALL
36
- SELECT sql
37
- FROM sqlite_temp_master
38
- WHERE name='index_cart_items_on_cart_id' AND type='index'
39
- 
40
-  (1.0ms) CREATE INDEX "index_cart_items_on_purchasable_type_and_purchasable_id" ON "cart_items" ("purchasable_type", "purchasable_id")
41
-  (0.9ms) CREATE TABLE "carts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
42
-  (0.8ms) CREATE INDEX "index_carts_on_user_id" ON "carts" ("user_id")
43
-  (0.9ms) CREATE TABLE "custom_products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "price" integer DEFAULT 0, "tax_exempt" boolean, "created_at" datetime, "updated_at" datetime) 
44
-  (1.0ms) CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "stripe_customer_id" varchar, "stripe_active_card" varchar, "stripe_connect_access_token" varchar, "created_at" datetime, "updated_at" datetime)
45
-  (1.0ms) CREATE TABLE "order_items" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order_id" integer, "seller_id" integer, "purchasable_type" varchar, "purchasable_id" integer, "title" varchar, "quantity" integer, "price" integer DEFAULT 0, "tax_exempt" boolean, "tax_rate" decimal(5,3) DEFAULT 0.0, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
46
-  (0.9ms) CREATE INDEX "index_order_items_on_order_id" ON "order_items" ("order_id")
47
-  (0.1ms)  SELECT sql
48
- FROM sqlite_master
49
- WHERE name='index_order_items_on_order_id' AND type='index'
50
- UNION ALL
51
- SELECT sql
52
- FROM sqlite_temp_master
53
- WHERE name='index_order_items_on_order_id' AND type='index'
54
- 
55
-  (0.9ms) CREATE INDEX "index_order_items_on_purchasable_id" ON "order_items" ("purchasable_id")
56
-  (0.1ms)  SELECT sql
57
- FROM sqlite_master
58
- WHERE name='index_order_items_on_purchasable_id' AND type='index'
59
- UNION ALL
60
- SELECT sql
61
- FROM sqlite_temp_master
62
- WHERE name='index_order_items_on_purchasable_id' AND type='index'
63
- 
64
-  (0.1ms) SELECT sql
65
- FROM sqlite_master
66
- WHERE name='index_order_items_on_order_id' AND type='index'
67
- UNION ALL
68
- SELECT sql
69
- FROM sqlite_temp_master
70
- WHERE name='index_order_items_on_order_id' AND type='index'
71
-
72
-  (0.9ms) CREATE INDEX "index_order_items_on_purchasable_type_and_purchasable_id" ON "order_items" ("purchasable_type", "purchasable_id")
73
-  (0.9ms) CREATE TABLE "orders" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "purchase_state" varchar, "purchased_at" datetime, "payment" text, "details" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "note" text)
74
-  (0.9ms) CREATE INDEX "index_orders_on_user_id" ON "orders" ("user_id")
75
-  (1.1ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "price" integer DEFAULT 0, "tax_exempt" boolean, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
76
-  (0.9ms) CREATE TABLE "product_with_float_prices" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "price" decimal DEFAULT 0, "tax_exempt" boolean, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
77
-  (1.0ms) CREATE TABLE "subscriptions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "customer_id" integer, "stripe_plan_id" varchar, "stripe_subscription_id" varchar, "stripe_coupon_id" varchar, "title" varchar, "price" integer DEFAULT 0, "created_at" datetime, "updated_at" datetime)
78
-  (1.1ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "encrypted_password" varchar, "reset_password_token" varchar, "reset_password_sent_at" datetime, "remember_created_at" datetime, "confirmation_sent_at" datetime, "confirmed_at" datetime, "confirmation_token" varchar, "unconfirmed_email" varchar, "sign_in_count" integer DEFAULT 0, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar, "last_sign_in_ip" varchar, "email" varchar, "roles_mask" integer DEFAULT 0, "archived" boolean DEFAULT 'f', "updated_at" datetime, "created_at" datetime) 
79
-  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
80
-  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
81
-  (0.1ms) SELECT version FROM "schema_migrations"
82
-  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('4')