Yes, this is the part of code that I checked, but couldn’t find the reason why my system doesn’t cancel the invoice and the Adjusting Journal entry as explained in my previous comment here
I guess it is a bug in the code.
Or do I miss something in the installation? Or there must be some other modifications in the ERPNext and Frappe Apps?