Banking: blocking risky transfers
Three rules, in order of priority: a high amount or a sensitive country makes the transfer risky, and a risky transfer is blocked. The rules can be read by the compliance department.
Result obtained on the server: the 15,500 € transfer to the Cayman Islands is blocked; the 820 € one remains pending.
$Banque = [ontology:define "Banque_Securite"
[ontology:class Virement
[attributes
[montant Float [required true]]
[pays_destination String [default "France"]]
[niveau_risque String [default "FAIBLE"]]
[statut String [default "EN_ATTENTE"]]]]]
[ontology:rule "MontantEleve" $Banque [target "Virement"] [priority 100]
[when ($this.montant > 10000)]
[then [ontology:set $this "niveau_risque" "ELEVE"]]]
[ontology:rule "PaysSensible" $Banque [target "Virement"] [priority 90]
[when ($this.pays_destination == "Iles Caimans")]
[then [ontology:set $this "niveau_risque" "ELEVE"]]]
[ontology:rule "Blocage" $Banque [target "Virement"] [priority 10]
[when ($this.niveau_risque == "ELEVE")]
[then [ontology:set $this "statut" "BLOQUE"]]]
[ontology:commit [new Virement [montant 15500] [pays_destination "Iles Caimans"]]]
[ontology:commit [new Virement [montant 820]]]
[ontology:infer-fixpoint $Banque 10]
[ontology:select $Banque "Virement" [statut "BLOQUE"]]