effective_cpd 0.4.3 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/admin/cpd_statement_activities_controller.rb +13 -0
  3. data/app/controllers/effective/cpd_statement_activities_controller.rb +1 -1
  4. data/app/datatables/admin/effective_cpd_categories_datatable.rb +2 -1
  5. data/app/datatables/admin/effective_cpd_cycles_datatable.rb +1 -1
  6. data/app/datatables/admin/effective_cpd_statement_activities_datatable.rb +39 -0
  7. data/app/datatables/admin/effective_cpd_statements_datatable.rb +10 -4
  8. data/app/datatables/effective_cpd_available_cycles_datatable.rb +5 -0
  9. data/app/datatables/effective_cpd_completed_statements_datatable.rb +6 -1
  10. data/app/helpers/effective_cpd_helper.rb +0 -1
  11. data/app/models/concerns/effective_cpd_user.rb +7 -0
  12. data/app/models/effective/cpd_activity.rb +1 -0
  13. data/app/models/effective/cpd_cycle.rb +5 -0
  14. data/app/models/effective/cpd_rule.rb +2 -2
  15. data/app/models/effective/cpd_scorer.rb +7 -3
  16. data/app/models/effective/cpd_special_rule.rb +2 -2
  17. data/app/models/effective/cpd_statement.rb +9 -2
  18. data/app/models/effective/cpd_statement_activity.rb +13 -0
  19. data/app/views/admin/cpd_activities/_form.html.haml +1 -0
  20. data/app/views/admin/cpd_categories/_form.html.haml +2 -2
  21. data/app/views/admin/cpd_cycles/_form_cpd_rules.html.haml +6 -1
  22. data/app/views/effective/cpd_audit_reviews/_layout.html.haml +2 -2
  23. data/app/views/effective/cpd_audits/_layout.html.haml +2 -2
  24. data/app/views/effective/cpd_statement_activities/_cpd_statement_activity.html.haml +3 -3
  25. data/app/views/effective/cpd_statement_activities/_form.html.haml +6 -5
  26. data/app/views/effective/cpd_statements/_activities_table.html.haml +1 -1
  27. data/app/views/effective/cpd_statements/_layout.html.haml +1 -1
  28. data/app/views/effective/cpd_statements/_summary.html.haml +9 -7
  29. data/config/routes.rb +1 -0
  30. data/db/migrate/01_create_effective_cpd.rb.erb +8 -2
  31. data/lib/effective_cpd/version.rb +1 -1
  32. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a4a0dc542b4aab7be7e662920d7d9c8c01b365debd9ba594bb6ffe92f4f3ccc
4
- data.tar.gz: cd1039d075de6ca26ee36fc38c5790599e1d6761aa1fe0e5fc9791e4294709cb
3
+ metadata.gz: bd54ef80261e5f2ed12db4d7d287e614d289fd3ad1472f8017e03f9661bd4320
4
+ data.tar.gz: 83539b1cd3c70cafc551fa29d49edb8af593f8979acd21170ef7f04cbbf440c8
5
5
  SHA512:
6
- metadata.gz: 9fb17b6984b76cc262edf4f85f898dd1b09e3338b388e178edb12068bc8eede3501b6314186a97fa28ecfbc81380df81d6316865321fe93ccf5d068ecbf7b5dd
7
- data.tar.gz: 0c514c94d8ff831ebdbd7431d00bd07e7f7b452721c0cbb17958381ace13e2e5426c3c8c73ba797d47e4c8c7fc2d69ad23061ff28d01da4c471ecfbc54cded6d
6
+ metadata.gz: f6342549a0bc5ded97f765e2bae7858d106cb93b6db69c8c25d7940120bd8d48138ed87306cfab136535c407edb4dcca84f26c0ee984df20758c10e8087372f7
7
+ data.tar.gz: c5f2027d52f8871a47635dbcd170ddeb3a98c28d897407c9790d59c21dab469bec2da0c6d14d209addd768e2b73486338a52e9969b1bf112a13ff667a6d8e3f5
@@ -0,0 +1,13 @@
1
+ module Admin
2
+ class CpdStatementActivitiesController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_cpd) }
5
+
6
+ include Effective::CrudController
7
+
8
+ # def permitted_params
9
+ # params.require(:effective_cpd_statement).permit!
10
+ # end
11
+
12
+ end
13
+ end
@@ -19,7 +19,7 @@ module Effective
19
19
 
