Cascade Updating Linked tables from a Valid Sales Invoice

We have created a custom regionalized application to generate electronic invoices here in Guatemala.

So far, the application is working robustly, and it’s method of operation is as follows:

  1. User validates an invoice in ERPNext
  2. A custom button appears where user can “generate electronic invoice”
  3. When custom button is pressed, the callback runs a python script that:
    3.1 Packs data into SOAP request
    3.2 Sends SOAP request to third-party listener
    3.3 Waits for response from remote server.
    3.4 Receives response from remote server, unpacks it and assigns variables
    3.5 Variables are then stored in a custom table
  4. One variable is stored in sales invoice.
  5. The javascript then refreshes and upon finding existence of a successful invoice generation record in custom table using variable stored in sales invoice, creates a link to the third-party website which displays the “electronic invoice”.

So far, so good.

Our problem lies in the fact that the serial number generated by the third party can fall behind the numbers in the ERPNext series. And the third party generator has a strict policy of them setting the primary key which is the “DTE number”, the reason being that it is the legally accepted document number, along with the signature key. For the invoice to be legally and fiscally valid, it must include both the DTE number and the key. We have no problem with the digital key, as this is simply being put in an extra field.

Our goal in the subsequent version is then to “update” the Sales Invoice name to reflect the DTE number obtained. To achieve this end, we would set a different Naming series for these electronic invoices (our software allows user to choose which series goes with which third party doctype), but the script would have to update the sales invoice name, which is the primary key.

My question, is this:
What would be a complete list of tables you suggest checking for the original voucher or sales invoice number, so the fields can be updated so the link is not lost when renaming the sales invoice?

I have the following, but input on which tables are missing is appreciated:

  • Sales Invoice Item is one
  • General Ledger is another
  • Stock Ledger Entry is another
  • Taxes and Charges
  • Return or Credit Note
  • Subscription table
  • Sales Order
  • Delivery Note
  • Timesheet
  • Payment Request
  • Payment

What else am I missing?