Loading

Troubleshoot Cancel and Rebill Issues in Salesforce Billing

Дата публикации: Mar 14, 2025
Описание
Cancel and Rebill can fail due to a number of issues. The following explain the various error messages and how to resolve them.
Решение

Apex CPU time limit exceeded issues
Salesforce Billing is a managed package and is subject to Salesforce Execution Governors and Limits. To Cancel and Rebill a posted invoice, Invoice and Invoice Lines and the related Order and Order Products are modified, a credit note is created and a credit note line and credit note allocation are created for each invoice line. This can trigger custom automation on these objects. In addition, a roll-up summary field from Credit Note or Invoice to Account can also trigger automation on the Account object. Using an external tax integration also adds to the load. Prevention is the best approach. If this happens in production, one approach is to make the corrections with a credit note or debit note. If that is not possible, then disabling some or all of the custom automation (flows, triggers) might allow cancel and rebill. Do not disable CPQ or Billing triggers as these are needed for cancel and rebill. 

Error Message: 'We can't cancel this invoice because its order or account has other invoices with later invoice dates. Cancel the later ones and try again.'
Cause: One or more of the Order Products has an invoice line from a later invoice that is in Draft or Posted Status. 

Solution: Later invoices must be canceled and rebilled before an earlier invoice can be. This is by design since billing for subscriptions is done sequentially and changing an earlier invoice can have effects on later invoices. 

If the later invoice lines in draft status are on a canceled invoice, this was due to a feature gap that was fixed in the Summer '23 release. Invoice Lines in this situation can be safely updated to Canceled using the trigger disable method as outlined in this knowledge article.

'Failure - Cannot cancel this invoice because it's already active' error message
Cancel and Rebill or Credit cannot be used on an Invoice when there are Payments, Credit Notes or Debit Notes allocated to that invoice or any lines on that invoice.
Solution: Please refer to this Knowledge Article.

Tax Errors
These errors are only seen when using an external tax integration. The errors come from the tax integration. 

Error Message: 'Document not found.'
This error is thrown when the invoice was deleted, or it never existed in the tax portal. One way to fix this is to set the Tax Status on all the invoice lines to 'Queued' to force a tax callout to create the record. If this is successful, then cancel and rebill will work. Another way is to change the Tax Rule field Taxable (Yes/No) to 'No' and then do a cancel and rebill. Don't forget to reset this field. Also, make sure to do this when no one else is using the Billing Package and no invoice runs are active or the invoices created will not calculate tax. 

Error Message: The document is locked and cannot be modified.
This happens because cancel and rebill of a posted invoice does not create a credit note in the tax portal. Rather, it attempts to void the original invoice and copy the tax to a credit note in Salesforce. Tax providers will file tax records periodically and, after the filing date, will not allow the status of the invoice to be changed. Check with your provider for details to see how to unlock an invoice in the event this is needed. Rather than cancel and rebill, consider trying to make the corrections using a credit note or debit note.  

Error Message: The transaction has already been canceled
Check the tax portal to see if the invoice is showing a status of Void. If it is, you can change it to match the invoice status as follows: For draft invoices, set the status to uncommitted. For posted invoices, set it to committed. Then you should be able to successfully use cancel and rebill. 

Error Message: End Date cannot be less than Start Date.

Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, End Date cannot be less than Start Date

Cause: One or more of the Invoice Lines has an End Date that is before the Start Date.
Solution: Update the affected invoice lines by setting the end date equal to the start date. This has to done with the Billing triggers disabled. The best way to do this is using anonymous apex using the global Apex API TriggerControl to manually disable CPQ and Billing triggers. There is sample code for how to do this for Invoice in this article.

Дополнительные ресурсы
SEE ALSO
Номер статьи базы знаний

000395735

 
Загрузка
Salesforce Help | Article