20
20
  def permitted_params
21
21
  params.require(:effective_cpd_statement_activity).permit(
22
- :id, :cpd_category_id, :cpd_activity_id, :amount, :amount2, :description, files: []
22
+ :id, :cpd_category_id, :cpd_activity_id, :amount, :amount2, :date, :description, files: []
23
23
  )
24
24
  end
25
25
 
@@ -9,9 +9,10 @@ module Admin
9
9
  col :updated_at, visible: false
10
10
 
11
11
  col :title do |cpd_category|
12
- content_tag(:div, cpd_category.title) + raw(cpd_category.body)
12
+ content_tag(:div, cpd_category.title)
13
13
  end
14
14
 
15
+ col :body, visible: false
15
16
  col :cpd_activities, label: 'Activities'
16
17
 
17
18
  actions_col
@@ -10,7 +10,7 @@ module Admin
10
10
  col :title
11
11
  col :start_at
12
12
  col :end_at
13
- col :required_score
13
+ col :required_score, label: 'Required'
14
14
 
15
15
  actions_col
16
16
  end
@@ -0,0 +1,39 @@
1
+ module Admin
2
+ class EffectiveCpdStatementActivitiesDatatable < Effective::Datatable
3
+ filters do
4
+ scope :all
5
+ scope :draft, label: 'In Progress'
6
+ scope :completed, label: 'Submitted'
7
+ end
8
+
9
+ datatable do
10
+ order :updated_at
11
+
12
+ col :id, visible: false
13
+ col :created_at, visible: false
14
+ col :updated_at, visible: false
15
+
16
+ col :cpd_cycle, label: cpd_cycle_label.capitalize, search: Effective::CpdCycle.sorted
17
+ col :cpd_statement, visible: false
18
+
19
+ col :user
20
+
21
+ col :date
22
+ col :description
23
+
24
+ col :score, label: cpd_credits_label.capitalize do |csa|
25
+ cpd_score(csa.score)
26
+ end
27
+
28
+ col :carry_forward do |csa|
29
+ cpd_score(csa.carry_forward)
30
+ end
31
+
32
+ actions_col
33
+ end
34
+
35
+ collection do
36
+ Effective::CpdStatementActivity.all.deep.joins(:cpd_statement)
37
+ end
38
+ end
39
+ end
@@ -3,7 +3,7 @@ module Admin
3
3
  filters do
4
4
  scope :all
5
5
  scope :draft, label: 'In Progress'
6
- scope :completed
6
+ scope :completed, label: 'Submitted'
7
7
  end
8
8
 
9
9
  datatable do
@@ -14,14 +14,20 @@ module Admin
14
14
  col :created_at, visible: false
15
15
  col :updated_at, visible: false
16
16
 
17
- col :cpd_cycle, label: cpd_cycle_label.titleize
17
+ col :cpd_cycle, label: cpd_cycle_label.capitalize, search: Effective::CpdCycle.sorted
18
18
  col :user
19
- col :submitted_at, as: :date, label: 'Submitted'
19
+ col :submitted_at, as: :date, label: 'Submitted on'
20
20
 
21
- col :score do |cpd_statement|
21
+ col :score, label: cpd_credits_label.capitalize do |cpd_statement|
22
22
  cpd_score(cpd_statement.score)
23
23
  end
24
24
 
25
+ if attributes[:user_id].present?
26
+ col :required_score, label: 'Required' do |cpd_statement|
27
+ cpd_score(cpd_statement.required_score || cpd_statement.targeted_score)
28
+ end
29
+ end
30
+
25
31
  col :carry_forward do |cpd_statement|
26
32
  cpd_score(cpd_statement.carry_forward)
27
33
  end
@@ -9,6 +9,11 @@ class EffectiveCpdAvailableCyclesDatatable < Effective::Datatable
9
9
  col(:title, label: cpd_cycle_label.titleize)
10
10
  col :available_date, label: 'Available'
11
11
 
12
+ col :required_score, label: 'Required' do |cpd_cycle|
13
+ cpd_statement = Effective::CpdStatement.new(cpd_cycle: cpd_cycle, user: current_user)
14
+ cpd_score(cpd_statement.required_score || cpd_statement.targeted_score)
15
+ end
16
+
12
17
  actions_col(actions: []) do |cpd_cycle|
13
18
  statement = cpd_cycle.cpd_statements.where(user: current_user).first
14
19
 
