Relationship scenario

Relationship scenario

Form LR is used to capture details from   the user.

Now we have to create an invoice for this LR so we created 2 forms: Invoice & Invoice LR. One invoice can have multiple LR associated with it. And while creating the Invoice we have to choose multiple existing LR that's why we created another form Invoice LR which has lookup field to LR. 
Check "Invoice Creation" file attached.
Now upon successful submission of Invoice, we are linking the selected LR and Invoice with deluge script (not found any configurational workflow action. If so please suggest.)

Till this we are good. Happy path. The issue what we are facing is this now:

If the user is editing Invoice and deleting the added Invoice LR records (which in turn hold selected LR) then Invoice LR and Invoice linking is removed automatically but linking between Invoice and LR which happened via deluge script is no getting delinked.

So request to provide detailed and useful suggestion about how we can handle this scenario and issue we are facing. Looking to have detailed explanation if possible.