// Création d'une échéance à partir de la définition du contrat échéanciers private EcheanceContrat CreateEcheanceFromContratEcheancier( int index, Contrat _contrat, PeriodeContrat _periodeUneEcheance) { // Attibuts var _Contrat = _contrat; var _ContratId = _Contrat.Id; // calcul de la date échéance var _DatePremiereEcheance = _contrat.DatePremiereEcheance; var _DateEcheanceMoment = _DatePremiereEcheance; // Init switch (_periodeUneEcheance.unite) { case "months": _DateEcheanceMoment = _DatePremiereEcheance .AddMonths(index * _periodeUneEcheance.nombre); break; case "weeks": _DateEcheanceMoment = _DatePremiereEcheance .AddDays(index * _periodeUneEcheance.nombre * 7); break; default: break; } var _DateEcheance = _DateEcheanceMoment; var _libelleMois = String.Format("{0:D}", _DateEcheanceMoment); // _DateEcheanceMoment.format('YYYY-MMMM'); // Calcul du libellé var _Libelle = _libelleMois; //var _Libelle = _libelleMois.CharAt(0).toUpperCase() + _libelleMois.Slice(1); // Calcul du montant var _Montant = _contrat.MontantEcheance; // Compte et moyen de paiement var _Compte = _contrat.Compte; var _CompteId = _Compte.Id; var _MoyenPaiement = _contrat.MoyenPaiement; var _MoyenPaiementId = _MoyenPaiement.Id; var _IsCaisse = _contrat.IsCaisse; var _ConvertibleOperation = _contrat.ConvertibleOperation; var _EcheanceImputable = _contrat.EcheanceImputable; var _ABatcher = _contrat.ABatcher; // Commentaire var _dateFormattee = String.Format("{0:D}", DateTime.Now); var _Commentaire = "Echéance générée automatiquement le " + _dateFormattee; // Attention: Year et Month ne sont pas calculés ici. var echeance = new EcheanceContrat { Compte = _Compte , CompteId = _CompteId , ContratId = _ContratId , Contrat = _Contrat , MoyenPaiement = _MoyenPaiement , MoyenPaiementId = _MoyenPaiementId , Libelle = _Libelle , Montant = _Montant , DateEcheance = _DateEcheance , IsCaisse = _IsCaisse , ConvertibleOperation = _ConvertibleOperation , EcheanceImputable = _EcheanceImputable , Commentaire = _Commentaire , ABatcher = _ABatcher }; return echeance; }
private void DupliquerContrat(Contrat _contrat) { // Récupération des échéances de la période courante var _echeances = uow.EcheanceContrat .GetAllByGroupeId(groupeId) .Where(ech => ech.ContratId == _contrat.Id) .Where(ech => ech.DateEcheance >= _contrat.DateDebut) .Where(ech => ech.DateEcheance <= _contrat.DateFin) .OrderBy(ech => ech.DateEcheance) ; // Calcul des nouvelles échéances _contrat.Echeances = new List<EcheanceContrat>(); int nombreEcheances = _echeances.Count(); for (var i = 0; i < nombreEcheances; i++) { var previousEch = _echeances.ElementAt(i); var newEch = CreateEcheanceFromPrevious(_contrat, previousEch); _contrat.Echeances.Add(newEch); }; }
// CreateEcheanceFromPrevious private EcheanceContrat CreateEcheanceFromPrevious(Contrat contrat , EcheanceContrat previousEch) { // calcul de la date échéance var _PreviousDateEcheance = previousEch.DateEcheance; var _NextDateEcheance = _PreviousDateEcheance; // Init var _unite = contrat.Budget.UnitePeriodeDepense; var _nbreUnite = contrat.Budget.NombreUnitePeriodeDepense; switch (_unite) { case "months": _NextDateEcheance = _PreviousDateEcheance.AddMonths(_nbreUnite); break; case "weeks": _NextDateEcheance = _PreviousDateEcheance.AddDays(_nbreUnite * 7); break; default: break; } // Commentaire var _dateFormattee = String.Format("{0:D}", DateTime.Now); var _Commentaire = "Echéance générée automatiquement le " + _dateFormattee; // Attention: Year et Month ne sont pas calculés ici. var echeance = new EcheanceContrat { Compte = previousEch.Compte , CompteId = previousEch.CompteId , ContratId = previousEch.ContratId , Contrat = previousEch.Contrat , MoyenPaiement = previousEch.MoyenPaiement , MoyenPaiementId = previousEch.MoyenPaiementId , Libelle = String.Format("{0:D}", _NextDateEcheance) , Montant = previousEch.Montant , DateEcheance = _NextDateEcheance , IsCaisse = previousEch.IsCaisse , ConvertibleOperation = previousEch.ConvertibleOperation , EcheanceImputable = previousEch.EcheanceImputable , Commentaire = _Commentaire , ABatcher = previousEch.ABatcher }; // Retour return echeance; }
public SoldeContrat(Contrat _contrat) { this.Contrat = _contrat; }