@@ -9,7 +9,12 @@ class EffectiveCpdCompletedStatementsDatatable < Effective::Datatable
9
9
  end
10
10
 
11
11
  col :submitted_at, as: :date, label: 'Submitted'
12
- col :score
12
+ col :score, label: cpd_credits_label.capitalize
13
+
14
+ col :required_score, label: 'Required' do |cpd_statement|
15
+ cpd_score(cpd_statement.required_score || cpd_statement.targeted_score)
16
+ end
17
+
13
18
  col :carry_forward
14
19
 
15
20
  unless attributes[:actions] == false
@@ -45,7 +45,6 @@ module EffectiveCpdHelper
45
45
  end
46
46
 
47
47
  def cpd_score(value)
48
- raise('expected a BigDecimal') unless value.nil? || value.kind_of?(BigDecimal)
49
48
  ("%.#{2}f" % value.to_d)
50
49
  end
51
50
 
@@ -20,10 +20,17 @@ module EffectiveCpdUser
20
20
  accepts_nested_attributes_for :cpd_statements
21
21
  end
22
22
 
23
+ # This one will actually be enforced or displayed first
23
24
  def cpd_statement_required_score(cpd_statement)
24
25
  nil
25
26
  end
26
27
 
28
+ # This one will be displayed on the sidebar if first one is nil
29
+ # Won't actually block the submission
30
+ def cpd_statement_targeted_score(cpd_statement)
31
+ nil
32
+ end
33
+
27
34
  def cpd_audit_cpd_required?
28
35
  true
29
36
  end
@@ -22,6 +22,7 @@ module Effective
22
22
 
23
23
  # Whether the user must attach supporting documents
24
24
  requires_upload_file :boolean
25
+ requires_date :boolean
25
26
 
26
27
  timestamps
27
28
  end
@@ -78,6 +78,11 @@ module Effective
78
78
  title.presence || 'New CPD Cycle'
79
79
  end
80
80
 
81
+ # Todo, implement a cpd cycle targeted score entirely
82
+ def targeted_score
83
+ nil
84
+ end
85
+
81
86
  def build_from_cycle(cycle:)
82
87
  raise('expected a CpdCycle') unless cycle.kind_of?(CpdCycle)
83
88
 
@@ -22,7 +22,7 @@ module Effective
22
22
  credit_description :text
23
23
 
24
24
  # The maximum credits per cycle a statement. Nil for no limit
25
- max_credits_per_cycle :integer
25
+ max_credits_per_cycle :decimal
26
26
 
27
27
  # (amount / 15) or (30) or (amount * 2) or (amount + (amount2 * 10))
28
28
  formula :string
@@ -44,7 +44,7 @@ module Effective
44
44
  scope :unavailable, -> { where(unavailable: true) }
45
45
 
46
46
  #validates :cpd_cycle_id, uniqueness: { scope: [:ruleable_id, :ruleable_type] }
47
- validates :max_credits_per_cycle, numericality: { greater_than: 0, allow_nil: true }
47
+ validates :max_credits_per_cycle, numericality: { greater_than: 0.0, allow_nil: true }
48
48
  validates :max_cycles_can_carry_forward, numericality: { greater_than_or_equal_to: 0, allow_nil: true }
49
49
 
50
50
  validates :formula, presence: true, if: -> { activity? }
@@ -60,7 +60,7 @@ module Effective
60
60
  # This scores and enforces CycleActivity.max_credits_per_cycle
61
61
  statement.cpd_statement_activities.group_by(&:cpd_activity).each do |cpd_activity, activities|
62
62
  rule = cycle.rule_for(cpd_activity)
63
- max_credits_per_cycle = rule.max_credits_per_cycle || 9999999
63
+ max_credits_per_cycle = rule.max_credits_per_cycle || 9999999.0
64
64
 
65
65
  activities.each do |activity|
66
66
  next if activity.marked_for_destruction?
@@ -141,9 +141,13 @@ module Effective
141
141
  return false if (activity.carry_forward == 0 || activity.marked_for_destruction?)
142
142
 
143
143
  from_cycle = @cycles.find { |cycle| cycle.id == (activity.original || activity).cpd_statement.cpd_cycle_id }
144
- max_cycles_can_carry_forward = from_cycle.rule_for(activity.cpd_activity).max_cycles_can_carry_forward
145
144
 
