Generate a payment schedule

Prev Next

There are two ways to use the schedule template for payment schedules:

  • Or you go through the milestones, as for the billing schedule, which allows a more finely tuned management to your customer's needs,

  • or you use the start and end dates on the invoice and then the frequency field in the schedule template.

In order to generate payment schedules, one or more schedule templates must first be set up, as described in this article:

Use cases & set up of schedule template.

If you want to use milestones, please follow this procedure to set them up first: Set up of milestones.

Please note: if you create a payment schedule when one or more payments exist and are pending, these payments will be deleted in favor of the new ones created via the schedule. For existing payments that are no longer pending (they have been paid), their amount is locked, they won't be deleted. The amount of the pending payments will be adjusted to the outstanding balance.


Steps

1. Go to the Invoice tab.
2. Open the relevant invoice.
3. Go to the Payments related list and click on Generate payment schedule.

4. Choose a schedule template.
5. Payments are created. The date of the first payment is the due date of the invoice. The payment method is also taken from the invoice, and the periods between payments and the distribution of their amounts are calculated according to the selected payment schedule.
6. Modify - if necessary - the dates, the payment methods, add comments. You can also uncheck whether the payment should be considered Pending or Not.
7. Then click on Validate.



8. You see your payments in the Payments related list.


Please note: If they do not appear immediately, it is probably a caching problem. Please click on View all in the Payments related list to ensure that the payments are created.

Schedule without milestones

If you decide not to use milestones, the frequency chosen on the schedule in question is applied to the dates indicated on the invoice:



The payments generated are distributed equally.

For example:

Type

Payment

Total amount including VAT

1200,00€

Start date

01/01/2020

End date

31/03/2020

Frequency

Monthly

Result

3 pending payments

Amount including VAT per payment

400,00€


Please note:The frequency must be adapted to the billing period chosen in the quotation/invoice.
If you select an annual periodicity for an invoicing period of one month, the result will be just an invoice or a payment.

Steps

1. Go to the Corporate names tab and open the relevant one.
2. Check the Enable Automatic Payments box.

3. Then go to the Invoice tab and open the relevant invoice.
4. Search for your schedule template using the Payment Schedule search field.


5. Save.
6. Thanks to the automatic payment system, you will find your payments in the Payments related list .

Please note: If they do not appear immediately, it is probably a caching problem. Please click on View all in the Payments related list to ensure that the payments are created.

Through the Payment Schedule lookup field you can find the invoices attached to the schedule templates:

Now that we have generated our payment schedule, let's see how to display it on the invoice PDF.

Adding the payment schedule in the PDF template

In order to add the payment list to the invoice PDF, you can add the following code snippet to your Visualforce page. Please contact your Salesforce administrator to make these changes.

To save the Visualforce page, you must first create these two fields in the payment object:

Field labelAPI nameType of dataFormula
VAT amountMontant_TVAFormula(Currency, 2 decimal places)sofactoapp__Facture__r.sofactoapp__TVA_pc__c
Amount excl. VATMontant_HTFormula(Currency, 2 decimal places)sofactoapp__Montant__c /( 1+ Montant_TVA__c)

Note:

(1) The following code does not handle the page break. The possible break of the table will be done without the table header or the invoice header being replicated on the second page.

(2) If you have set a condition on the page break, the table will not be cut correctly. Either the table is cut, but the continuation will not be carried over to the second page, or a blank page will be inserted. In this case, you can integrate it directly on your second page.


Please test this code in a sandbox first, to test the display in the different cases (many invoice lines / many payment schedule lines).

<!-- Echéancier -->

<table class="borderOn" style="padding:0;margin:0;page-break-before:auto;page-break-inside:auto;">
                <tr style="page-break-inside:avoid;page-break-before:auto;font-size:10px;text-transform:uppercase">
                    <td width="10%" class="alignleft borderOn"
                        style="border-left:hidden;border-right:hidden;border-top:hidden;border-bottom:display;">
                        N°
                    </td>
                    <td width="18%" class="alignleft borderOn"
                        style="border-left:hidden;border-right:hidden;border-top:hidden;border-bottom:display;">
                        {!$ObjectType.sofactoapp__R_glement__c.Fields.sofactoapp__Date__c.Label}
                    </td>
                    <td width="18%" class="alignleft borderOn"
                        style="border-left:hidden;border-right:hidden;border-top:hidden;border-bottom:display;">
                        {!$ObjectType.sofactoapp__R_glement__c.Fields.Montant_HT__c.Label}
                    </td>
                    <td width="18%" class="alignleft borderOn"
                        style="border-left:hidden;border-right:hidden;border-top:hidden;border-bottom:display;">
                        {!$ObjectType.sofactoapp__R_glement__c.Fields.Montant_TVA__c.Label}
                    </td>
                    <td width="18%" class="alignleft borderOn"
                        style="border-left:hidden;border-right:hidden;border-top:hidden;border-bottom:display;">
                        {!$ObjectType.sofactoapp__R_glement__c.Fields.sofactoapp__Montant__c.Label}
                    </td>
                    
                </tr>
                ​
                <apex:variable var="counter" value="{!1}" />
                <apex:repeat value="{!orderedPayments}" var="orderedPaymentsLigne" id="orderedPaymentsLignes">
                    <apex:repeat value="{!sofactoapp__Factures_Client__c.sofactoapp__R_glements__r}" var="paymentLigne"
                        id="paymentLignes">
                        <apex:outputPanel layout="none" rendered="{!paymentLigne.Id == orderedPaymentsLigne}">
                            <apex:outputPanel layout="none">
                                    
                                <tr style="page-break-inside:avoid;page-break-before:auto">
                                    <td width="10%" style="text-align:center;">
                                        <apex:outputText value="{!counter}" />
                                        <apex:variable var="counter" value="{!counter+ 1}" />
                                    </td>
                                    <td width="18%" style="text-align:center;">
                                        <apex:outputField value="{!paymentLigne.sofactoapp__Date__c}" />
                                    </td>
                                    <td width="18%" style="text-align:center;">
                                        <apex:outputField value="{!paymentLigne.Montant_HT__c}" />
                                    </td>
                                    <td width="18%" style="text-align:center;">
                                        <apex:outputField value="{!paymentLigne.Montant_TVA__c}" />
                                    </td>
                                    <td width="18%" style="text-align:center;">
                                        <apex:outputField style="text-align:center;"
                                            value="{!paymentLigne.sofactoapp__Montant__c}" />
                                    </td>
                                </tr>
                             </apex:outputPanel>
                        </apex:outputPanel>

                    </apex:repeat>
                </apex:repeat>
            </table>


Here is the table integrated in the Cloud Kicks invoice:



For questions about setting up the Visualforce page, we advise you to read our PDF template module, starting here: How to customize your Visualforce template.