Logo

How can we help you?

Search our knowledge base to get answers to your questions, access video training & more!

Developer

Calling global method from InvoiceLinePayment class to add Invoice Line Payments to existing records

Updated 2 days ago

Enabling Line Payment Reporting can be used to create reports of payments per purchased items. Enabling the setting creates Invoice Line Payments for new payments.

If you just enabled Invoice Line Payment Reporting and you wish to create a report that includes existing Payment records that were created before the setting was enabled, you can call a global method from the InvoiceLinePayment class to add Invoice Line Payments to existing records.

global void distributePaidAmount(List<fw1__Payment__c> payments){
distributeTotalPaidAmount(payments);
}

Example:

List<fw1__Payment__c> payments = [
    SELECT Id, fw1__Invoice__c,fw1__Payment_Method__c,fw1__Status__c,
fw1__Credit_Card_Surcharge_Amount__c,fw1__Amount__c,fw1__Total_Paid_Amount__c
    FROM fw1__Payment__c
    WHERE CreatedDate = THIS_MONTH
    LIMIT 10];
fw1.InvoiceLinePayment.distributeTotalPaidAmount(payments);

Note: This is not a batch process and you may have to limit the number of payments to process otherwise you'll get a CPU time limit error

Previous

Outstanding Invoice Component

Next