146
- return true if max_cycles_can_carry_forward.blank?
145
+ max_carry_activity = from_cycle.rule_for(activity.cpd_activity).max_cycles_can_carry_forward
146
+ max_carry_category = from_cycle.rule_for(activity.cpd_category).max_cycles_can_carry_forward
147
+
148
+ return true if max_carry_activity.blank? && max_carry_category.blank?
149
+
150
+ max_cycles_can_carry_forward = [max_carry_activity, max_carry_category].compact.min
147
151
 
148
152
  cycles_carried = (@cycles.index(to_cycle) || @cycles.size) - @cycles.index(from_cycle)
149
153
  cycles_carried <= max_cycles_can_carry_forward
@@ -15,7 +15,7 @@ module Effective
15
15
  category :string # Special rule tyoes
16
16
 
17
17
  # For cumulative max credits
18
- max_credits_per_cycle :integer
18
+ max_credits_per_cycle :decimal
19
19
 
20
20
  timestamps
21
21
  end
@@ -30,7 +30,7 @@ module Effective
30
30
  validates :category, presence: true, inclusion: { in: CATEGORIES }
31
31
 
32
32
  with_options(if: -> { cumulative_max_credits? }) do
33
- validates :max_credits_per_cycle, presence: true, numericality: { greater_than: 0 }
33
+ validates :max_credits_per_cycle, presence: true, numericality: { greater_than: 0.0 }
34
34
  end
35
35
 
36
36
  def to_s
@@ -55,7 +55,7 @@ module Effective
55
55
  end
56
56
 
57
57
  validate(if: -> { completed? }) do
58
- min = required_score()
58
+ min = required_score() || 0.0
59
59
  self.errors.add(:score, "must be #{min} or greater to submit a statement") if score < min
60
60
  end
61
61
 
@@ -107,7 +107,14 @@ module Effective
107
107
  required_by_cycle = cpd_cycle&.required_score
108
108
  required_by_user = user.cpd_statement_required_score(self) if user.respond_to?(:cpd_statement_required_score)
109
109
 
110
- [required_by_cycle.to_d, required_by_user.to_d].max
110
+ [required_by_cycle, required_by_user].compact.max
111
+ end
112
+
113
+ def targeted_score
114
+ targeted_by_cycle = cpd_cycle&.targeted_score
115
+ targeted_by_user = user.cpd_statement_targeted_score(self) if user.respond_to?(:cpd_statement_targeted_score)
116
+
117
+ [targeted_by_cycle, targeted_by_user].compact.max
111
118
  end
112
119
 
113
120
  def carry_forward
@@ -7,6 +7,10 @@ module Effective
7
7
  belongs_to :cpd_category
8
8
  belongs_to :cpd_activity
9
9
 
10
+ # Denormalized from cpd_statement
11
+ belongs_to :cpd_cycle
12
+ belongs_to :user, polymorphic: true
13
+
10
14
  belongs_to :original, class_name: 'CpdStatementActivity', optional: true # If this is a Carryover, the original_statement_activity will be set.
11
15
  #has_many :carried, class_name: 'CpdStatementActivity', foreign_key: 'original_id', dependent: :delete_all
12
16
 
@@ -20,6 +24,7 @@ module Effective
20
24
  amount :decimal
21
25
  amount2 :decimal
22
26
 
27
+ date :date
23
28
  description :text
24
29
 
25
30
  carry_over :decimal # carry_over_from_last_cycle
@@ -36,9 +41,17 @@ module Effective
36
41
  scope :deep, -> { includes(:cpd_statement, :cpd_category, :cpd_activity, :original) }
37
42
  scope :sorted, -> { order(:id) }
38
43
 
44
+ scope :draft, -> { where(cpd_statement_id: CpdStatement.draft) }
45
+ scope :completed, -> { where(cpd_statement_id: CpdStatement.completed) }
46
+
39
47
  validates :original, presence: true, if: -> { (carry_over || 0) > 0 }
40
48
  validates :description, presence: true
41
49
 
50
+ before_validation(if: -> { cpd_statement.present? }) do
51
+ self.cpd_cycle ||= cpd_statement.cpd_cycle
52
+ self.user ||= cpd_statement.user
53
+ end
54
+
42
55
  validate(if: -> { new_record? && cpd_statement.present? }, unless: -> { importing }) do
43
56
  self.errors.add(:base, "statement has already been completed") if cpd_statement.completed?
44
57
  self.errors.add(:base, "cycle is unavailable") unless cpd_statement.cpd_cycle.available?
