erp_txns_and_accts 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/controllers/api/v1/biz_txn_acct_roots_controller.rb +124 -0
- data/app/controllers/api/v1/biz_txn_acct_types_controller.rb +130 -0
- data/app/controllers/api/v1/biz_txn_events_controller.rb +53 -0
- data/app/controllers/api/v1/biz_txn_types_controller.rb +131 -0
- data/app/controllers/api/v1/financial_txns_controller.rb +53 -0
- data/app/models/biz_txn_acct_pty_rtype.rb +1 -0
- data/app/models/biz_txn_acct_root.rb +130 -6
- data/app/models/biz_txn_acct_type.rb +2 -0
- data/app/models/biz_txn_event.rb +229 -49
- data/app/models/biz_txn_party_role_type.rb +6 -0
- data/app/models/biz_txn_type.rb +23 -0
- data/app/models/extensions/party.rb +4 -2
- data/app/models/financial_txn.rb +108 -19
- data/config/routes.rb +13 -0
- data/db/data_migrations/20151216210147_add_default_gl_accounts.rb +33 -0
- data/db/migrate/20080805000030_base_txns_and_accts.rb +129 -127
- data/db/migrate/20151216202856_add_nested_set_to_biz_txn_acct_roots.rb +31 -0
- data/db/migrate/20151231185337_add_billable_to_finanical_txn.rb +13 -0
- data/db/migrate/20160310163051_add_created_by_updated_by_to_erp_txns_and_accts.rb +35 -0
- data/db/migrate/20160628145626_upgrade_biz_txn_events_entered_date_data_type.rb +21 -0
- data/lib/erp_txns_and_accts/extensions/active_record/acts_as_biz_txn_event.rb +29 -15
- data/lib/erp_txns_and_accts/version.rb +1 -1
- metadata +17 -10
- data/db/data_migrations/20101014142230_financial_txn_types.rb +0 -15
- data/db/migrate/20130408195119_add_biz_txn_acct_type_id_to_biz_txn_acct_root.rb +0 -5
- data/db/migrate/20140523095709_add_custom_fields_to_biz_txn_events.rb +0 -10
data/app/models/biz_txn_type.rb
CHANGED
@@ -34,4 +34,27 @@ class BizTxnType < ActiveRecord::Base
|
|
34
34
|
return nil
|
35
35
|
end
|
36
36
|
|
37
|
+
# finds all child for given types.
|
38
|
+
#
|
39
|
+
# @param biz_txn_types [Array] BizTxnType internal identifiers or records
|
40
|
+
# @returns [Array] BizTxnTypes types based and any of their children in a flat array
|
41
|
+
def self.find_child_types(biz_txn_types)
|
42
|
+
all_biz_txn_types = []
|
43
|
+
|
44
|
+
biz_txn_types.each do |biz_txn_type|
|
45
|
+
|
46
|
+
if biz_txn_type.is_a?(String)
|
47
|
+
biz_txn_type = BizTxnType.iid(biz_txn_type)
|
48
|
+
end
|
49
|
+
|
50
|
+
all_biz_txn_types.concat biz_txn_type.self_and_descendants
|
51
|
+
end
|
52
|
+
|
53
|
+
all_biz_txn_types.flatten
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_data_hash
|
57
|
+
to_hash(:only => [:id, :description, :internal_identifier, :created_at, :updated_at])
|
58
|
+
end
|
59
|
+
|
37
60
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
Party.class_eval do
|
2
2
|
|
3
|
-
has_many :biz_txn_acct_party_roles
|
4
|
-
has_many :biz_txn_acct_roots, :through => :biz_txn_acct_party_roles
|
3
|
+
has_many :biz_txn_acct_party_roles, dependent: :destroy
|
4
|
+
has_many :biz_txn_acct_roots, :through => :biz_txn_acct_party_roles
|
5
|
+
has_many :biz_txn_party_roles, dependent: :destroy
|
6
|
+
|
5
7
|
# has_many :entity_content_assignments, :as => :da_assignment
|
6
8
|
# has_many :credit_cards, :class_name => "CreditCard", :foreign_key => "cardholder_id"
|
7
9
|
|
data/app/models/financial_txn.rb
CHANGED
@@ -1,34 +1,123 @@
|
|
1
|
+
#### Table Definition ###########################
|
2
|
+
# create_table :financial_txns do |t|
|
3
|
+
# t.integer :money_id
|
4
|
+
# t.date :apply_date
|
5
|
+
#
|
6
|
+
# t.timestamps
|
7
|
+
# end
|
8
|
+
#################################################
|
9
|
+
|
1
10
|
class FinancialTxn < ActiveRecord::Base
|
2
11
|
attr_protected :created_at, :updated_at
|
3
12
|
|
4
13
|
acts_as_biz_txn_event
|
5
|
-
|
6
|
-
|
14
|
+
can_be_generated
|
15
|
+
|
7
16
|
belongs_to :money, :dependent => :destroy
|
8
|
-
has_many :payments
|
9
17
|
|
10
|
-
|
11
|
-
|
12
|
-
|
18
|
+
class << self
|
19
|
+
# Filter records
|
20
|
+
#
|
21
|
+
# @param filters [Hash] a hash of filters to be applied,
|
22
|
+
# @param statement [ActiveRecord::Relation] the query being built
|
23
|
+
# @return [ActiveRecord::Relation] the query being built
|
24
|
+
def apply_filters(filters, statement=nil)
|
25
|
+
unless statement
|
26
|
+
statement = FinancialTxn
|
27
|
+
end
|
13
28
|
|
14
|
-
|
15
|
-
has_payments? and self.payments.last.current_state == 'pending'
|
16
|
-
end
|
29
|
+
statement = statement.joins(:biz_txn_event)
|
17
30
|
|
18
|
-
|
19
|
-
self.is_scheduled? || self.has_pending_payment?
|
20
|
-
end
|
31
|
+
biz_txn_event_tbl = BizTxnEvent.arel_table
|
21
32
|
|
22
|
-
|
23
|
-
|
24
|
-
|
33
|
+
# filter by query which will filter on description
|
34
|
+
if filters[:query]
|
35
|
+
statement = statement.where('biz_txn_events.description like ?', "%#{filters[:query].strip}%")
|
36
|
+
end
|
37
|
+
|
38
|
+
# filter by WorkEffortType
|
39
|
+
unless filters[:biz_txn_type_iids].blank?
|
40
|
+
statement = statement.where(biz_txn_events: {biz_txn_type_id: BizTxnType.where(internal_identifier: filters[:biz_txn_type_iids])})
|
41
|
+
end
|
42
|
+
|
43
|
+
# filter by start_at
|
44
|
+
unless filters[:start_date].blank?
|
45
|
+
statement = statement.where(biz_txn_event_tbl[:entered_date].gteq(Time.parse(filters[:start_date])))
|
46
|
+
end
|
47
|
+
|
48
|
+
# filter by end_at
|
49
|
+
unless filters[:end_date].blank?
|
50
|
+
statement = statement.where(biz_txn_event_tbl[:entered_date].lteq(Time.parse(filters[:end_date])))
|
51
|
+
end
|
52
|
+
|
53
|
+
unless filters[:parties].blank?
|
54
|
+
data = JSON.parse(filters[:parties])
|
55
|
+
|
56
|
+
statement = statement.scope_by_party(data['party_ids'].split(','), {role_types: data['role_types']})
|
57
|
+
end
|
58
|
+
|
59
|
+
statement
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
# scoping helpers
|
64
|
+
#
|
65
|
+
|
66
|
+
# scope by dba organization
|
67
|
+
#
|
68
|
+
# @param dba_organization [Party] dba organization to scope by
|
69
|
+
#
|
70
|
+
# @return [ActiveRecord::Relation]
|
71
|
+
def scope_by_dba_organization(dba_organization)
|
72
|
+
dba_org_role_type = BizTxnPartyRoleType.find_or_create('dba_org', 'DBA Organization')
|
73
|
+
|
74
|
+
joins(:biz_txn_event)
|
75
|
+
.joins("inner join biz_txn_party_roles on biz_txn_party_roles.biz_txn_event_id = biz_txn_events.id")
|
76
|
+
.where('biz_txn_party_roles.party_id' => dba_organization)
|
77
|
+
.where('biz_txn_party_roles.biz_txn_party_role_type_id' => dba_org_role_type)
|
78
|
+
end
|
79
|
+
|
80
|
+
alias scope_by_dba scope_by_dba_organization
|
81
|
+
|
82
|
+
# scope by party
|
83
|
+
#
|
84
|
+
# @param party [Integer | Party | Array] either a id of Party record, a Party record, an array of Party records
|
85
|
+
# or an array of Party ids
|
86
|
+
# @param options [Hash] options to apply to this scope
|
87
|
+
# @option options [String | Array] :role_types BizTxnPartyRoleType internal identifiers to include in the scope,
|
88
|
+
# comma separated or an Array
|
89
|
+
#
|
90
|
+
# @return [ActiveRecord::Relation]
|
91
|
+
def scope_by_party(party, options={})
|
92
|
+
statement = joins(:biz_txn_event)
|
93
|
+
.joins("inner join biz_txn_party_roles on biz_txn_party_roles.biz_txn_event_id = biz_txn_events.id")
|
94
|
+
.where("biz_txn_party_roles.party_id" => party).uniq
|
95
|
+
|
96
|
+
if options[:role_types]
|
97
|
+
role_types = options[:role_types]
|
98
|
+
unless role_types.is_a? Array
|
99
|
+
role_types = role_types.split(',')
|
100
|
+
end
|
101
|
+
|
102
|
+
statement = statement.joins("inner join biz_txn_party_role_types
|
103
|
+
on biz_txn_party_role_types.id = biz_txn_party_roles.biz_txn_party_role_type_id")
|
104
|
+
.where(biz_txn_party_role_types: {internal_identifier: role_types})
|
105
|
+
end
|
106
|
+
|
107
|
+
statement
|
108
|
+
end
|
25
109
|
|
26
|
-
def has_payments?
|
27
|
-
!self.payments.empty?
|
28
110
|
end
|
29
111
|
|
30
|
-
|
31
|
-
|
112
|
+
# converts this record a hash data representation
|
113
|
+
#
|
114
|
+
# @return [Hash]
|
115
|
+
def to_data_hash
|
116
|
+
data = to_hash(only: [:id, :description, :apply_date])
|
117
|
+
|
118
|
+
data[:amount] = self.money.nil? ? 0 : self.money.amount
|
119
|
+
|
120
|
+
data
|
32
121
|
end
|
33
122
|
|
34
123
|
end
|
data/config/routes.rb
CHANGED
@@ -1,2 +1,15 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
namespace :api do
|
3
|
+
namespace :v1 do
|
4
|
+
resources :biz_txn_types, defaults: { :format => 'json' }
|
5
|
+
resources :biz_txn_events, defaults: { :format => 'json' }
|
6
|
+
resources :biz_txn_acct_roots, defaults: { :format => 'json' }
|
7
|
+
resources :biz_txn_acct_types, defaults: { :format => 'json' }
|
8
|
+
resources :financial_txns, defaults: { :format => 'json' }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
1
14
|
ErpTxnsAndAccts::Engine.routes.draw do
|
2
15
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class AddDefaultGlAccounts
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
gl_account_type = BizTxnAcctType.find_or_create('gl_account', 'GL Account')
|
5
|
+
|
6
|
+
expense = BizTxnAcctRoot.create(description: 'Expense',
|
7
|
+
internal_identifier: 'expense',
|
8
|
+
external_identifier: 'expense',
|
9
|
+
biz_txn_acct_type: gl_account_type)
|
10
|
+
|
11
|
+
revenue = BizTxnAcctRoot.create(description: 'Revenue',
|
12
|
+
internal_identifier: 'revenue',
|
13
|
+
external_identifier: 'revenue',
|
14
|
+
biz_txn_acct_type: gl_account_type)
|
15
|
+
|
16
|
+
# add BizTxnAcctPtyRoles for DBA Organization
|
17
|
+
if User.find_by_username('admin')
|
18
|
+
dba_organization = User.find_by_username('admin').party.dba_organization
|
19
|
+
|
20
|
+
BizTxnAcctPartyRole.create(biz_txn_acct_root: expense,
|
21
|
+
party: dba_organization,
|
22
|
+
biz_txn_acct_pty_rtype: BizTxnAcctPtyRtype.find_or_create('dba_org', 'DBA Organization'))
|
23
|
+
|
24
|
+
BizTxnAcctPartyRole.create(biz_txn_acct_root: revenue,
|
25
|
+
party: dba_organization,
|
26
|
+
biz_txn_acct_pty_rtype: BizTxnAcctPtyRtype.find_or_create('dba_org', 'DBA Organization'))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.down
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -3,18 +3,18 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
3
3
|
|
4
4
|
unless table_exists?(:biz_txn_events)
|
5
5
|
create_table :biz_txn_events do |t|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
t.column :description, :string
|
7
|
+
t.column :biz_txn_acct_root_id, :integer
|
8
|
+
t.column :biz_txn_type_id, :integer
|
9
|
+
t.column :entered_date, :date
|
10
|
+
t.column :post_date, :date
|
11
|
+
t.column :biz_txn_record_id, :integer
|
12
|
+
t.column :biz_txn_record_type, :string
|
13
|
+
t.column :external_identifier, :string
|
14
|
+
t.column :external_id_source, :string
|
15
|
+
t.timestamps
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
add_index :biz_txn_events, :biz_txn_acct_root_id
|
19
19
|
add_index :biz_txn_events, :biz_txn_type_id
|
20
20
|
add_index :biz_txn_events, [:biz_txn_record_id, :biz_txn_record_type], :name => "btai_1"
|
@@ -22,13 +22,13 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
22
22
|
|
23
23
|
unless table_exists?(:biz_txn_event_descs)
|
24
24
|
create_table :biz_txn_event_descs do |t|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
t.column :biz_txn_event_id, :integer
|
26
|
+
t.column :language_id, :integer
|
27
|
+
t.column :locale_id, :integer
|
28
|
+
t.column :priority, :integer
|
29
|
+
t.column :sequence, :integer
|
30
|
+
t.column :short_description, :string
|
31
|
+
t.column :long_description, :string
|
32
32
|
t.timestamps
|
33
33
|
end
|
34
34
|
|
@@ -39,16 +39,16 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
39
39
|
|
40
40
|
unless table_exists?(:biz_txn_types)
|
41
41
|
create_table :biz_txn_types do |t|
|
42
|
-
t.column
|
43
|
-
t.column
|
44
|
-
t.column
|
42
|
+
t.column :parent_id, :integer
|
43
|
+
t.column :lft, :integer
|
44
|
+
t.column :rgt, :integer
|
45
45
|
|
46
46
|
#custom columns go here
|
47
|
-
t.column
|
48
|
-
t.column
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
52
52
|
t.timestamps
|
53
53
|
end
|
54
54
|
|
@@ -58,12 +58,12 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
58
58
|
unless table_exists?(:biz_txn_relationships)
|
59
59
|
create_table :biz_txn_relationships do |t|
|
60
60
|
t.column :biz_txn_rel_type_id, :integer
|
61
|
-
t.column :description,
|
62
|
-
t.column :txn_event_id_from,
|
63
|
-
t.column :txn_event_id_to,
|
64
|
-
t.column :status_type_id,
|
65
|
-
t.column :from_date,
|
66
|
-
t.column :thru_date,
|
61
|
+
t.column :description, :string
|
62
|
+
t.column :txn_event_id_from, :integer
|
63
|
+
t.column :txn_event_id_to, :integer
|
64
|
+
t.column :status_type_id, :integer
|
65
|
+
t.column :from_date, :date
|
66
|
+
t.column :thru_date, :date
|
67
67
|
t.timestamps
|
68
68
|
end
|
69
69
|
|
@@ -73,15 +73,15 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
73
73
|
|
74
74
|
unless table_exists?(:biz_txn_rel_types)
|
75
75
|
create_table :biz_txn_rel_types do |t|
|
76
|
-
t.column
|
77
|
-
t.column
|
78
|
-
t.column
|
76
|
+
t.column :parent_id, :integer
|
77
|
+
t.column :lft, :integer
|
78
|
+
t.column :rgt, :integer
|
79
79
|
#custom columns go here
|
80
|
-
t.column
|
81
|
-
t.column
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
t.column :description, :string
|
81
|
+
t.column :comments, :string
|
82
|
+
t.column :internal_identifier, :string
|
83
|
+
t.column :external_identifier, :string
|
84
|
+
t.column :external_id_source, :string
|
85
85
|
t.timestamps
|
86
86
|
end
|
87
87
|
|
@@ -90,27 +90,27 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
90
90
|
|
91
91
|
unless table_exists?(:biz_txn_statuses)
|
92
92
|
create_table :biz_txn_statuses do |t|
|
93
|
-
t.column
|
94
|
-
t.column
|
93
|
+
t.column :description, :string
|
94
|
+
t.column :comments, :string
|
95
95
|
t.timestamps
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
99
|
unless table_exists?(:biz_txn_tasks)
|
100
100
|
create_table :biz_txn_tasks do |t|
|
101
|
-
t.column
|
101
|
+
t.column :description, :string
|
102
102
|
t.timestamps
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
unless table_exists?(:biz_txn_task_types)
|
107
107
|
create_table :biz_txn_task_types do |t|
|
108
|
-
t.column
|
109
|
-
t.column
|
110
|
-
t.column
|
108
|
+
t.column :parent_id, :integer
|
109
|
+
t.column :lft, :integer
|
110
|
+
t.column :rgt, :integer
|
111
111
|
#custom columns go here
|
112
|
-
t.column
|
113
|
-
t.column
|
112
|
+
t.column :description, :string
|
113
|
+
t.column :comments, :string
|
114
114
|
t.timestamps
|
115
115
|
end
|
116
116
|
|
@@ -119,9 +119,9 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
119
119
|
|
120
120
|
unless table_exists?(:biz_txn_party_roles)
|
121
121
|
create_table :biz_txn_party_roles do |t|
|
122
|
-
t.column
|
123
|
-
|
124
|
-
t.column
|
122
|
+
t.column :biz_txn_event_id, :integer
|
123
|
+
t.column :party_id, :integer
|
124
|
+
t.column :biz_txn_party_role_type_id, :integer
|
125
125
|
t.timestamps
|
126
126
|
end
|
127
127
|
|
@@ -132,13 +132,13 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
132
132
|
|
133
133
|
unless table_exists?(:biz_txn_party_role_types)
|
134
134
|
create_table :biz_txn_party_role_types do |t|
|
135
|
-
t.column
|
136
|
-
t.column
|
137
|
-
t.column
|
135
|
+
t.column :parent_id, :integer
|
136
|
+
t.column :lft, :integer
|
137
|
+
t.column :rgt, :integer
|
138
138
|
#custom columns go here
|
139
|
-
t.column
|
140
|
-
t.column
|
141
|
-
t.column
|
139
|
+
t.column :description, :string
|
140
|
+
t.column :comments, :string
|
141
|
+
t.column :internal_identifier, :string
|
142
142
|
t.timestamps
|
143
143
|
end
|
144
144
|
|
@@ -147,17 +147,19 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
147
147
|
|
148
148
|
unless table_exists?(:biz_txn_acct_roots)
|
149
149
|
create_table :biz_txn_acct_roots do |t|
|
150
|
-
|
151
|
-
|
152
|
-
t.column
|
153
|
-
t.column
|
154
|
-
|
155
|
-
|
156
|
-
t.column
|
150
|
+
t.column :description, :string
|
151
|
+
t.column :status, :integer
|
152
|
+
t.column :biz_txn_acct_id, :integer
|
153
|
+
t.column :biz_txn_acct_type, :string
|
154
|
+
t.column :external_identifier, :string
|
155
|
+
t.column :external_id_source, :string
|
156
|
+
t.column :type, :string
|
157
|
+
t.references :biz_txn_acct_type
|
157
158
|
t.timestamps
|
158
159
|
end
|
159
160
|
|
160
161
|
add_index :biz_txn_acct_roots, [:biz_txn_acct_id, :biz_txn_acct_type], :name => "btai_2"
|
162
|
+
add_index :biz_txn_acct_roots, :biz_txn_acct_type_id, :name => "btai_3"
|
161
163
|
end
|
162
164
|
|
163
165
|
unless table_exists?(:biz_txn_acct_status_types)
|
@@ -165,18 +167,18 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
165
167
|
t.timestamps
|
166
168
|
end
|
167
169
|
end
|
168
|
-
|
170
|
+
|
169
171
|
unless table_exists?(:biz_txn_acct_types)
|
170
172
|
create_table :biz_txn_acct_types do |t|
|
171
|
-
t.column
|
172
|
-
t.column
|
173
|
-
t.column
|
173
|
+
t.column :parent_id, :integer
|
174
|
+
t.column :lft, :integer
|
175
|
+
t.column :rgt, :integer
|
174
176
|
#custom columns go here
|
175
|
-
t.column
|
176
|
-
t.column
|
177
|
-
|
178
|
-
|
179
|
-
|
177
|
+
t.column :description, :string
|
178
|
+
t.column :comments, :string
|
179
|
+
t.column :internal_identifier, :string
|
180
|
+
t.column :external_identifier, :string
|
181
|
+
t.column :external_id_source, :string
|
180
182
|
t.timestamps
|
181
183
|
end
|
182
184
|
|
@@ -191,15 +193,15 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
191
193
|
|
192
194
|
unless table_exists?(:biz_txn_acct_rel_types)
|
193
195
|
create_table :biz_txn_acct_rel_types do |t|
|
194
|
-
t.column
|
195
|
-
t.column
|
196
|
-
t.column
|
196
|
+
t.column :parent_id, :integer
|
197
|
+
t.column :lft, :integer
|
198
|
+
t.column :rgt, :integer
|
197
199
|
#custom columns go here
|
198
|
-
t.column
|
199
|
-
t.column
|
200
|
-
|
201
|
-
|
202
|
-
|
200
|
+
t.column :description, :string
|
201
|
+
t.column :comments, :string
|
202
|
+
t.column :internal_identifier, :string
|
203
|
+
t.column :external_identifier, :string
|
204
|
+
t.column :external_id_source, :string
|
203
205
|
t.timestamps
|
204
206
|
end
|
205
207
|
|
@@ -208,13 +210,13 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
208
210
|
|
209
211
|
unless table_exists?(:biz_txn_acct_relationships)
|
210
212
|
create_table :biz_txn_acct_relationships do |t|
|
211
|
-
t.column
|
212
|
-
t.column
|
213
|
-
t.column
|
214
|
-
t.column
|
215
|
-
t.column
|
216
|
-
t.column
|
217
|
-
t.column
|
213
|
+
t.column :biz_txn_acct_rel_type_id, :integer
|
214
|
+
t.column :description, :string
|
215
|
+
t.column :biz_txn_acct_root_id_from, :integer
|
216
|
+
t.column :biz_txn_acct_root_id_to, :integer
|
217
|
+
t.column :status_type_id, :integer
|
218
|
+
t.column :from_date, :date
|
219
|
+
t.column :thru_date, :date
|
218
220
|
t.timestamps
|
219
221
|
end
|
220
222
|
|
@@ -225,11 +227,11 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
225
227
|
|
226
228
|
unless table_exists?(:biz_txn_acct_party_roles)
|
227
229
|
create_table :biz_txn_acct_party_roles do |t|
|
228
|
-
t.column
|
229
|
-
t.column
|
230
|
-
t.column
|
231
|
-
t.column
|
232
|
-
t.column
|
230
|
+
t.column :description, :string
|
231
|
+
t.column :biz_txn_acct_root_id, :integer
|
232
|
+
t.column :party_id, :integer
|
233
|
+
t.column :biz_txn_acct_pty_rtype_id, :integer
|
234
|
+
t.column :is_default_billing_acct_flag, :integer
|
233
235
|
t.timestamps
|
234
236
|
end
|
235
237
|
|
@@ -240,15 +242,15 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
240
242
|
|
241
243
|
unless table_exists?(:biz_txn_acct_pty_rtypes)
|
242
244
|
create_table :biz_txn_acct_pty_rtypes do |t|
|
243
|
-
t.column
|
244
|
-
t.column
|
245
|
-
t.column
|
245
|
+
t.column :parent_id, :integer
|
246
|
+
t.column :lft, :integer
|
247
|
+
t.column :rgt, :integer
|
246
248
|
#custom columns go here
|
247
|
-
t.column
|
248
|
-
t.column
|
249
|
-
|
250
|
-
|
251
|
-
|
249
|
+
t.column :description, :string
|
250
|
+
t.column :comments, :string
|
251
|
+
t.column :internal_identifier, :string
|
252
|
+
t.column :external_identifier, :string
|
253
|
+
t.column :external_id_source, :string
|
252
254
|
t.timestamps
|
253
255
|
end
|
254
256
|
|
@@ -257,12 +259,12 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
257
259
|
|
258
260
|
unless table_exists?(:biz_acct_txn_tasks)
|
259
261
|
create_table :biz_acct_txn_tasks do |t|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
262
|
+
t.column :biz_txn_task_id, :integer
|
263
|
+
t.column :biz_txn_account_id, :integer
|
264
|
+
t.column :description, :string
|
265
|
+
t.column :comments, :string
|
266
|
+
t.column :entered_date, :datetime
|
267
|
+
t.column :requested_date, :datetime
|
266
268
|
t.timestamps
|
267
269
|
end
|
268
270
|
|
@@ -272,13 +274,13 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
272
274
|
|
273
275
|
unless table_exists?(:biz_txn_agreement_role_types)
|
274
276
|
create_table :biz_txn_agreement_role_types do |t|
|
275
|
-
t.column
|
276
|
-
t.column
|
277
|
-
t.column
|
277
|
+
t.column :parent_id, :integer
|
278
|
+
t.column :lft, :integer
|
279
|
+
t.column :rgt, :integer
|
278
280
|
#custom columns go here
|
279
|
-
t.column
|
280
|
-
t.column
|
281
|
-
t.column
|
281
|
+
t.column :description, :string
|
282
|
+
t.column :comments, :string
|
283
|
+
t.column :internal_identifier, :string
|
282
284
|
t.timestamps
|
283
285
|
end
|
284
286
|
|
@@ -287,9 +289,9 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
287
289
|
|
288
290
|
unless table_exists?(:biz_txn_agreement_roles)
|
289
291
|
create_table :biz_txn_agreement_roles do |t|
|
290
|
-
t.references
|
291
|
-
t.column
|
292
|
-
t.column
|
292
|
+
t.references :biz_txn_event, :polymorphic => true
|
293
|
+
t.column :agreement_id, :integer
|
294
|
+
t.column :biz_txn_agreement_role_type_id, :integer
|
293
295
|
t.timestamps
|
294
296
|
end
|
295
297
|
|
@@ -300,7 +302,7 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
300
302
|
unless table_exists?(:financial_txns)
|
301
303
|
create_table :financial_txns do |t|
|
302
304
|
t.integer :money_id
|
303
|
-
t.date
|
305
|
+
t.date :apply_date
|
304
306
|
|
305
307
|
t.timestamps
|
306
308
|
end
|
@@ -317,13 +319,13 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
317
319
|
|
318
320
|
unless table_exists?(:financial_txn_accounts)
|
319
321
|
create_table :financial_txn_accounts do |t|
|
320
|
-
t.column :account_number,
|
321
|
-
t.column :agreement_id,
|
322
|
-
t.column :balance_id,
|
323
|
-
t.column :balance_date,
|
322
|
+
t.column :account_number, :string
|
323
|
+
t.column :agreement_id, :integer
|
324
|
+
t.column :balance_id, :integer
|
325
|
+
t.column :balance_date, :date
|
324
326
|
t.column :calculate_balance, :boolean
|
325
|
-
t.column :payment_due_id,
|
326
|
-
t.column :due_date,
|
327
|
+
t.column :payment_due_id, :integer
|
328
|
+
t.column :due_date, :date
|
327
329
|
|
328
330
|
#polymorphic tables
|
329
331
|
t.references :financial_account, :polymorphic => true
|
@@ -334,10 +336,10 @@ class BaseTxnsAndAccts < ActiveRecord::Migration
|
|
334
336
|
|
335
337
|
unless table_exists?(:base_txn_contexts)
|
336
338
|
create_table :base_txn_contexts do |t|
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
339
|
+
t.references :biz_txn_event
|
340
|
+
t.references :txn_context_record, :polymorphic => true
|
341
|
+
|
342
|
+
t.timestamps
|
341
343
|
end
|
342
344
|
|
343
345
|
add_index :base_txn_contexts, [:txn_context_record_id, :txn_context_record_type], :name => 'txn_context_record_idx'
|