function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Maxime SavartMaxime Savart 

Building Recurrence for Paiement Terms

Hi all,

I have at the moment this code to build recurrence on paiement terms
            if(this.produitPrincipal.Modalites_de_paiement__c=='Paiement en 2 fois'){this.periode=2;this.periodeText='Facturé en 2 fois';}
            if(this.produitPrincipal.Modalites_de_paiement__c=='Paiement en 3 fois'){this.periode=3;this.periodeText='Facturé en 3 fois';}    
            if(this.produitPrincipal.Modalites_de_paiement__c=='Paiement en 4 fois'){this.periode=4;this.periodeText='Facturé en 4 fois';}
            if(this.produitPrincipal.Modalites_de_paiement__c=='Paiement en 2 fois sur 2 mois glissants'){this.periode=2;this.periodeText='Facturé en 2 fois sur 2 mois glissants';}
            if(this.produitPrincipal.Modalites_de_paiement__c=='Paiement en 3 fois sur 3 mois glissants'){this.periode=3;this.periodeText='Facturé en 3 fois sur 3 mois glissants';}
            if(this.produitPrincipal.Modalites_de_paiement__c=='Paiement en 4 fois sur 4 mois glissants'){this.periode=4;this.periodeText='Facturé en 4 fois sur 4 mois glissants';}
            if(this.produitPrincipal.Modalites_de_paiement__c=='Paiement mensuel'){this.periode=this.dureeContratMonths;this.periodeText='Paiement mensuel';}
            
            this.paiementUpfront = false;
            this.paiementReccurent = (opp.Amount-opp.AmountInstallation__c) / (this.periode);
            this.paiementSignature = opp.AmountInstallation__c+((opp.Amount-opp.AmountInstallation__c) / (this.periode));
            this.recurrence= Integer.valueOf((this.dureeContratMonths/this.periode));
            Date dateDebut = date.newinstance(opp.Date_d_entr_e_en_vigueur_du_contrat__c.year(),
                                              opp.Date_d_entr_e_en_vigueur_du_contrat__c.month(),
                                              26).addMonths(recurrence) ;
            listDateEcheance = new List<Date>();
            listDateEcheance.add(dateDebut);
            for (Integer i = recurrence; i < this.dureeContratMonths-recurrence; i=i+recurrence) {listDateEcheance.add(dateDebut.addMonths(recurrence));}

My problem is that the recurrence doesn't work for the "paiement en 2 fois en 2 mois glissants" and so on ("paiement en 3 fois sur 3 mois glissants" & "paiement en 4 fois sur 4 mois glissants"). I need my dates of paiement to be consecutive for those ones.

Do you hav ean idea on how to do it?

Thanks a lot,