@@ -21,5 +21,6 @@
21
21
  hint: 'continuing education units'
22
22
 
23
23
  = f.check_box :requires_upload_file
24
+ = f.check_box :requires_date
24
25
 
25
26
  = effective_submit(f)
@@ -1,7 +1,7 @@
1
1
  = tabs do
2
2
  = tab 'Category' do
3
3
  - if cpd_category.persisted?
4
- .alert.alert-warning
4
+ .alert.alert-warning.mb-4
5
5
  Changes to categories and activities will be displayed in all #{cpd_cycles_label}.
6
6
 
7
7
  = render 'admin/cpd_categories/form_cpd_category', cpd_category: cpd_category
@@ -10,7 +10,7 @@
10
10
  %h2 Activities
11
11
  %p
12
12
  After adding an activity here, please visit any existing
13
- = link_to(cpd_cycles_label.titleize + ' Settings', effective_cpd.admin_cpd_cycles_path)
13
+ = link_to(cpd_cycle_label.capitalize + ' Settings', effective_cpd.admin_cpd_cycles_path)
14
14
  pages and build a rule before it will be displayed.
15
15
 
16
16
  - datatable = Admin::EffectiveCpdActivitiesDatatable.new(cpd_category_id: cpd_category.id)
@@ -12,6 +12,10 @@
12
12
  = fc.number_field :max_credits_per_cycle,
13
13
  label: "Max #{cpd_credits_label} per #{cpd_cycle_label}",
14
14
  hint: "The maximum number of #{cpd_credits_label} that may be earned in this category for this #{cpd_cycle_label}. Leave blank for no limit."
15
+
16
+ = fc.number_field :max_cycles_can_carry_forward,
17
+ label: "Max #{cpd_cycles_label} can carry forward",
18
+ hint: "leave blank for no limit. enter zero for no carry forward."
15
19
  .col
16
20
  = fc.select :cpd_special_rule_ids, cpd_cycle.cpd_special_rules, multiple: true,
17
21
  label: 'Special Rules', hint: "Special rules operate on more than one category at a time"
@@ -46,11 +50,12 @@
46
50
  = f.static_field :amount_label, value: activity.amount_label.presence || '-'
47
51
  = f.static_field :amount2_label, value: activity.amount2_label.presence || '-'
48
52
  = f.static_field :requires_upload_file, value: (activity.requires_upload_file ? 'Yes' : '-')
53
+ = f.static_field :requires_date, value: (activity.requires_date ? 'Yes' : '-')
49
54
 
50
55
  .col
51
56
  = fa.text_field :formula, hint: cpd_rule_formula_hint(activity)
52
57
 
53
- = fa.text_field :credit_description, label: "#{cpd_credits_label.titleize} description",
58
+ = fa.text_field :credit_description, label: "#{cpd_credits_label.capitalize} description",
54
59
  hint: "A simple description of the formula and its #{cpd_credits_label} calculation"
55
60
 
56
61
  = fa.number_field :max_credits_per_cycle,
@@ -16,9 +16,9 @@
16
16
  %h1= @page_title
17
17
 
18
18
  - if resource.cpd_audit_level.rich_text_all_steps_audit_review_content.present?
19
- .mb-2= resource.cpd_audit_level.rich_text_all_steps_audit_review_content
19
+ .mb-2= resource.cpd_audit_level.rich_text_all_steps_audit_review_content.to_s
20
20
 
21
21
  - if resource.cpd_audit_level.send("rich_text_#{step}_audit_review_content").present?
22
- .mb-2= resource.cpd_audit_level.send("rich_text_#{step}_audit_review_content")
22
+ .mb-2= resource.cpd_audit_level.send("rich_text_#{step}_audit_review_content").to_s
23
23
 
24
24
  = yield
@@ -25,9 +25,9 @@
25
25
  %h1= @page_title
26
26
 
27
27
  - if resource.cpd_audit_level.rich_text_all_steps_audit_content.present?
28
- .mb-2= resource.cpd_audit_level.rich_text_all_steps_audit_content
28
+ .mb-2= resource.cpd_audit_level.rich_text_all_steps_audit_content.to_s
29
29
 
30
30
  - if resource.cpd_audit_level.send("rich_text_#{step}_audit_content").present?
31
- .mb-2= resource.cpd_audit_level.send("rich_text_#{step}_audit_content")
31
+ .mb-2= resource.cpd_audit_level.send("rich_text_#{step}_audit_content").to_s
32
32
 
