erp_communication_events 4.0.0 → 4.2.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.
- checksums.yaml +4 -4
- data/app/models/comm_evt_purpose_type.rb +19 -0
- data/app/models/communication_event.rb +129 -14
- data/app/models/communication_event_pty_role.rb +20 -0
- data/app/models/extensions/party.rb +16 -2
- data/db/migrate/20160113185606_update_communication_events.rb +29 -0
- data/db/migrate/20160310163058_add_created_by_updated_by_to_erp_communication_events.rb +35 -0
- data/db/migrate/20160608193204_add_communication_event_party_roles.rb +64 -0
- data/lib/erp_communication_events/version.rb +1 -1
- metadata +11 -8
- data/db/migrate/20140519144444_add_custom_fields_to_comm_evt.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d777fb52b7db802076cf451808a097320c4fffad
|
4
|
+
data.tar.gz: 044663c2f550314136c07781eb9614fcaf55ea2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74f4ea8bf1cd002d45bcbd8f94c57f61360bc36c52178cd6b39e4759f43654140a731a4e015622ce26ada1b2fd2c83347cc13099163ea536eb808642cfa5cec4
|
7
|
+
data.tar.gz: 49438a4840011be4fb8318b56c8f84bf8cc126023382dc22e820c1a93b66976095c48bb519b7fa73e3ea12d05ad9de34dee3b3ade7057e0bd3b083d95eff16c5
|
@@ -12,4 +12,23 @@ class CommEvtPurposeType < ActiveRecord::Base
|
|
12
12
|
"#{description}"
|
13
13
|
end
|
14
14
|
|
15
|
+
class << self
|
16
|
+
def iid(internal_identifier)
|
17
|
+
self.find_by_internal_identifier(internal_identifier)
|
18
|
+
end
|
19
|
+
|
20
|
+
def find_or_create(internal_identifier, description)
|
21
|
+
activity_stream_entry_type = self.iid(internal_identifier)
|
22
|
+
|
23
|
+
unless activity_stream_entry_type
|
24
|
+
activity_stream_entry_type = CommEvtPurposeType.create(
|
25
|
+
internal_identifier: internal_identifier,
|
26
|
+
description: description
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
activity_stream_entry_type
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
15
34
|
end
|
@@ -1,27 +1,142 @@
|
|
1
|
+
# create_table :communication_events do |t|
|
2
|
+
# t.integer :from_contact_mechanism_id
|
3
|
+
# t.string :from_contact_mechanism_type
|
4
|
+
#
|
5
|
+
# t.integer :to_contact_mechanism_id
|
6
|
+
# t.string :to_contact_mechanism_type
|
7
|
+
#
|
8
|
+
# t.string :short_description
|
9
|
+
# t.integer :case_id
|
10
|
+
# t.datetime :start_at
|
11
|
+
# t.datetime :end_at
|
12
|
+
# t.string :notes
|
13
|
+
# t.string :external_identifier
|
14
|
+
# t.string :external_id_source
|
15
|
+
#
|
16
|
+
# t.timestamps
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# add_index :communication_events, :status_type_id
|
20
|
+
# add_index :communication_events, :case_id
|
21
|
+
# add_index :communication_events, [:to_contact_mechanism_id, :to_contact_mechanism_type], :name => 'to_contact_mech_idx'
|
22
|
+
# add_index :communication_events, [:from_contact_mechanism_id, :from_contact_mechanism_type], :name => 'from_contact_mech_idx'
|
23
|
+
|
1
24
|
class CommunicationEvent < ActiveRecord::Base
|
2
25
|
attr_protected :created_at, :updated_at
|
3
26
|
|
4
|
-
belongs_to :from_party, :class_name => 'Party', :foreign_key => 'party_id_from'
|
5
|
-
belongs_to :to_party , :class_name => 'Party', :foreign_key => 'party_id_to'
|
6
|
-
|
7
|
-
belongs_to :from_role , :class_name => 'RoleType', :foreign_key => 'role_type_id_from'
|
8
|
-
belongs_to :to_role , :class_name => 'RoleType', :foreign_key => 'role_type_id_to'
|
9
|
-
|
10
|
-
belongs_to :comm_evt_status, :class_name => 'CommEvtStatus', :foreign_key => 'status_type_id'
|
11
|
-
|
12
27
|
belongs_to :from_contact_mechanism, :polymorphic => true
|
13
28
|
belongs_to :to_contact_mechanism, :polymorphic => true
|
14
29
|
|
15
30
|
has_and_belongs_to_many :comm_evt_purpose_types, :join_table => 'comm_evt_purposes'
|
16
31
|
|
17
|
-
|
18
|
-
|
32
|
+
has_many :communication_event_pty_roles, dependent: :destroy
|
33
|
+
|
34
|
+
has_tracked_status
|
35
|
+
tracks_created_by_updated_by
|
36
|
+
|
37
|
+
class << self
|
38
|
+
# scope by party
|
39
|
+
#
|
40
|
+
# @param party [Integer | Party | Array] either a id of Party record, a Party record, an array of Party records
|
41
|
+
# or an array of Party ids
|
42
|
+
# @param options [Hash] options to apply to this scope
|
43
|
+
# @option options [Array] :role_types role types to include in the scope
|
44
|
+
#
|
45
|
+
# @return [ActiveRecord::Relation]
|
46
|
+
def scope_by_party(party, options={})
|
47
|
+
if options[:role_types]
|
48
|
+
joins(communication_event_pty_roles: :role_type)
|
49
|
+
.where(communication_event_pty_roles: {party_id: party, role_type_id: options[:role_types]})
|
50
|
+
|
51
|
+
else
|
52
|
+
joins(:communication_event_pty_roles).where(communication_event_pty_roles: {party_id: party})
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def parties
|
58
|
+
Party.joins(:communication_event_pty_roles)
|
59
|
+
.where(communication_event_pty_roles: {communication_event_id: self.id})
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_parties
|
63
|
+
parties.joins(communication_event_pty_roles: :role_type)
|
64
|
+
.where(role_types: {internal_identifier: 'communication_events_to'})
|
65
|
+
end
|
66
|
+
|
67
|
+
def from_parties
|
68
|
+
parties.joins(communication_event_pty_roles: :role_type)
|
69
|
+
.where(role_types: {internal_identifier: 'communication_events_from'})
|
70
|
+
end
|
71
|
+
|
72
|
+
# Helper method if this communication event only has one to party
|
73
|
+
#
|
74
|
+
def to_party
|
75
|
+
to_parties.first
|
76
|
+
end
|
77
|
+
|
78
|
+
# Helper method if this communication event only has one to party
|
79
|
+
#
|
80
|
+
def to_party=(party)
|
81
|
+
remove_to_parties
|
82
|
+
|
83
|
+
add_party(party, 'communication_events_to')
|
84
|
+
end
|
85
|
+
|
86
|
+
# Helper method if this communication event only has one from party
|
87
|
+
#
|
88
|
+
def from_party
|
89
|
+
from_parties.first
|
90
|
+
end
|
91
|
+
|
92
|
+
# Helper method if this communication event only has one from party
|
93
|
+
#
|
94
|
+
def from_party=(party)
|
95
|
+
remove_from_parties
|
96
|
+
|
97
|
+
add_party(party, 'communication_events_from')
|
98
|
+
end
|
99
|
+
|
100
|
+
def add_from_party(party)
|
101
|
+
add_party(party, 'communication_events_from')
|
102
|
+
end
|
103
|
+
|
104
|
+
def remove_from_parties
|
105
|
+
remove_parties('communication_events_from')
|
106
|
+
end
|
107
|
+
|
108
|
+
def add_to_party(party)
|
109
|
+
add_party(party, 'communication_events_to')
|
110
|
+
end
|
111
|
+
|
112
|
+
def remove_to_parties
|
113
|
+
remove_parties('communication_events_to')
|
114
|
+
end
|
115
|
+
|
116
|
+
# Add party with role type
|
117
|
+
#
|
118
|
+
def add_party(party, role_type)
|
119
|
+
if role_type.is_a? String
|
120
|
+
role_type = RoleType.iid(role_type)
|
121
|
+
end
|
122
|
+
|
123
|
+
communication_event_pty_roles.create(party: party, role_type: role_type)
|
124
|
+
end
|
125
|
+
|
126
|
+
def remove_parties(role_type)
|
127
|
+
if role_type.is_a? String
|
128
|
+
role_type = RoleType.iid(role_type)
|
129
|
+
end
|
19
130
|
|
20
|
-
|
21
|
-
|
131
|
+
communication_event_pty_roles.joins(:role_type)
|
132
|
+
.where(role_types: {id: role_type}).each do |communication_event_pty_role|
|
133
|
+
communication_event_pty_role.destroy
|
134
|
+
end
|
135
|
+
end
|
22
136
|
|
23
|
-
def
|
137
|
+
def to_s
|
24
138
|
"#{short_description}"
|
25
|
-
end
|
139
|
+
end
|
140
|
+
alias :to_label :to_s
|
26
141
|
|
27
142
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# create_table :communication_event_pty_roles do |t|
|
2
|
+
# t.references :party
|
3
|
+
# t.references :communication_event
|
4
|
+
# t.references :role_type
|
5
|
+
#
|
6
|
+
# t.timestamps
|
7
|
+
# end
|
8
|
+
|
9
|
+
# add_index :communication_event_pty_roles, :party_id, name: 'comm_evt_pty_role_pty_idx'
|
10
|
+
# add_index :communication_event_pty_roles, :communication_event_id, name: 'comm_evt_pty_role_comm_evt_idx'
|
11
|
+
# add_index :communication_event_pty_roles, :role_type_id, name: 'comm_evt_pty_role_role_idx'
|
12
|
+
|
13
|
+
class CommunicationEventPtyRole < ActiveRecord::Base
|
14
|
+
attr_protected :created_at, :updated_at
|
15
|
+
|
16
|
+
belongs_to :party
|
17
|
+
belongs_to :communication_event
|
18
|
+
belongs_to :role_type
|
19
|
+
|
20
|
+
end
|
@@ -1,6 +1,20 @@
|
|
1
1
|
Party.class_eval do
|
2
2
|
|
3
|
-
has_many :
|
4
|
-
|
3
|
+
has_many :communication_event_pty_roles, dependent: :destroy
|
4
|
+
|
5
|
+
def communication_events
|
6
|
+
CommunicationEvent.joins(:communication_event_pty_roles)
|
7
|
+
.where(communication_event_pty_roles: {party_id: self.id})
|
8
|
+
end
|
9
|
+
|
10
|
+
def from_communication_events
|
11
|
+
communication_events.joins(communication_event_pty_roles: :role_type)
|
12
|
+
.where(role_types: {internal_identifier: 'communication_events_from'})
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_communication_events
|
16
|
+
communication_events.joins(communication_event_pty_roles: :role_type)
|
17
|
+
.where(role_types: {internal_identifier: 'communication_events_to'})
|
18
|
+
end
|
5
19
|
|
6
20
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class UpdateCommunicationEvents < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
unless column_exists? :communication_events, :start_at
|
4
|
+
rename_column :communication_events, :date_time_started, :start_at
|
5
|
+
end
|
6
|
+
|
7
|
+
unless column_exists? :communication_events, :end_at
|
8
|
+
rename_column :communication_events, :date_time_ended, :end_at
|
9
|
+
end
|
10
|
+
|
11
|
+
if column_exists? :communication_events, :status_type_id
|
12
|
+
remove_column :communication_events, :status_type_id
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def down
|
17
|
+
if column_exists? :communication_events, :start_at
|
18
|
+
rename_column :communication_events, :start_at, :date_time_started
|
19
|
+
end
|
20
|
+
|
21
|
+
if column_exists? :communication_events, :end_at
|
22
|
+
rename_column :communication_events, :end_at, :date_time_ended
|
23
|
+
end
|
24
|
+
|
25
|
+
unless column_exists? :communication_events, :status_type_id
|
26
|
+
add_column :communication_events, :status_type_id, :integer
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class AddCreatedByUpdatedByToErpCommunicationEvents < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
%w{communication_events}.each do |table|
|
4
|
+
|
5
|
+
unless column_exists? table.to_sym, :created_by_party_id
|
6
|
+
add_column table.to_sym, :created_by_party_id, :integer
|
7
|
+
|
8
|
+
add_index table.to_sym, :created_by_party_id, name: "#{table}_created_by_pty_idx"
|
9
|
+
end
|
10
|
+
|
11
|
+
unless column_exists? table.to_sym, :updated_by_party_id
|
12
|
+
add_column table.to_sym, :updated_by_party_id, :integer
|
13
|
+
|
14
|
+
add_index table.to_sym, :updated_by_party_id, name: "#{table}_updated_by_pty_idx"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def down
|
22
|
+
%w{communication_events}.each do |table|
|
23
|
+
|
24
|
+
if column_exists? table.to_sym, :created_by_party_id
|
25
|
+
remove_column table.to_sym, :created_by_party_id
|
26
|
+
end
|
27
|
+
|
28
|
+
if column_exists? table.to_sym, :updated_by_party_id
|
29
|
+
remove_column table.to_sym, :updated_by_party_id
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class AddCommunicationEventPartyRoles < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
|
4
|
+
unless table_exists? :communication_event_pty_roles
|
5
|
+
create_table :communication_event_pty_roles do |t|
|
6
|
+
t.references :party
|
7
|
+
t.references :communication_event
|
8
|
+
t.references :role_type
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index :communication_event_pty_roles, :party_id, name: 'comm_evt_pty_role_pty_idx'
|
14
|
+
add_index :communication_event_pty_roles, :communication_event_id, name: 'comm_evt_pty_role_comm_evt_idx'
|
15
|
+
add_index :communication_event_pty_roles, :role_type_id, name: 'comm_evt_pty_role_role_idx'
|
16
|
+
|
17
|
+
communication_events_role_type = RoleType.find_or_create('communication_events', 'Communication Events')
|
18
|
+
to_role_type = RoleType.find_or_create('communication_events_to', 'To', communication_events_role_type)
|
19
|
+
from_role_type = RoleType.find_or_create('communication_events_from', 'From', communication_events_role_type)
|
20
|
+
|
21
|
+
result = select_all "Select * from communication_events"
|
22
|
+
|
23
|
+
result.each do |row|
|
24
|
+
unless row['party_id_from'].blank?
|
25
|
+
CommunicationEventPtyRole.create(
|
26
|
+
party_id: row['party_id_from'],
|
27
|
+
communication_event_id: row['id'],
|
28
|
+
role_type: from_role_type
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
unless row['party_id_to'].blank?
|
33
|
+
CommunicationEventPtyRole.create(
|
34
|
+
party_id: row['party_id_to'],
|
35
|
+
communication_event_id: row['id'],
|
36
|
+
role_type: to_role_type
|
37
|
+
)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
remove_column :communication_events, :party_id_from
|
42
|
+
remove_column :communication_events, :party_id_to
|
43
|
+
remove_column :communication_events, :role_type_id_from
|
44
|
+
remove_column :communication_events, :role_type_id_to
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def down
|
50
|
+
if table_exists? :communication_event_pty_roles
|
51
|
+
add_column :communication_events, :party_id_from, :integer
|
52
|
+
add_column :communication_events, :party_id_to, :integer
|
53
|
+
add_column :communication_events, :role_type_id_from, :integer
|
54
|
+
add_column :communication_events, :role_type_id_to, :integer
|
55
|
+
|
56
|
+
add_index :communication_events, :role_type_id_from
|
57
|
+
add_index :communication_events, :role_type_id_to
|
58
|
+
add_index :communication_events, :party_id_from
|
59
|
+
add_index :communication_events, :party_id_to
|
60
|
+
|
61
|
+
drop_table :communication_event_pty_roles
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erp_communication_events
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rick Koloski, Russell Holmes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erp_tech_svcs
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '4.
|
19
|
+
version: '4.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '4.
|
26
|
+
version: '4.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: erp_dev_svcs
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '4.
|
33
|
+
version: '4.2'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '4.
|
40
|
+
version: '4.2'
|
41
41
|
description: ErpCommunicationEvents add models and services to CompassAE's ERP core
|
42
42
|
to handle contacts between Business Parties. For example, tracking inbound or outbound
|
43
43
|
emails, customer contact events, support requests, etc. These models would be used
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- app/models/comm_evt_purpose_type.rb
|
58
58
|
- app/models/comm_evt_status.rb
|
59
59
|
- app/models/communication_event.rb
|
60
|
+
- app/models/communication_event_pty_role.rb
|
60
61
|
- app/models/extensions/email_address.rb
|
61
62
|
- app/models/extensions/party.rb
|
62
63
|
- app/models/extensions/phone_number.rb
|
@@ -67,7 +68,9 @@ files:
|
|
67
68
|
- app/observers/postal_address_change_event_observer.rb
|
68
69
|
- config/routes.rb
|
69
70
|
- db/migrate/20080805000080_communication_events_services.rb
|
70
|
-
- db/migrate/
|
71
|
+
- db/migrate/20160113185606_update_communication_events.rb
|
72
|
+
- db/migrate/20160310163058_add_created_by_updated_by_to_erp_communication_events.rb
|
73
|
+
- db/migrate/20160608193204_add_communication_event_party_roles.rb
|
71
74
|
- lib/erp_communication_events.rb
|
72
75
|
- lib/erp_communication_events/engine.rb
|
73
76
|
- lib/erp_communication_events/version.rb
|
@@ -122,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
125
|
version: '0'
|
123
126
|
requirements: []
|
124
127
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.4.8
|
126
129
|
signing_key:
|
127
130
|
specification_version: 4
|
128
131
|
summary: ErpCommunicationEvents add models and services to CompassAE's ERP core to
|