// _Match: retourne l'indice de confiance public bool Match(Operation operation, OperationRawSG raw, SeuilRappro seuil) { // Type de raw var type = raw.TypeMoyenPaiement; // Choix de la machine budget en fonction du seuil.budgetAutorise if (seuil.BudgetAutorise == false) { BudgetMachine = new BudgetMatchingMachine(); } else { BudgetMachine = new BudgetNonAlloueMatchingMachine(); } //BudgetMachine.fabriqueSpec = fab; // Variation sur type de raw switch (type) { // VIREMENT case "COTISATION": case "FRAIS": case "TELEREGLT": case "TIP": case "ECHEANCE": case "PRELEVEMENT EUROPEEN": case "PRELEVEMENT": case "VIREMENT PAYE": case "VIREMENT RECU": if (MatchVirement(operation, raw, seuil)) { return true; } break; // CHEQUE case "REMISE CHEQUE": case "CHEQUE": if (MatchCheque(operation, raw, seuil)) { return true; } break; // RETRAIT case "RETRAIT": if (MatchRetrait(operation, raw, seuil)) { return true; } break; // CARTE case "CARTE": if (MatchCarte(operation, raw, seuil)) { return true; } break; default: break; } // Par défaut return false; }
// Rapprocher private IList<RapproRaw> RapprocherAvecSeuil(IQueryable<OperationRawSG> raws , IQueryable<Operation> operations, SeuilRappro seuil) { // 1- Parcours des opérations rapprochables non rapprochées // 2- Vérification si possibilité de rapprochement dans liste des raws // 3- Si oui, rapprocher: avec création de rappro // Initialisation des rappros IList<RapproRaw> rappros = new List<RapproRaw>(); // Raw list var rawsList = raws.ToList(); // 1- foreach (var ope in operations) { //if (ope.Libelle.Contains("mercredi")) //{ // var test = ope.DateOperation.ToShortDateString() == DateTime.ParseExact("01/09/2015", "dd/MM/yyyy", CultureInfo.InvariantCulture).ToShortDateString(); // if (test) // { // // then stop debug // var x = 10; // } //} // 2- foreach (var raw in rawsList) { //var test2 = raw.DateOperation.ToShortDateString() == DateTime.ParseExact("02/09/2015", "dd/MM/yyyy", CultureInfo.InvariantCulture).ToShortDateString(); //if (raw.Montant == -15.58M && ope.Montant == 15.56M) // //if (test2) // //{ // { // var z = 10; // } // //} if (ope.Etat != EtatOperationEnum.RAPPROCHEE && raw.Etat == EtatOperationRaw.CREEE) { // Match ope et raw if (machine.Match(ope, raw, seuil)) { // Fabrique rappro string _origine = "RAPPRO with OPERATION FRONTLOADED"; var rappro = fabrique.Produire(ope, raw, seuil.IndiceConfiance, _origine); rappro.Operation.Commentaire = rappro.Operation.Commentaire + "\n" + seuil.Commentaire; // Ajout à la liste des rappros rappros.Add(rappro); // Remove la raw de la liste des raws rawsList.Remove(raw); // Sortie de la boucle break; } } } } // Retour return rappros; }
// Match fonction des types de transaction private bool MatchVirement(Operation operation, OperationRawSG raw, SeuilRappro seuil) { return operation.MoyenPaiementCompteA.Type == EnumTypeMoyenPaiement.VIREMENT && operation.TypeOperation.Libelle == "TransactionCompte" && BudgetMachine.Match(operation, raw) && MatchDate(operation, raw, seuil) && MatchMontant(operation, raw, seuil); }
private bool MatchRetrait(Operation operation, OperationRawSG raw, SeuilRappro seuil) { return operation.MoyenPaiementCompteA.Type == EnumTypeMoyenPaiement.CARTE && operation.TypeOperation.Libelle == "MiseEnCaisse" && BudgetMachine.Match(operation, raw) && MatchDate(operation, raw, seuil) && MatchMontant(operation, raw, seuil); }
// MatchMontant private Boolean MatchMontant(Operation ope, OperationRawSG raw, SeuilRappro seuil) { if (raw.Montant == 0) { return false; } decimal ecart = Math.Abs(ope.Montant - (-raw.Montant)); decimal ecartRelatif = ecart / Math.Abs(raw.Montant); decimal diff = Math.Abs(ecartRelatif - (seuil.DeltaMontant / 100.00M)); if (seuil.DeltaMontant == 3.00M) { if (ope.Montant == 15.58M) { //var stopIt = "say hello"; } } if (ecartRelatif <= seuil.DeltaMontant / 100.00M) //if (diff <= 0.01M) { return true; } return false; }
// MatchDate private Boolean MatchDate(Operation ope, OperationRawSG raw, SeuilRappro seuil) { if ( ope.DateOperation.AddDays(seuil.DeltaDays) >= raw.DateOperation && raw.DateOperation >= ope.DateOperation.AddDays(-seuil.DeltaDays) ) { return true; } return false; }