33
33
  = yield
@@ -22,7 +22,7 @@
22
22
  .row
23
23
  - if cpd_activity.amount_label.present?
24
24
  .col
25
- %strong= cpd_activity.amount_label
25
+ %strong= cpd_activity.amount_label.capitalize
26
26
  %br
27
27
  = cpd_score(cpd_statement_activity.amount)
28
28
 
@@ -40,14 +40,14 @@
40
40
  .col-sm-4
41
41
  .row
42
42
  .col.text-center
43
- %strong= cpd_credits_label.titleize
43
+ %strong= cpd_credits_label.capitalize
44
44
  %br
45
45
  - if cpd_statement_activity.reduced_messages.present?
46
46
  %span{title: cpd_statement_activity.reduced_messages.values.join("\n\n")}= "#{cpd_score(cpd_statement_activity.score)} *"
47
47
  - else
48
48
  = cpd_score(cpd_statement_activity.score)
49
49
 
50
- .col.text-center
50
+ .col.text-center.carry-forward
51
51
  %strong Carry
52
52
  %br
53
53
  = cpd_score(cpd_statement_activity.carry_forward)
@@ -19,20 +19,20 @@
19
19
 
20
20
  .row.my-3
21
21
  .col-8
22
- %strong #{cpd_credits_label.titleize} Calculation
22
+ %strong #{cpd_credits_label.capitalize} Calculation
23
23
  %br
24
24
  = rule.credit_description
25
25
 
26
26
  .col-2.text-center
27
27
  - if f.object.persisted?
28
- %strong= cpd_credits_label.titleize
28
+ %strong= cpd_credits_label.capitalize
29
29
  %br
30
30
  - if f.object.reduced_messages.present?
31
31
  %span{title: f.object.reduced_messages.values.join("\n\n")}= "#{cpd_score(f.object.score)} *"
32
32
  - else
33
33
  = cpd_score(f.object.score)
34
34
 
35
- .col-2.text-center
35
+ .col-2.text-center.carry-forward
36
36
  - if f.object.persisted?
37
37
  %strong Carry Forward
38
38
  %br
@@ -41,15 +41,16 @@
41
41
  .row
42
42
  .col
43
43
  - if activity.amount_label.present?
44
- = f.float_field :amount, label: activity.amount_label, required: true
44
+ = f.float_field :amount, label: activity.amount_label.capitalize, required: true
45
45
 
46
46
  - if activity.amount2_label.present?
47
- = f.float_field :amount2, label: activity.amount2_label, required: true
47
+ = f.float_field :amount2, label: activity.amount2_label.capitalize, required: true
48
48
 
49
49
  - if activity.amount_static?
50
50
  = f.hidden_field :amount, value: 1
51
51
  %p One (1) #{activity}
52
52
 
53
+ = f.date_field :date, required: activity.requires_date?
53
54
  = f.file_field :files, label: 'Supporting Documents', required: activity.requires_upload_file?
54
55
 
55
56
  .col
@@ -2,7 +2,7 @@
2
2
  .row
3
3
  .col-8
4
4
  .col-2.score
5
- %strong= cpd_credits_label.titleize
5
+ %strong= cpd_credits_label.capitalize
6
6
  .col-2.carry-forward
7
7
  %strong Carry Forward
8
8
 
@@ -22,7 +22,7 @@
22
22
  %h4= cpd_score(resource.score.to_d)
23
23
 
24
24
  %td
25
- #{cpd_credits_label} out of #{resource.required_score.to_i} required
25
+ #{cpd_credits_label} out of #{(resource.required_score || resource.targeted_score).to_d} required
26
26
 
27
27
  %tr
28
28
  %td
@@ -8,10 +8,12 @@
8
8
  %br
9
9
  %small= mail_to cpd_statement.user.email
10
10
 
11
- - if request.path.start_with?('/admin') && respond_to?(:edit_admin_user_path)
12
- %tr
13
- %th User
14
- %td= link_to(cpd_statement.user, edit_admin_user_path(cpd_statement.user))
11
+ - if request.path.start_with?('/admin')
12
+ %tr
13
+ %th User
14
+ %td
15
+ - url = (polymorphic_admin_path(cpd_statement.user) rescue "/admin/users/#{cpd_statement.user.to_param}/edit")
16
+ = link_to(cpd_statement.user, url)
15
17
 
