effective_orders 6.7.2 → 6.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/effective_orders/_order.scss +1 -1
- data/app/models/effective/cart.rb +1 -1
- data/app/models/effective/cart_item.rb +1 -1
- data/app/models/effective/customer.rb +1 -1
- data/app/models/effective/order.rb +7 -7
- data/app/models/effective/order_item.rb +1 -1
- data/app/models/effective/product.rb +1 -1
- data/app/models/effective/subscription.rb +1 -1
- data/config/effective_orders.rb +0 -9
- data/config/routes.rb +1 -1
- data/db/migrate/{01_create_effective_orders.rb.erb → 101_create_effective_orders.rb} +21 -33
- data/lib/effective_orders/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f83eb44947b1c5f4f906f04822df9860f892727a02146f33e03eb468ffe65ea6
|
4
|
+
data.tar.gz: 726acb095ff327c25c438eacaec1db6cfa551207582a4d82a7a677e809b5087f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cc47f00733d0927470036ec6d9d2ef434945204426692ac26858e64a88d0b38e3a57396f64d2c1980152a8924d174cbd014dde7cc4245c2e8bcdf1922f7eb22
|
7
|
+
data.tar.gz: 3e6d4ee0aa861c39ec8f11e55879201908b3c6c62910e47631e69ab8662966eaef265e51906a8a954a806a7cec9020c13c6eb1123b26c11669d3c44137172cfc
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Effective
|
2
2
|
class Cart < ActiveRecord::Base
|
3
|
-
self.table_name = EffectiveOrders.carts_table_name.to_s
|
3
|
+
self.table_name = (EffectiveOrders.carts_table_name || :carts).to_s
|
4
4
|
|
5
5
|
belongs_to :user, polymorphic: true, optional: true # Optional. We want non-logged-in users to have carts too.
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Effective
|
2
2
|
class CartItem < ActiveRecord::Base
|
3
|
-
self.table_name = EffectiveOrders.cart_items_table_name.to_s
|
3
|
+
self.table_name = (EffectiveOrders.cart_items_table_name || :cart_items).to_s
|
4
4
|
|
5
5
|
belongs_to :cart, counter_cache: true
|
6
6
|
belongs_to :purchasable, polymorphic: true
|
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
module Effective
|
11
11
|
class Order < ActiveRecord::Base
|
12
|
-
self.table_name = EffectiveOrders.orders_table_name.to_s
|
12
|
+
self.table_name = (EffectiveOrders.orders_table_name || :orders).to_s
|
13
13
|
|
14
14
|
# Effective Resources
|
15
15
|
acts_as_statused(
|
@@ -201,13 +201,13 @@ module Effective
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
|
-
validate(if: -> { was_voided? }) do
|
205
|
-
errors.add(:status, "cannot update a voided order") unless
|
204
|
+
validate(if: -> { was_voided? && status_changed? }) do
|
205
|
+
errors.add(:status, "cannot update status of a voided order") unless voided?
|
206
206
|
end
|
207
207
|
|
208
208
|
# Sanity check
|
209
209
|
before_save(if: -> { status_was.to_s == 'purchased' }) do
|
210
|
-
raise('cannot unpurchase an order') unless purchased?
|
210
|
+
raise('cannot unpurchase an order. try voiding instead.') unless purchased? || voided?
|
211
211
|
|
212
212
|
raise('cannot change subtotal of a purchased order') if changes[:subtotal].present?
|
213
213
|
|
@@ -722,13 +722,13 @@ module Effective
|
|
722
722
|
end
|
723
723
|
|
724
724
|
def void!
|
725
|
-
raise('
|
726
|
-
voided!
|
725
|
+
raise('already voided') if voided?
|
726
|
+
voided!(skip_buyer_validations: true)
|
727
727
|
end
|
728
728
|
|
729
729
|
def unvoid!
|
730
730
|
raise('order must be voided to unvoid') unless voided?
|
731
|
-
|
731
|
+
unvoided!(skip_buyer_validations: true)
|
732
732
|
end
|
733
733
|
|
734
734
|
# These are all the emails we send all notifications to
|
data/config/effective_orders.rb
CHANGED
@@ -1,15 +1,6 @@
|
|
1
1
|
# EffectiveOrders Rails Engine
|
2
2
|
|
3
3
|
EffectiveOrders.setup do |config|
|
4
|
-
# Configure Database Tables
|
5
|
-
config.orders_table_name = :orders
|
6
|
-
config.order_items_table_name = :order_items
|
7
|
-
config.carts_table_name = :carts
|
8
|
-
config.cart_items_table_name = :cart_items
|
9
|
-
config.customers_table_name = :customers
|
10
|
-
config.subscriptions_table_name = :subscriptions
|
11
|
-
config.products_table_name = :products
|
12
|
-
|
13
4
|
# Layout Settings
|
14
5
|
# config.layout = { application: 'application', admin: 'admin' }
|
15
6
|
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
class CreateEffectiveOrders < ActiveRecord::Migration[
|
2
|
-
def
|
3
|
-
create_table
|
1
|
+
class CreateEffectiveOrders < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :orders do |t|
|
4
4
|
t.integer :user_id
|
5
5
|
t.string :user_type
|
6
6
|
|
@@ -43,10 +43,9 @@ class CreateEffectiveOrders < ActiveRecord::Migration[4.2]
|
|
43
43
|
t.timestamps
|
44
44
|
end
|
45
45
|
|
46
|
-
add_index
|
46
|
+
add_index :orders, :user_id
|
47
47
|
|
48
|
-
|
49
|
-
create_table <%= @order_items_table_name %> do |t|
|
48
|
+
create_table :order_items do |t|
|
50
49
|
t.integer :order_id
|
51
50
|
t.string :purchasable_type
|
52
51
|
t.integer :purchasable_id
|
@@ -59,12 +58,11 @@ class CreateEffectiveOrders < ActiveRecord::Migration[4.2]
|
|
59
58
|
t.timestamps
|
60
59
|
end
|
61
60
|
|
62
|
-
add_index
|
63
|
-
add_index
|
64
|
-
add_index
|
65
|
-
|
61
|
+
add_index :order_items, :order_id
|
62
|
+
add_index :order_items, :purchasable_id
|
63
|
+
add_index :order_items, [:purchasable_type, :purchasable_id]
|
66
64
|
|
67
|
-
create_table
|
65
|
+
create_table :carts do |t|
|
68
66
|
t.integer :user_id
|
69
67
|
t.string :user_type
|
70
68
|
|
@@ -72,9 +70,9 @@ class CreateEffectiveOrders < ActiveRecord::Migration[4.2]
|
|
72
70
|
t.timestamps
|
73
71
|
end
|
74
72
|
|
75
|
-
add_index
|
73
|
+
add_index :carts, :user_id
|
76
74
|
|
77
|
-
create_table
|
75
|
+
create_table :cart_items do |t|
|
78
76
|
t.integer :cart_id
|
79
77
|
t.string :purchasable_type
|
80
78
|
t.integer :purchasable_id
|
@@ -85,11 +83,11 @@ class CreateEffectiveOrders < ActiveRecord::Migration[4.2]
|
|
85
83
|
t.timestamps
|
86
84
|
end
|
87
85
|
|
88
|
-
add_index
|
89
|
-
add_index
|
90
|
-
add_index
|
86
|
+
add_index :cart_items, :cart_id
|
87
|
+
add_index :cart_items, :purchasable_id
|
88
|
+
add_index :cart_items, [:purchasable_type, :purchasable_id]
|
91
89
|
|
92
|
-
create_table
|
90
|
+
create_table :customers do |t|
|
93
91
|
t.integer :user_id
|
94
92
|
t.string :user_type
|
95
93
|
|
@@ -103,9 +101,9 @@ class CreateEffectiveOrders < ActiveRecord::Migration[4.2]
|
|
103
101
|
t.timestamps
|
104
102
|
end
|
105
103
|
|
106
|
-
add_index
|
104
|
+
add_index :customers, :user_id
|
107
105
|
|
108
|
-
create_table
|
106
|
+
create_table :subscriptions do |t|
|
109
107
|
t.integer :customer_id
|
110
108
|
|
111
109
|
t.integer :subscribable_id
|
@@ -123,11 +121,11 @@ class CreateEffectiveOrders < ActiveRecord::Migration[4.2]
|
|
123
121
|
t.timestamps
|
124
122
|
end
|
125
123
|
|
126
|
-
add_index
|
127
|
-
add_index
|
128
|
-
add_index
|
124
|
+
add_index :subscriptions, :customer_id
|
125
|
+
add_index :subscriptions, :subscribable_id
|
126
|
+
add_index :subscriptions, [:subscribable_type, :subscribable_id]
|
129
127
|
|
130
|
-
create_table
|
128
|
+
create_table :products do |t|
|
131
129
|
t.integer :purchased_order_id
|
132
130
|
|
133
131
|
t.string :name
|
@@ -140,14 +138,4 @@ class CreateEffectiveOrders < ActiveRecord::Migration[4.2]
|
|
140
138
|
end
|
141
139
|
|
142
140
|
end
|
143
|
-
|
144
|
-
def self.down
|
145
|
-
drop_table <%= @orders_table_name %>
|
146
|
-
drop_table <%= @order_items_table_name %>
|
147
|
-
drop_table <%= @carts_table_name %>
|
148
|
-
drop_table <%= @cart_items_table_name %>
|
149
|
-
drop_table <%= @customers_table_name %>
|
150
|
-
drop_table <%= @subscriptions_table_name %>
|
151
|
-
drop_table <%= @products_table_name %>
|
152
|
-
end
|
153
141
|
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: 6.
|
4
|
+
version: 6.8.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: 2023-08-
|
11
|
+
date: 2023-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -328,7 +328,7 @@ files:
|
|
328
328
|
- config/effective_orders.rb
|
329
329
|
- config/locales/effective_orders.en.yml
|
330
330
|
- config/routes.rb
|
331
|
-
- db/migrate/
|
331
|
+
- db/migrate/101_create_effective_orders.rb
|
332
332
|
- lib/effective_orders.rb
|
333
333
|
- lib/effective_orders/engine.rb
|
334
334
|
- lib/effective_orders/version.rb
|