feat(Logic.computable?): add computable? to know if a ineligibilite_rules set is computable

This commit is contained in:
mfo 2024-06-05 17:33:03 +02:00
parent 5de4ce889f
commit 5644692448
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
9 changed files with 141 additions and 0 deletions

View file

@ -269,6 +269,12 @@ class ProcedureRevision < ApplicationRecord
types_de_champ_for(scope: :public).filter(&:conditionable?)
end
def ineligibilite_rules_computable?(champs)
ineligibilite_enabled && ineligibilite_rules&.computable?(champs)
ensure
champs.map(&:reset_visible) # otherwise @visible is cached, then dossier can be updated. champs are not updated
end
private
def compute_estimated_fill_duration
@ -483,6 +489,13 @@ class ProcedureRevision < ApplicationRecord
changes
end
def ineligibilite_rules_are_valid?
if ineligibilite_rules
ineligibilite_rules.errors(types_de_champ_for(scope: :public).to_a)
.each { errors.add(:ineligibilite_rules, :invalid) }
end
end
def replace_type_de_champ_by_clone(coordinate)
cloned_type_de_champ = coordinate.type_de_champ.deep_clone do |original, kopy|
ClonePiecesJustificativesService.clone_attachments(original, kopy)