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.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v1/biz_txn_acct_roots_controller.rb +124 -0
  3. data/app/controllers/api/v1/biz_txn_acct_types_controller.rb +130 -0
  4. data/app/controllers/api/v1/biz_txn_events_controller.rb +53 -0
  5. data/app/controllers/api/v1/biz_txn_types_controller.rb +131 -0
  6. data/app/controllers/api/v1/financial_txns_controller.rb +53 -0
  7. data/app/models/biz_txn_acct_pty_rtype.rb +1 -0
  8. data/app/models/biz_txn_acct_root.rb +130 -6
  9. data/app/models/biz_txn_acct_type.rb +2 -0
  10. data/app/models/biz_txn_event.rb +229 -49
  11. data/app/models/biz_txn_party_role_type.rb +6 -0
  12. data/app/models/biz_txn_type.rb +23 -0
  13. data/app/models/extensions/party.rb +4 -2
  14. data/app/models/financial_txn.rb +108 -19
  15. data/config/routes.rb +13 -0
  16. data/db/data_migrations/20151216210147_add_default_gl_accounts.rb +33 -0
  17. data/db/migrate/20080805000030_base_txns_and_accts.rb +129 -127
  18. data/db/migrate/20151216202856_add_nested_set_to_biz_txn_acct_roots.rb +31 -0
  19. data/db/migrate/20151231185337_add_billable_to_finanical_txn.rb +13 -0
  20. data/db/migrate/20160310163051_add_created_by_updated_by_to_erp_txns_and_accts.rb +35 -0
  21. data/db/migrate/20160628145626_upgrade_biz_txn_events_entered_date_data_type.rb +21 -0
  22. data/lib/erp_txns_and_accts/extensions/active_record/acts_as_biz_txn_event.rb +29 -15
  23. data/lib/erp_txns_and_accts/version.rb +1 -1
  24. metadata +17 -10
  25. data/db/data_migrations/20101014142230_financial_txn_types.rb +0 -15
  26. data/db/migrate/20130408195119_add_biz_txn_acct_type_id_to_biz_txn_acct_root.rb +0 -5
  27. data/db/migrate/20140523095709_add_custom_fields_to_biz_txn_events.rb +0 -10
@@ -3,4 +3,10 @@ class BizTxnPartyRoleType < ActiveRecord::Base
3
3
 
4
4
  acts_as_nested_set
5
5
  include ErpTechSvcs::Utils::DefaultNestedSetMethods
6
+ acts_as_erp_type
7
+
8
+ def self.iid(internal_identifier)
9
+ find_by_internal_identifier(internal_identifier)
10
+ end
11
+
6
12
  end
@@ -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, :dependent => :destroy
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
 
@@ -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
- has_many :charge_line_payment_txns, :as => :payment_txn, :dependent => :destroy
6
- has_many :charge_lines, :through => :charge_line_payment_txns
14
+ can_be_generated
15
+
7
16
  belongs_to :money, :dependent => :destroy
8
- has_many :payments
9
17
 
10
- def has_captured_payment?
11
- has_payments? and self.payments.last.current_state == 'captured'
12
- end
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
- def has_pending_payment?
15
- has_payments? and self.payments.last.current_state == 'pending'
16
- end
29
+ statement = statement.joins(:biz_txn_event)
17
30
 
18
- def is_pending?
19
- self.is_scheduled? || self.has_pending_payment?
20
- end
31
+ biz_txn_event_tbl = BizTxnEvent.arel_table
21
32
 
22
- def is_scheduled?
23
- ((self.apply_date > Date.today) or (!self.has_payments?))
24
- end
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
- def most_recent_payment
31
- Payment.order('created_at DESC').where('financial_txn_id = ?', self.id).first
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
@@ -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
- 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, :datetime
10
- t.column :post_date, :datetime
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
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
- 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
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 :parent_id, :integer
43
- t.column :lft, :integer
44
- t.column :rgt, :integer
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 :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
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, :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
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 :parent_id, :integer
77
- t.column :lft, :integer
78
- t.column :rgt, :integer
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 :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
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 :description, :string
94
- t.column :comments, :string
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 :description, :string
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 :parent_id, :integer
109
- t.column :lft, :integer
110
- t.column :rgt, :integer
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 :description, :string
113
- t.column :comments, :string
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 :biz_txn_event_id, :integer
123
- t.column :party_id, :integer
124
- t.column :biz_txn_party_role_type_id, :integer
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 :parent_id, :integer
136
- t.column :lft, :integer
137
- t.column :rgt, :integer
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 :description, :string
140
- t.column :comments, :string
141
- t.column :internal_identifier, :string
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
- 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
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 :parent_id, :integer
172
- t.column :lft, :integer
173
- t.column :rgt, :integer
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 :description, :string
176
- t.column :comments, :string
177
- t.column :internal_identifier, :string
178
- t.column :external_identifier, :string
179
- t.column :external_id_source, :string
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 :parent_id, :integer
195
- t.column :lft, :integer
196
- t.column :rgt, :integer
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 :description, :string
199
- t.column :comments, :string
200
- t.column :internal_identifier, :string
201
- t.column :external_identifier, :string
202
- t.column :external_id_source, :string
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 :biz_txn_acct_rel_type_id, :integer
212
- t.column :description, :string
213
- t.column :biz_txn_acct_root_id_from, :integer
214
- t.column :biz_txn_acct_root_id_to, :integer
215
- t.column :status_type_id, :integer
216
- t.column :from_date, :date
217
- t.column :thru_date, :date
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 :description, :string
229
- t.column :biz_txn_acct_root_id, :integer
230
- t.column :party_id, :integer
231
- t.column :biz_txn_acct_pty_rtype_id, :integer
232
- t.column :is_default_billing_acct_flag, :integer
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 :parent_id, :integer
244
- t.column :lft, :integer
245
- t.column :rgt, :integer
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 :description, :string
248
- t.column :comments, :string
249
- t.column :internal_identifier, :string
250
- t.column :external_identifier, :string
251
- t.column :external_id_source, :string
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
- t.column :biz_txn_task_id, :integer
261
- t.column :biz_txn_account_id, :integer
262
- t.column :description, :string
263
- t.column :comments, :string
264
- t.column :entered_date, :datetime
265
- t.column :requested_date, :datetime
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 :parent_id, :integer
276
- t.column :lft, :integer
277
- t.column :rgt, :integer
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 :description, :string
280
- t.column :comments, :string
281
- t.column :internal_identifier, :string
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 :biz_txn_event, :polymorphic => true
291
- t.column :agreement_id, :integer
292
- t.column :biz_txn_agreement_role_type_id, :integer
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 :apply_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, :string
321
- t.column :agreement_id, :integer
322
- t.column :balance_id, :integer
323
- t.column :balance_date, :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, :integer
326
- t.column :due_date, :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
- t.references :biz_txn_event
338
- t.references :txn_context_record, :polymorphic => true
339
-
340
- t.timestamps
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'