Incorrect Type of Transaction Error When Cancelling a Sales Invoice

While attempting to cancel a sales invoice in ERPNext, an error occurs, as shown in the attached screenshot. The error message states:

“The type of transaction of Serial and Batch Bundle <Batch ID> is Outward, but as per the Actual Qty 1.0 for the item <Item Code> in the Sales Invoice <Invoice ID> the type of transaction should be Inward.”

This prevents the cancellation of the sales invoice