erp_orders 4.0.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/charge_line.rb +31 -13
- data/app/models/charge_type.rb +7 -0
- data/app/models/extensions/party.rb +13 -0
- data/app/models/order_line_item.rb +150 -14
- data/app/models/order_line_item_rel_type.rb +6 -0
- data/app/models/order_line_item_relationship.rb +8 -0
- data/app/models/order_txn.rb +314 -61
- data/app/models/sales_tax_line.rb +15 -0
- data/app/models/sales_tax_policy.rb +7 -0
- data/db/data_migrations/20141214150732_add_order_tracked_statues.rb +25 -0
- data/db/data_migrations/20150309004308_add_base_charge_types.rb +19 -0
- data/db/migrate/20080805000060_base_orders.rb +119 -111
- data/db/migrate/20150309003812_add_charge_type_to_charge_lines.rb +5 -0
- data/db/migrate/20150309004440_create_charge_types.rb +18 -0
- data/db/migrate/20150311160005_add_unit_price_to_order_line_items.rb +5 -0
- data/db/migrate/20150622151009_add_tax_policy.rb +42 -0
- data/db/migrate/20150622170438_update_taxation_for_orders.rb +58 -0
- data/db/migrate/20150624000721_add_internal_identifier_to_charge_type.rb +5 -0
- data/db/migrate/20160310163060_add_created_by_updated_by_to_erp_orders.rb +35 -0
- data/lib/erp_orders.rb +2 -0
- data/lib/erp_orders/engine.rb +0 -4
- data/lib/erp_orders/extensions/active_record/acts_as_order_line_item.rb +2 -1
- data/lib/erp_orders/extensions/active_record/acts_as_order_txn.rb +1 -1
- data/lib/erp_orders/taxation.rb +49 -0
- data/lib/erp_orders/version.rb +1 -1
- metadata +24 -15
- data/app/models/charge_line_payment_txn.rb +0 -7
- data/db/migrate/20130620203217_add_quantity_to_order_line_items.rb +0 -13
- data/db/migrate/20131005232344_update_order_line_pty_role_indexes.erp_orders.rb +0 -19
- data/db/migrate/20131005232611_remove_order_line_specific_rtype.rb +0 -32
- data/db/migrate/20140129200040_add_uom_to_order_line_item.rb +0 -13
- data/db/migrate/20140930152140_add_custom_fields_to_order_txn.rb +0 -12
@@ -0,0 +1,15 @@
|
|
1
|
+
# create_table :sales_tax_line do |t|
|
2
|
+
# t.references :sales_tax_policy
|
3
|
+
# t.decimal :rate, precision: 8, scale: 2
|
4
|
+
# t.text :comment
|
5
|
+
# t.references :taxed_record, polymorphic: true
|
6
|
+
#
|
7
|
+
# t.timestamps
|
8
|
+
# end#
|
9
|
+
|
10
|
+
class SalesTaxLine < ActiveRecord::Base
|
11
|
+
attr_protected :created_at, :updated_at
|
12
|
+
|
13
|
+
belongs_to :taxed_record, polymorphic: true
|
14
|
+
belongs_to :sales_tax_policy
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class AddOrderTrackedStatues
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
order_statuses = TrackedStatusType.create(internal_identifier: 'order_statuses', description: 'Order Statuses')
|
5
|
+
|
6
|
+
[
|
7
|
+
['initialized', 'Initialized'],
|
8
|
+
['items_added', 'Items Added'],
|
9
|
+
['demographics_gathered', 'Demographics Gathered'],
|
10
|
+
['payment_failed', 'Payment Failed'],
|
11
|
+
['paid', 'Paid'],
|
12
|
+
['ready_to_ship', 'Ready To Ship'],
|
13
|
+
['shipped', 'Shipped'],
|
14
|
+
].each do |data|
|
15
|
+
status = TrackedStatusType.create(internal_identifier: data[0], description: data[1])
|
16
|
+
status.move_to_child_of(order_statuses)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.down
|
22
|
+
TrackedStatusType.find_by_internal_identifier('order_statuses').destroy
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class AddBaseChargeTypes
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
ActiveRecord::Base.transaction do
|
5
|
+
ChargeType.create(description: 'Shipping', internal_identifier: 'shipping', taxable: false)
|
6
|
+
ChargeType.create(description: 'Tax', internal_identifier: 'tax', taxable: true)
|
7
|
+
ChargeType.create(description: 'Assembly', internal_identifier: 'assembly', taxable: true)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
ActiveRecord::Base.transaction do
|
13
|
+
ChargeType.find_by_internal_identifier('shipping').destroy
|
14
|
+
ChargeType.find_by_internal_identifier('tax').destroy
|
15
|
+
ChargeType.find_by_internal_identifier('assembly').destroy
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -1,178 +1,186 @@
|
|
1
1
|
class BaseOrders < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
|
-
|
3
|
+
|
4
4
|
unless table_exists?(:order_txns)
|
5
5
|
create_table :order_txns do |t|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
t.column
|
19
|
-
t.column
|
20
|
-
t.column
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
6
|
+
t.column :description, :string
|
7
|
+
t.column :order_txn_type_id, :integer
|
8
|
+
|
9
|
+
# Multi-table inheritance info
|
10
|
+
t.column :order_txn_record_id, :integer
|
11
|
+
t.column :order_txn_record_type, :string
|
12
|
+
|
13
|
+
# Contact Information
|
14
|
+
t.column :email, :string
|
15
|
+
t.column :phone_number, :string
|
16
|
+
|
17
|
+
# Shipping Address
|
18
|
+
t.column :ship_to_first_name, :string
|
19
|
+
t.column :ship_to_last_name, :string
|
20
|
+
t.column :ship_to_address_line_1, :string
|
21
|
+
t.column :ship_to_address_line_2, :string
|
22
|
+
t.column :bill_to_address_line_1, :string
|
23
|
+
t.column :bill_to_address_line_2, :string
|
24
|
+
t.column :ship_to_city, :string
|
25
|
+
t.column :ship_to_state, :string
|
26
|
+
t.column :ship_to_postal_code, :string
|
27
|
+
t.column :ship_to_country, :string
|
28
|
+
|
29
|
+
# Private parts
|
30
|
+
t.column :customer_ip, :string
|
31
|
+
t.column :order_number, :string
|
32
|
+
t.column :error_message, :string
|
33
|
+
|
34
|
+
t.timestamps
|
33
35
|
end
|
34
36
|
|
35
37
|
add_index :order_txns, :order_txn_type_id
|
36
38
|
add_index :order_txns, [:order_txn_record_id, :order_txn_record_type], :name => 'order_txn_record_idx'
|
37
39
|
end
|
38
|
-
|
40
|
+
|
39
41
|
unless table_exists?(:order_txn_types)
|
40
42
|
create_table :order_txn_types do |t|
|
41
|
-
t.column
|
42
|
-
t.column
|
43
|
-
t.column
|
43
|
+
t.column :parent_id, :integer
|
44
|
+
t.column :lft, :integer
|
45
|
+
t.column :rgt, :integer
|
44
46
|
#custom columns go here
|
45
|
-
t.column
|
46
|
-
t.column
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
t.column :description, :string
|
48
|
+
t.column :comments, :string
|
49
|
+
t.column :internal_identifier, :string
|
50
|
+
t.column :external_identifier, :string
|
51
|
+
t.column :external_id_source, :string
|
50
52
|
t.timestamps
|
51
53
|
end
|
52
54
|
|
53
55
|
add_index :order_txn_types, :parent_id
|
54
56
|
end
|
55
|
-
|
57
|
+
|
56
58
|
|
57
59
|
unless table_exists?(:order_line_items)
|
58
60
|
create_table :order_line_items do |t|
|
59
|
-
t.column
|
60
|
-
t.column
|
61
|
-
t.column
|
62
|
-
t.column
|
63
|
-
t.column
|
64
|
-
t.column
|
65
|
-
t.column
|
66
|
-
t.column
|
67
|
-
t.column
|
68
|
-
t.column
|
69
|
-
t.column
|
70
|
-
t.column
|
71
|
-
t.
|
72
|
-
t.
|
61
|
+
t.column :order_txn_id, :integer
|
62
|
+
t.column :order_line_item_type_id, :integer
|
63
|
+
t.column :product_instance_id, :integer
|
64
|
+
t.column :product_instance_description, :string
|
65
|
+
t.column :product_type_id, :integer
|
66
|
+
t.column :product_type_description, :string
|
67
|
+
t.column :sold_price, :decimal, :precision => 8, :scale => 2
|
68
|
+
t.column :sold_price_uom, :integer
|
69
|
+
t.column :sold_amount, :integer
|
70
|
+
t.column :sold_amount_uom, :integer
|
71
|
+
t.column :product_offer_id, :integer
|
72
|
+
t.column :quantity, :integer
|
73
|
+
t.references :unit_of_measurement
|
74
|
+
t.string :product_offer_description
|
75
|
+
|
73
76
|
t.timestamps
|
74
77
|
end
|
75
78
|
|
79
|
+
add_index :order_line_items, :unit_of_measurement_id, :name => 'order_line_item_uom_idx'
|
76
80
|
add_index :order_line_items, :order_txn_id
|
77
81
|
add_index :order_line_items, :order_line_item_type_id
|
78
|
-
add_index :order_line_items, :product_id
|
79
82
|
add_index :order_line_items, :product_instance_id
|
80
83
|
add_index :order_line_items, :product_type_id
|
81
84
|
add_index :order_line_items, :product_offer_id
|
82
85
|
end
|
83
|
-
|
86
|
+
|
84
87
|
unless table_exists?(:order_line_item_types)
|
85
88
|
create_table :order_line_item_types do |t|
|
86
|
-
t.column
|
87
|
-
t.column
|
88
|
-
t.column
|
89
|
+
t.column :parent_id, :integer
|
90
|
+
t.column :lft, :integer
|
91
|
+
t.column :rgt, :integer
|
89
92
|
#custom columns go here
|
90
|
-
t.column
|
91
|
-
t.column
|
92
|
-
|
93
|
-
|
94
|
-
|
93
|
+
t.column :description, :string
|
94
|
+
t.column :comments, :string
|
95
|
+
t.column :internal_identifier, :string
|
96
|
+
t.column :external_identifier, :string
|
97
|
+
t.column :external_id_source, :string
|
95
98
|
t.timestamps
|
96
99
|
end
|
97
100
|
|
98
101
|
add_index :order_line_item_types, :parent_id
|
99
102
|
end
|
100
|
-
|
103
|
+
|
101
104
|
unless table_exists?(:order_line_item_pty_roles)
|
102
105
|
create_table :order_line_item_pty_roles do |t|
|
103
|
-
t.
|
104
|
-
t.
|
105
|
-
t.
|
106
|
-
t.
|
107
|
-
|
106
|
+
t.references :role_type
|
107
|
+
t.references :biz_txn_acct_root #optional for splitting orders across accounts
|
108
|
+
t.references :order_line_item
|
109
|
+
t.references :party
|
110
|
+
|
111
|
+
t.string :description
|
112
|
+
|
108
113
|
t.timestamps
|
109
114
|
end
|
110
115
|
|
111
|
-
add_index :order_line_item_pty_roles, :order_line_item_id
|
112
|
-
add_index :order_line_item_pty_roles, :party_id
|
113
|
-
add_index :order_line_item_pty_roles, :
|
114
|
-
add_index :order_line_item_pty_roles, :biz_txn_acct_root_id
|
116
|
+
add_index :order_line_item_pty_roles, :order_line_item_id, :name => 'order_line_item_pty_role_order_line_item_idx'
|
117
|
+
add_index :order_line_item_pty_roles, :party_id, :name => 'order_line_item_pty_role_party_idx'
|
118
|
+
add_index :order_line_item_pty_roles, :role_type_id, :name => 'order_line_item_pty_role_role_type_idx'
|
119
|
+
add_index :order_line_item_pty_roles, :biz_txn_acct_root_id , :name => 'order_line_item_pty_role_biz_txn_acct_root_idx'
|
115
120
|
end
|
116
|
-
|
117
|
-
unless table_exists?(:
|
118
|
-
create_table :
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
t.column :external_id_source, :string
|
128
|
-
t.timestamps
|
121
|
+
|
122
|
+
unless table_exists?(:order_line_item_relationships)
|
123
|
+
create_table :order_line_item_relationships do |t|
|
124
|
+
t.column :order_line_item_rel_type_id, :integer
|
125
|
+
t.column :description, :string
|
126
|
+
t.column :order_line_item_id_from, :integer
|
127
|
+
t.column :order_line_item_id_to, :integer
|
128
|
+
t.column :status_type_id, :integer
|
129
|
+
t.column :from_date, :date
|
130
|
+
t.column :thru_date, :date
|
131
|
+
t.timestamps
|
129
132
|
end
|
130
133
|
|
131
|
-
add_index :
|
134
|
+
add_index :order_line_item_relationships, :order_line_item_rel_type_id, name: 'order_line_item_rel_on_order_line_item_rel_type_id'
|
135
|
+
add_index :order_line_item_relationships, :status_type_id
|
132
136
|
end
|
133
|
-
|
134
|
-
unless table_exists?(:charge_lines)
|
135
|
-
create_table :charge_lines do |t|
|
136
|
-
t.string :sti_type
|
137
|
-
t.references :money
|
138
|
-
t.string :description #could be expanded to include type information, etc.
|
139
|
-
t.string :external_identifier
|
140
|
-
t.string :external_id_source
|
141
|
-
|
142
|
-
#polymorphic
|
143
|
-
t.references :charged_item, :polymorphic => true
|
144
137
|
|
138
|
+
unless table_exists?(:order_line_item_rel_types)
|
139
|
+
create_table :order_line_item_rel_types do |t|
|
140
|
+
t.column :parent_id, :integer
|
141
|
+
t.column :lft, :integer
|
142
|
+
t.column :rgt, :integer
|
143
|
+
#custom columns go here
|
144
|
+
t.column :description, :string
|
145
|
+
t.column :comments, :string
|
146
|
+
t.column :internal_identifier, :string
|
147
|
+
t.column :external_identifier, :string
|
148
|
+
t.column :external_id_source, :string
|
145
149
|
t.timestamps
|
146
150
|
end
|
147
151
|
|
148
|
-
add_index :
|
152
|
+
add_index :order_line_item_rel_types, :parent_id
|
149
153
|
end
|
150
|
-
|
151
|
-
unless table_exists?(:
|
152
|
-
create_table :
|
153
|
-
t.
|
154
|
-
|
154
|
+
|
155
|
+
unless table_exists?(:charge_lines)
|
156
|
+
create_table :charge_lines do |t|
|
157
|
+
t.string :sti_type
|
158
|
+
t.references :money
|
159
|
+
t.string :description #could be expanded to include type information, etc.
|
160
|
+
t.string :external_identifier
|
161
|
+
t.string :external_id_source
|
162
|
+
|
155
163
|
#polymorphic
|
156
|
-
t.references :
|
164
|
+
t.references :charged_item, :polymorphic => true
|
157
165
|
|
158
166
|
t.timestamps
|
159
167
|
end
|
160
168
|
|
161
|
-
add_index :
|
162
|
-
add_index :charge_line_payment_txns, :charge_line_id
|
169
|
+
add_index :charge_lines, [:charged_item_id, :charged_item_type], :name => 'charged_item_idx'
|
163
170
|
end
|
171
|
+
|
164
172
|
end
|
165
173
|
|
166
174
|
def self.down
|
167
175
|
[
|
168
|
-
|
169
|
-
|
170
|
-
|
176
|
+
:charge_lines, :line_item_role_types, :order_line_item_pty_roles,
|
177
|
+
:order_line_item_types, :order_line_items, :order_txn_types,
|
178
|
+
:order_txns, :order_line_item_relationships, :order_line_item_rel_types
|
171
179
|
].each do |tbl|
|
172
180
|
if table_exists?(tbl)
|
173
181
|
drop_table tbl
|
174
182
|
end
|
175
|
-
end
|
183
|
+
end
|
176
184
|
end
|
177
|
-
|
185
|
+
|
178
186
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateChargeTypes < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
unless table_exists?(:charge_types)
|
4
|
+
create_table :charge_types do |t|
|
5
|
+
t.string :description
|
6
|
+
t.string :internal_identifier
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def down
|
14
|
+
if table_exists?(:charge_types)
|
15
|
+
drop_table :charge_types
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class AddTaxPolicy < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
|
4
|
+
#
|
5
|
+
# Stores tax rates determined from external system
|
6
|
+
#
|
7
|
+
unless table_exists? :sales_tax_lines
|
8
|
+
create_table :sales_tax_lines do |t|
|
9
|
+
t.references :sales_tax_policies
|
10
|
+
t.decimal :rate, precision: 8, scale: 2
|
11
|
+
t.text :comment
|
12
|
+
t.references :taxed_record, polymorphic: true
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# Federal Sales Tax
|
20
|
+
# State Sales Tax
|
21
|
+
# Local Sales Tax
|
22
|
+
#
|
23
|
+
unless table_exists? :sales_tax_policies
|
24
|
+
create_table :sales_tax_policies do |t|
|
25
|
+
t.string :description
|
26
|
+
t.string :internal_identifier
|
27
|
+
|
28
|
+
t.timestamps
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def down
|
35
|
+
[:sales_tax_lines, :sales_tax_policies].each do |table|
|
36
|
+
if table_exists? table
|
37
|
+
drop_table table
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class UpdateTaxationForOrders < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
|
4
|
+
unless column_exists? :order_line_items, :sales_tax
|
5
|
+
add_column :order_line_items, :sales_tax, :decimal, precision: 8, scale: 2
|
6
|
+
end
|
7
|
+
|
8
|
+
unless column_exists? :order_line_items, :taxed
|
9
|
+
add_column :order_line_items, :taxed, :boolean
|
10
|
+
end
|
11
|
+
|
12
|
+
unless column_exists? :order_txns, :sales_tax
|
13
|
+
add_column :order_txns, :sales_tax, :decimal, precision: 8, scale: 2
|
14
|
+
end
|
15
|
+
|
16
|
+
unless column_exists? :charge_lines, :sales_tax
|
17
|
+
add_column :charge_lines, :sales_tax, :decimal, precision: 8, scale: 2
|
18
|
+
end
|
19
|
+
|
20
|
+
unless column_exists? :charge_lines, :taxed
|
21
|
+
add_column :charge_lines, :taxed, :boolean
|
22
|
+
end
|
23
|
+
|
24
|
+
unless column_exists? :charge_types, :taxable
|
25
|
+
add_column :charge_types, :taxable, :boolean
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def down
|
31
|
+
|
32
|
+
if column_exists? :order_line_items, :sales_tax
|
33
|
+
remove_column :order_line_items, :sales_tax
|
34
|
+
end
|
35
|
+
|
36
|
+
if column_exists? :order_line_items, :taxed
|
37
|
+
remove_column :order_line_items, :taxed
|
38
|
+
end
|
39
|
+
|
40
|
+
if column_exists? :order_txns, :sales_tax
|
41
|
+
remove_column :order_txns, :sales_tax
|
42
|
+
end
|
43
|
+
|
44
|
+
if column_exists? :charge_lines, :sales_tax
|
45
|
+
remove_column :charge_lines, :sales_tax
|
46
|
+
end
|
47
|
+
|
48
|
+
if column_exists? :charge_types, :taxable
|
49
|
+
remove_column :charge_types, :taxable
|
50
|
+
end
|
51
|
+
|
52
|
+
if column_exists? :charge_lines, :taxed
|
53
|
+
remove_column :charge_lines, :taxed
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|