erp_agreements 3.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.
- data/GPL-3-LICENSE +674 -0
- data/README.rdoc +2 -0
- data/Rakefile +31 -0
- data/app/assets/javascripts/erp_agreements/application.js +9 -0
- data/app/assets/stylesheets/erp_agreements/application.css +7 -0
- data/app/controllers/erp_agreements/application_controller.rb +4 -0
- data/app/helpers/erp_agreements/application_helper.rb +4 -0
- data/app/models/agreement.rb +42 -0
- data/app/models/agreement_item.rb +4 -0
- data/app/models/agreement_item_type.rb +4 -0
- data/app/models/agreement_party_role.rb +6 -0
- data/app/models/agreement_relationship.rb +32 -0
- data/app/models/agreement_reln_type.rb +7 -0
- data/app/models/agreement_role_type.rb +4 -0
- data/app/models/agreement_type.rb +4 -0
- data/app/models/extensions/party.rb +4 -0
- data/app/models/loyalty_program_code.rb +5 -0
- data/app/views/layouts/erp_agreements/application.html.erb +14 -0
- data/config/initializers/has_many_polymorphic.rb +1 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20080805000070_agreements_services.rb +159 -0
- data/db/migrate/20080805000071_agreements_services_indexes.rb +51 -0
- data/lib/erp_agreements.rb +4 -0
- data/lib/erp_agreements/engine.rb +6 -0
- data/lib/erp_agreements/version.rb +3 -0
- data/lib/tasks/erp_agreements_tasks.rake +4 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +44 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +8 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/spec.rb +27 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/agreement.rb +4 -0
- data/spec/factories/agreement_item.rb +4 -0
- data/spec/factories/agreement_item_type.rb +4 -0
- data/spec/factories/agreement_party_role.rb +4 -0
- data/spec/factories/agreement_relationship.rb +4 -0
- data/spec/factories/agreement_reln_type.rb +4 -0
- data/spec/models/agreement_item_spec.rb +11 -0
- data/spec/models/agreement_item_type_spec.rb +11 -0
- data/spec/models/agreement_party_role_spec.rb +12 -0
- data/spec/models/agreement_relationship_spec.rb +55 -0
- data/spec/models/agreement_reln_type_spec.rb +12 -0
- data/spec/models/agreement_role_type_spec.rb +13 -0
- data/spec/models/agreement_spec.rb +63 -0
- data/spec/models/agreement_type_spec.rb +11 -0
- data/spec/models/loyalty_program_code_spec.rb +12 -0
- data/spec/spec_helper.rb +61 -0
- metadata +191 -0
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'ErpAgreements'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
28
|
+
require "rspec/core/rake_task"
|
29
|
+
RSpec::Core::RakeTask.new(:spec)
|
30
|
+
task :default => :spec
|
31
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require jquery
|
8
|
+
//= require jquery_ujs
|
9
|
+
//= require_tree .
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Agreement < ActiveRecord::Base
|
2
|
+
|
3
|
+
belongs_to :agreement_type
|
4
|
+
has_many :agreement_items
|
5
|
+
has_many :agreement_party_roles
|
6
|
+
has_many :parties, :through => :agreement_party_roles
|
7
|
+
belongs_to :agreement_record, :polymorphic => true, :dependent => :destroy
|
8
|
+
|
9
|
+
alias :items :agreement_items
|
10
|
+
|
11
|
+
def agreement_relationships
|
12
|
+
AgreementRelationship.where('agreement_id_from = ? OR agreement_id_to = ?',id,id)
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
description
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_label
|
20
|
+
to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def find_parties_by_role(role)
|
24
|
+
self.parties.where("role_type_id = ?", role.id).all
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_item_by_item_type_internal_identifier(item_type_internal_identifier)
|
28
|
+
agreement_items.joins("join agreement_item_types on
|
29
|
+
agreement_item_types.id =
|
30
|
+
agreement_items.agreement_item_type_id").where("agreement_item_types.internal_identifier = '#{item_type_internal_identifier}'").first
|
31
|
+
end
|
32
|
+
|
33
|
+
def respond_to?(m)
|
34
|
+
((get_item_by_item_type_internal_identifier(m.to_s).nil? ? false : true)) unless super
|
35
|
+
end
|
36
|
+
|
37
|
+
def method_missing(m, *args, &block)
|
38
|
+
agreement_item = get_item_by_item_type_internal_identifier(m.to_s)
|
39
|
+
(agreement_item.nil?) ? super : (return agreement_item.agreement_item_value)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class AgreementRelationship < ActiveRecord::Base
|
2
|
+
belongs_to :agreement_from, :class_name => "Agreement", :foreign_key => "agreement_id_from"
|
3
|
+
belongs_to :agreement_to, :class_name => "Agreement", :foreign_key => "agreement_id_to"
|
4
|
+
|
5
|
+
belongs_to :from_role , :class_name => 'AgreementRoleType', :foreign_key => 'role_type_id_from'
|
6
|
+
belongs_to :to_role , :class_name => 'AgreementRoleType', :foreign_key => 'role_type_id_to'
|
7
|
+
|
8
|
+
belongs_to :relationship_type, :class_name => 'AgreementRelnType', :foreign_key => 'agreement_reln_type_id'
|
9
|
+
|
10
|
+
#convenience class methods to return an instance of this class with the from_role, to_role and
|
11
|
+
#relationship_type set using an internal_identifier for the relationship_type. Note that
|
12
|
+
#you still need to set the from and to parties and any contracts / accounts.
|
13
|
+
|
14
|
+
def self.for_relationship_type( rel_type )
|
15
|
+
reln = self.new
|
16
|
+
reln.relationship_type = rel_type
|
17
|
+
reln.from_role = rel_type.valid_from_role
|
18
|
+
reln.to_role = rel_type.valid_to_role
|
19
|
+
reln
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.for_relationship_type_identifier( internal_identifier )
|
23
|
+
relationship_type = AgreementRelnType.find_by_internal_identifier( internal_identifier )
|
24
|
+
self.for_relationship_type( relationship_type )
|
25
|
+
end
|
26
|
+
|
27
|
+
#this is a shortcut for the 'self.for_relationship_type_identifier( internal_identifier )' method
|
28
|
+
def self.for_reln_type_id( internal_identifier )
|
29
|
+
self.for_relationship_type_identifier( internal_identifier )
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class AgreementRelnType < ActiveRecord::Base
|
2
|
+
acts_as_nested_set
|
3
|
+
include ErpTechSvcs::Utils::DefaultNestedSetMethods
|
4
|
+
|
5
|
+
belongs_to :valid_from_role, :class_name => "AgreementRoleType", :foreign_key => "valid_from_role_type_id"
|
6
|
+
belongs_to :valid_to_role, :class_name => "AgreementRoleType", :foreign_key => "valid_to_role_type_id"
|
7
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>ErpAgreements</title>
|
5
|
+
<%= stylesheet_link_tag "erp_agreements/application" %>
|
6
|
+
<%= javascript_include_tag "erp_agreements/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
RussellEdge::HasManyPolymorphic::Engine.add_models("Agreement")
|
data/config/routes.rb
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
class AgreementsServices < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
|
4
|
+
# Create agreements
|
5
|
+
unless table_exists?(:agreements)
|
6
|
+
create_table :agreements do |t|
|
7
|
+
t.column :description, :string
|
8
|
+
t.column :agreement_type_id, :integer
|
9
|
+
t.column :agreement_status, :string
|
10
|
+
t.column :product_id, :integer
|
11
|
+
t.column :agreement_date, :date
|
12
|
+
t.column :from_date, :date
|
13
|
+
t.column :thru_date, :date
|
14
|
+
t.column :external_identifier, :string
|
15
|
+
t.column :external_id_source, :string
|
16
|
+
|
17
|
+
t.timestamps
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Create agreement types
|
22
|
+
unless table_exists?(:agreement_types)
|
23
|
+
create_table :agreement_types do |t|
|
24
|
+
t.column :parent_id, :integer
|
25
|
+
t.column :lft, :integer
|
26
|
+
t.column :rgt, :integer
|
27
|
+
|
28
|
+
#custom columns go here
|
29
|
+
t.column :description, :string
|
30
|
+
t.column :comments, :string
|
31
|
+
t.column :internal_identifier, :string
|
32
|
+
t.column :external_identifier, :string
|
33
|
+
t.column :external_id_source, :string
|
34
|
+
|
35
|
+
t.timestamps
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Create agreement items
|
40
|
+
unless table_exists?(:agreement_items)
|
41
|
+
create_table :agreement_items do |t|
|
42
|
+
t.column :agreement_id, :integer
|
43
|
+
t.column :agreement_item_type_id, :integer
|
44
|
+
t.column :agreement_item_value, :string
|
45
|
+
t.column :description, :string
|
46
|
+
t.column :agreement_item_rule_string, :string
|
47
|
+
|
48
|
+
t.timestamps
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Create agreement item types
|
53
|
+
unless table_exists?(:agreement_item_types)
|
54
|
+
create_table :agreement_item_types do |t|
|
55
|
+
t.column :parent_id, :integer
|
56
|
+
t.column :lft, :integer
|
57
|
+
t.column :rgt, :integer
|
58
|
+
|
59
|
+
#custom columns go here
|
60
|
+
t.column :description, :string
|
61
|
+
t.column :comments, :string
|
62
|
+
t.column :internal_identifier, :string
|
63
|
+
t.column :external_identifier, :string
|
64
|
+
t.column :external_id_source, :string
|
65
|
+
|
66
|
+
t.timestamps
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Create agreement_party_roles
|
71
|
+
unless table_exists?(:agreement_party_roles)
|
72
|
+
create_table :agreement_party_roles do |t|
|
73
|
+
t.column :description, :string
|
74
|
+
t.column :agreement_id, :integer
|
75
|
+
t.column :party_id, :integer
|
76
|
+
t.column :role_type_id, :integer
|
77
|
+
t.column :external_identifier, :string
|
78
|
+
t.column :external_id_source, :string
|
79
|
+
|
80
|
+
t.timestamps
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
unless table_exists?(:agreement_relationships)
|
85
|
+
create_table :agreement_relationships do |t|
|
86
|
+
t.column :agreement_reln_type_id, :integer
|
87
|
+
t.column :description, :string
|
88
|
+
t.column :agreement_id_from, :integer
|
89
|
+
t.column :agreement_id_to, :integer
|
90
|
+
t.column :role_type_id_from, :integer
|
91
|
+
t.column :role_type_id_to, :integer
|
92
|
+
t.column :status_type_id, :integer
|
93
|
+
t.column :from_date, :date
|
94
|
+
t.column :thru_date, :date
|
95
|
+
|
96
|
+
t.timestamps
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
unless table_exists?(:agreement_reln_types)
|
101
|
+
create_table :agreement_reln_types do |t|
|
102
|
+
t.column :parent_id, :integer
|
103
|
+
t.column :lft, :integer
|
104
|
+
t.column :rgt, :integer
|
105
|
+
#custom columns go here
|
106
|
+
t.column :valid_from_role_type_id, :integer
|
107
|
+
t.column :valid_to_role_type_id, :integer
|
108
|
+
t.column :name, :string
|
109
|
+
t.column :description, :string
|
110
|
+
t.column :internal_identifier, :string
|
111
|
+
t.column :external_identifier, :string
|
112
|
+
t.column :external_id_source, :string
|
113
|
+
|
114
|
+
t.timestamps
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
unless table_exists?(:agreement_role_types)
|
119
|
+
create_table :agreement_role_types do |t|
|
120
|
+
|
121
|
+
t.column :parent_id, :integer
|
122
|
+
t.column :lft, :integer
|
123
|
+
t.column :rgt, :integer
|
124
|
+
#custom columns go here
|
125
|
+
t.column :description, :string
|
126
|
+
t.column :comments, :string
|
127
|
+
t.column :internal_identifier, :string
|
128
|
+
t.column :external_identifier, :string
|
129
|
+
t.column :external_id_source, :string
|
130
|
+
|
131
|
+
t.timestamps
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
unless table_exists?(:loyalty_program_codes)
|
136
|
+
create_table :loyalty_program_codes do |t|
|
137
|
+
t.string :identifier
|
138
|
+
t.string :name
|
139
|
+
t.string :description
|
140
|
+
|
141
|
+
t.timestamps
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.down
|
148
|
+
[
|
149
|
+
:loyalty_program_codes, :agreement_role_types, :agreement_reln_types,
|
150
|
+
:agreement_relationships, :agreement_party_roles, :agreement_item_types,
|
151
|
+
:agreement_items, :agreements
|
152
|
+
].each do |tbl|
|
153
|
+
if table_exists?(tbl)
|
154
|
+
drop_table tbl
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class AgreementsServicesIndexes < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
add_index :agreements, :agreement_type_id
|
4
|
+
add_index :agreements, :product_id
|
5
|
+
|
6
|
+
add_index :agreement_types, :parent_id
|
7
|
+
|
8
|
+
add_index :agreement_items, :agreement_id
|
9
|
+
add_index :agreement_items, :agreement_item_type_id
|
10
|
+
|
11
|
+
add_index :agreement_item_types, :parent_id
|
12
|
+
|
13
|
+
add_index :agreement_party_roles, :agreement_id
|
14
|
+
add_index :agreement_party_roles, :party_id
|
15
|
+
add_index :agreement_party_roles, :role_type_id
|
16
|
+
|
17
|
+
add_index :agreement_relationships, :agreement_reln_type_id
|
18
|
+
add_index :agreement_relationships, :status_type_id
|
19
|
+
|
20
|
+
add_index :agreement_reln_types, :parent_id
|
21
|
+
add_index :agreement_reln_types, :valid_from_role_type_id
|
22
|
+
add_index :agreement_reln_types, :valid_to_role_type_id
|
23
|
+
|
24
|
+
add_index :agreement_role_types, :parent_id
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.down
|
28
|
+
remove_index :agreements, :agreement_type_id
|
29
|
+
remove_index :agreements, :product_id
|
30
|
+
|
31
|
+
remove_index :agreement_types, :parent_id
|
32
|
+
|
33
|
+
remove_index :agreement_items, :agreement_id
|
34
|
+
remove_index :agreement_items, :agreement_item_type_id
|
35
|
+
|
36
|
+
remove_index :agreement_item_types, :parent_id
|
37
|
+
|
38
|
+
remove_index :agreement_party_roles, :agreement_id
|
39
|
+
remove_index :agreement_party_roles, :party_id
|
40
|
+
remove_index :agreement_party_roles, :role_type_id
|
41
|
+
|
42
|
+
remove_index :agreement_relationships, :agreement_reln_type_id
|
43
|
+
remove_index :agreement_relationships, :status_type_id
|
44
|
+
|
45
|
+
remove_index :agreement_reln_types, :parent_id
|
46
|
+
remove_index :agreement_reln_types, :valid_from_role_type_id
|
47
|
+
remove_index :agreement_reln_types, :valid_to_role_type_id
|
48
|
+
|
49
|
+
remove_index :agreement_role_types, :parent_id
|
50
|
+
end
|
51
|
+
end
|