16
18
  - if cpd_statement.completed?
17
19
  %tr
@@ -19,13 +21,13 @@
19
21
  %td= cpd_statement.submitted_at.strftime('%F %H:%M')
20
22
 
21
23
  %tr
22
- %th= cpd_cycle_label.titleize
24
+ %th= cpd_cycle_label.capitalize
23
25
  %td= cpd_statement.cpd_cycle
24
26
 
25
27
  %tr
26
- %th Total #{cpd_credits_label.titleize}
28
+ %th Total #{cpd_credits_label}
27
29
  %td= cpd_score(cpd_statement.score)
28
30
 
29
- %tr
31
+ %tr.carry-forward
30
32
  %th Carry Forward
31
33
  %td= cpd_score(cpd_statement.carry_forward)
data/config/routes.rb CHANGED
@@ -30,6 +30,7 @@ EffectiveCpd::Engine.routes.draw do
30
30
  namespace :admin do
31
31
  resources :cpd_categories, except: [:show]
32
32
  resources :cpd_activities, except: [:show]
33
+ resources :cpd_statement_activities, only: [:index, :show]
33
34
  resources :cpd_cycles, except: [:show]
34
35
  resources :cpd_rules, only: [:index]
35
36
  resources :cpd_special_rules, except: [:show]
@@ -30,6 +30,7 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
30
30
  t.string :amount2_label
31
31
 
32
32
  t.boolean :requires_upload_file, default: false
33
+ t.boolean :requires_date, default: false
33
34
 
34
35
  t.datetime :updated_at
35
36
  t.datetime :created_at
@@ -43,7 +44,7 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
43
44
  t.text :credit_description
44
45
  t.string :formula
45
46
 
46
- t.integer :max_credits_per_cycle
47
+ t.decimal :max_credits_per_cycle
47
48
  t.integer :max_cycles_can_carry_forward
48
49
  t.boolean :unavailable, default: false
49
50
 
@@ -54,7 +55,7 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
54
55
  create_table <%= @cpd_special_rules_table_name %> do |t|
55
56
  t.references :cpd_cycle
56
57
 
57
- t.integer :max_credits_per_cycle
58
+ t.decimal :max_credits_per_cycle
58
59
  t.string :category
59
60
 
60
61
  t.datetime :updated_at
@@ -75,9 +76,14 @@ class CreateEffectiveCpd < ActiveRecord::Migration[6.0]
75
76
  t.references :cpd_category
76
77
  t.references :original
77
78
 
79
+ t.references :cpd_cycle
80
+ t.integer :user_id
81
+ t.string :user_type
82
+
78
83
  t.decimal :amount, precision: 10, scale: 2
79
84
  t.decimal :amount2, precision: 10, scale: 2
80
85
 
86
+ t.date :date
81
87
  t.text :description
82
88
 
83
89
  t.decimal :carry_over, precision: 10, scale: 2
@@ -1,3 +1,3 @@
1
1
  module EffectiveCpd
2
- VERSION = '0.4.3'
2
+ VERSION = '0.5.1'
3
3
  end
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.3
4
+ version: 0.5.1
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: 2022-09-09 00:00:00.000000000 Z
11
+ date: 2022-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -189,6 +189,7 @@ files:
189
189
  - app/controllers/admin/cpd_cycles_controller.rb
190
190
  - app/controllers/admin/cpd_rules_controller.rb
191
191
  - app/controllers/admin/cpd_special_rules_controller.rb
192
+ - app/controllers/admin/cpd_statement_activities_controller.rb
192
193
  - app/controllers/admin/cpd_statements_controller.rb
193
194
  - app/controllers/effective/cpd_audit_reviews_controller.rb
194
195
  - app/controllers/effective/cpd_audits_controller.rb
@@ -204,6 +205,7 @@ files:
204
205
  - app/datatables/admin/effective_cpd_cycles_datatable.rb
205
206
  - app/datatables/admin/effective_cpd_rules_datatable.rb
206
207
  - app/datatables/admin/effective_cpd_special_rules_datatable.rb
208
+ - app/datatables/admin/effective_cpd_statement_activities_datatable.rb
207
209
  - app/datatables/admin/effective_cpd_statements_datatable.rb
208
210
  - app/datatables/effective_cpd_available_audit_reviews_datatable.rb
209
211
  - app/datatables/effective_cpd_available_audits_datatable.rb