Skip to content

Commit

Permalink
Fix claims being flagged for qa
Browse files Browse the repository at this point in the history
When a new academic year has started, and we are yet to approved any
claims from this academic year, all claims from the previous year are
flagged for qa when approved. To avoid this we need to count the number
of approved claims in the _claim's_ academic year rather than the
current academic year.
  • Loading branch information
rjlynch committed Oct 2, 2024
1 parent 1ae9923 commit 2fe90f5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,11 @@ def flaggable_for_qa?
def below_min_qa_threshold?
return false if policy::MIN_QA_THRESHOLD.zero?

claims_approved_so_far = Claim.by_policy(policy).current_academic_year.approved.count
approved_claims = Claim.by_policy(policy).by_academic_year(academic_year).approved
claims_approved_so_far = approved_claims.count
return true if claims_approved_so_far.zero?

(Claim.by_policy(policy).current_academic_year.approved.qa_required.count.to_f / claims_approved_so_far) * 100 <= policy::MIN_QA_THRESHOLD
(approved_claims.qa_required.count.to_f / claims_approved_so_far) * 100 <= policy::MIN_QA_THRESHOLD
end

def qa_completed?
Expand Down

0 comments on commit 2fe90f5

Please sign in to comment.