effective_cpd 0.1.19 → 0.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/datatables/admin/effective_cpd_statements_datatable.rb +8 -2
- data/app/helpers/effective_cpd_helper.rb +5 -0
- data/app/models/effective/cpd_rule.rb +4 -2
- data/app/models/effective/cpd_scorer.rb +1 -1
- data/app/models/effective/cpd_statement.rb +4 -4
- data/app/models/effective/cpd_statement_activity.rb +6 -6
- data/app/views/effective/cpd_audits/_layout.html.haml +1 -1
- data/app/views/effective/cpd_statement_activities/_cpd_statement_activity.html.haml +5 -5
- data/app/views/effective/cpd_statement_activities/_form.html.haml +5 -5
- data/app/views/effective/cpd_statements/_activities_new.html.haml +1 -1
- data/app/views/effective/cpd_statements/_activities_table.html.haml +6 -6
- data/app/views/effective/cpd_statements/_layout.html.haml +3 -3
- data/app/views/effective/cpd_statements/_summary.html.haml +2 -2
- data/db/migrate/01_create_effective_cpd.rb.erb +6 -6
- data/lib/effective_cpd/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80e098e09ddea7dbc4d43707500e647e1795dd750b63f6e21ac44512a430fbcb
|
4
|
+
data.tar.gz: 72590ba94aa5535c8431afb6bcd4a4ef1b4a90be5f21f120914c94dbcfbe4cd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3b459b4701245f5953e2ce0d01135dbc19e8d5587ba0a7e1b2e9de94897ae7c59e940b7bd8b3ad364e2bd1c8b78c617f83da2ffa075cb8e4fc19670d6b94f18
|
7
|
+
data.tar.gz: 238cc81c30a48006ca4e4886cdd654add4b322dd3bd612e5186e0b6fb15bb50a24639fa434639ca32d86506ef165a369ab22435f60d17c7a2e255f643975e42e
|
@@ -17,8 +17,14 @@ module Admin
|
|
17
17
|
col :cpd_cycle, label: cpd_cycle_label.titleize
|
18
18
|
col :user
|
19
19
|
col :submitted_at, as: :date, label: 'Submitted'
|
20
|
-
|
21
|
-
col :
|
20
|
+
|
21
|
+
col :score do |cpd_statement|
|
22
|
+
cpd_score(cpd_statement.score)
|
23
|
+
end
|
24
|
+
|
25
|
+
col :carry_forward do |cpd_statement|
|
26
|
+
cpd_score(cpd_statement.carry_forward)
|
27
|
+
end
|
22
28
|
|
23
29
|
actions_col
|
24
30
|
end
|
@@ -117,10 +117,12 @@ module Effective
|
|
117
117
|
private
|
118
118
|
|
119
119
|
def eval_equation(amount: nil, amount2: nil)
|
120
|
-
return 0 if formula.blank?
|
120
|
+
return BigDecimal(0) if formula.blank?
|
121
121
|
|
122
122
|
equation = formula.gsub('amount2', amount2.to_s).gsub('amount', amount.to_s)
|
123
|
-
|
123
|
+
|
124
|
+
# Returns a BigDecimal
|
125
|
+
eval(equation).to_d
|
124
126
|
end
|
125
127
|
|
126
128
|
end
|
@@ -103,7 +103,7 @@ module Effective
|
|
103
103
|
cpd_categories = special_rule.ruleables.select { |obj| obj.kind_of?(Effective::CpdCategory) }
|
104
104
|
|
105
105
|
max_credits_per_cycle = special_rule.max_credits_per_cycle
|
106
|
-
raise('expected max credits per cycle to be present') unless max_credits_per_cycle
|
106
|
+
raise('expected max credits per cycle to be present') unless (max_credits_per_cycle || 0) > 0
|
107
107
|
|
108
108
|
activities = statement.cpd_statement_activities.select { |sa| cpd_categories.include?(sa.cpd_category) }
|
109
109
|
|
@@ -97,17 +97,17 @@ module Effective
|
|
97
97
|
required_by_cycle = cpd_cycle&.required_score
|
98
98
|
required_by_user = user.cpd_statement_required_score(self) if user.respond_to?(:cpd_statement_required_score)
|
99
99
|
|
100
|
-
[required_by_cycle.
|
100
|
+
[required_by_cycle.to_d, required_by_user.to_d].max
|
101
101
|
end
|
102
102
|
|
103
103
|
def carry_forward
|
104
|
-
cpd_statement_activities.sum { |activity| activity.carry_forward
|
104
|
+
cpd_statement_activities.sum { |activity| activity.carry_forward || BigDecimal(0) }.to_d
|
105
105
|
end
|
106
106
|
|
107
107
|
# {category_id => 20, category_id => 15}
|
108
108
|
def score_per_category
|
109
|
-
@score_per_category ||= Hash.new(0).tap do |scores|
|
110
|
-
cpd_statement_activities.each { |activity| scores[activity.cpd_category_id] += activity.score.
|
109
|
+
@score_per_category ||= Hash.new(BigDecimal(0)).tap do |scores|
|
110
|
+
cpd_statement_activities.each { |activity| scores[activity.cpd_category_id] += activity.score.to_d }
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -16,14 +16,14 @@ module Effective
|
|
16
16
|
end
|
17
17
|
|
18
18
|
effective_resource do
|
19
|
-
amount :
|
20
|
-
amount2 :
|
19
|
+
amount :decimal
|
20
|
+
amount2 :decimal
|
21
21
|
|
22
22
|
description :text
|
23
23
|
|
24
|
-
carry_over :
|
25
|
-
score :
|
26
|
-
carry_forward :
|
24
|
+
carry_over :decimal # carry_over_from_last_cycle
|
25
|
+
score :decimal
|
26
|
+
carry_forward :decimal # carry_forward_to_next_cycle
|
27
27
|
|
28
28
|
reduced_messages :text
|
29
29
|
|
@@ -35,7 +35,7 @@ module Effective
|
|
35
35
|
scope :deep, -> { includes(:cpd_statement, :cpd_category, :cpd_activity, :original) }
|
36
36
|
scope :sorted, -> { order(:id) }
|
37
37
|
|
38
|
-
validates :original, presence: true, if: -> { carry_over
|
38
|
+
validates :original, presence: true, if: -> { (carry_over || 0) > 0 }
|
39
39
|
validates :description, presence: true
|
40
40
|
|
41
41
|
validate(if: -> { new_record? && cpd_statement.present? }) do
|
@@ -24,12 +24,12 @@
|
|
24
24
|
.col
|
25
25
|
%strong= cpd_activity.amount_label
|
26
26
|
%br
|
27
|
-
= cpd_statement_activity.amount
|
27
|
+
= cpd_score(cpd_statement_activity.amount)
|
28
28
|
|
29
29
|
- if cpd_activity.amount2_label.present?
|
30
30
|
.col.text-center
|
31
31
|
%strong= cpd_activity.amount2_label
|
32
|
-
= cpd_statement_activity.amount2
|
32
|
+
= cpd_score(cpd_statement_activity.amount2)
|
33
33
|
|
34
34
|
- if cpd_activity.amount_static?
|
35
35
|
.col
|
@@ -43,14 +43,14 @@
|
|
43
43
|
%strong= cpd_credits_label.titleize
|
44
44
|
%br
|
45
45
|
- if cpd_statement_activity.reduced_messages.present?
|
46
|
-
%span{title: cpd_statement_activity.reduced_messages.values.join("\n\n")}= "#{cpd_statement_activity.score} *"
|
46
|
+
%span{title: cpd_statement_activity.reduced_messages.values.join("\n\n")}= "#{cpd_score(cpd_statement_activity.score)} *"
|
47
47
|
- else
|
48
|
-
= cpd_statement_activity.score
|
48
|
+
= cpd_score(cpd_statement_activity.score)
|
49
49
|
|
50
50
|
.col.text-center
|
51
51
|
%strong Carry
|
52
52
|
%br
|
53
|
-
= cpd_statement_activity.carry_forward
|
53
|
+
= cpd_score(cpd_statement_activity.carry_forward)
|
54
54
|
|
55
55
|
- if cpd_statement_activity.files.present?
|
56
56
|
%p
|
@@ -28,23 +28,23 @@
|
|
28
28
|
%strong= cpd_credits_label.titleize
|
29
29
|
%br
|
30
30
|
- if f.object.reduced_messages.present?
|
31
|
-
%span{title: f.object.reduced_messages.values.join("\n\n")}= "#{f.object.score} *"
|
31
|
+
%span{title: f.object.reduced_messages.values.join("\n\n")}= "#{cpd_score(f.object.score)} *"
|
32
32
|
- else
|
33
|
-
= f.object.score
|
33
|
+
= cpd_score(f.object.score)
|
34
34
|
|
35
35
|
.col-2.text-center
|
36
36
|
- if f.object.persisted?
|
37
37
|
%strong Carry Forward
|
38
38
|
%br
|
39
|
-
= f.object.carry_forward
|
39
|
+
= cpd_score(f.object.carry_forward)
|
40
40
|
|
41
41
|
.row
|
42
42
|
.col
|
43
43
|
- if activity.amount_label.present?
|
44
|
-
= f.
|
44
|
+
= f.float_field :amount, label: activity.amount_label, required: true
|
45
45
|
|
46
46
|
- if activity.amount2_label.present?
|
47
|
-
= f.
|
47
|
+
= f.float_field :amount2, label: activity.amount2_label, required: true
|
48
48
|
|
49
49
|
- if activity.amount_static?
|
50
50
|
= f.hidden_field :amount, value: 1
|
@@ -16,7 +16,7 @@
|
|
16
16
|
%h3
|
17
17
|
#{category}
|
18
18
|
%small
|
19
|
-
= cpd_statement.score_per_category[category.id]
|
19
|
+
= cpd_score(cpd_statement.score_per_category[category.id])
|
20
20
|
- if rule.max_credits_per_cycle.present?
|
21
21
|
= '/'
|
22
22
|
= rule.max_credits_per_cycle
|
@@ -41,12 +41,12 @@
|
|
41
41
|
|
42
42
|
.col-2.score
|
43
43
|
- if statement_activity.reduced_messages.present?
|
44
|
-
%span{title: statement_activity.reduced_messages.values.join("\n\n")}= "#{statement_activity.score} *"
|
44
|
+
%span{title: statement_activity.reduced_messages.values.join("\n\n")}= "#{cpd_score(statement_activity.score)} *"
|
45
45
|
- else
|
46
|
-
= statement_activity.score
|
46
|
+
= cpd_score(statement_activity.score)
|
47
47
|
|
48
48
|
.col-2.carry-forward
|
49
|
-
= statement_activity.carry_forward
|
49
|
+
= cpd_score(statement_activity.carry_forward)
|
50
50
|
|
51
51
|
.statement-activity-form.row{style: 'display: none;'}
|
52
52
|
.col
|
@@ -59,6 +59,6 @@
|
|
59
59
|
.col-8
|
60
60
|
%h4 Total #{cpd_credits_label} in statement
|
61
61
|
.col-2.score
|
62
|
-
%h4= cpd_statement.score
|
62
|
+
%h4= cpd_score(cpd_statement.score)
|
63
63
|
.col-2.carry-forward
|
64
|
-
%h4= cpd_statement.carry_forward
|
64
|
+
%h4= cpd_score(cpd_statement.carry_forward)
|
@@ -19,14 +19,14 @@
|
|
19
19
|
|
20
20
|
%tr
|
21
21
|
%td
|
22
|
-
%h4= resource.score.
|
22
|
+
%h4= cpd_score(resource.score.to_d)
|
23
23
|
|
24
24
|
%td
|
25
|
-
#{cpd_credits_label} out of #{resource.required_score} required
|
25
|
+
#{cpd_credits_label} out of #{resource.required_score.to_i} required
|
26
26
|
|
27
27
|
%tr
|
28
28
|
%td
|
29
|
-
%h4= last_3_scores.
|
29
|
+
%h4= cpd_score(last_3_scores.to_d)
|
30
30
|
|
31
31
|
%td #{cpd_credits_label} in last 3 #{cpd_cycles_label} (including this #{cpd_cycle_label})
|
32
32
|
|
@@ -75,14 +75,14 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
|
|
75
75
|
t.references :cpd_category
|
76
76
|
t.references :original
|
77
77
|
|
78
|
-
t.
|
79
|
-
t.
|
78
|
+
t.decimal :amount, precision: 10, scale: 2
|
79
|
+
t.decimal :amount2, precision: 10, scale: 2
|
80
80
|
|
81
81
|
t.text :description
|
82
82
|
|
83
|
-
t.
|
84
|
-
t.
|
85
|
-
t.
|
83
|
+
t.decimal :carry_over, precision: 10, scale: 2
|
84
|
+
t.decimal :score, precision: 10, scale: 2
|
85
|
+
t.decimal :carry_forward, precision: 10, scale: 2
|
86
86
|
|
87
87
|
t.text :reduced_messages
|
88
88
|
|
@@ -98,7 +98,7 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
|
|
98
98
|
|
99
99
|
t.string :token
|
100
100
|
|
101
|
-
t.
|
101
|
+
t.decimal :score, precision: 10, scale: 2
|
102
102
|
|
103
103
|
t.boolean :confirm_read
|
104
104
|
t.boolean :confirm_factual
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_cpd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|