Mismatching $number parameter in mail template

Hello,
I have an issue in setting up mail template for payment confirmation

$number parameter in mail template for new invoice is OK

but for payment confirmation email $number parameter is injecting number of PAYMENT instead of INVOICE

What can I do to insert invoice number instead of payment number?

please help.

@ginare1431

The $number variable in the payments is the payment number, if you wish to show the invoice number in the payment you can use the variable $invoice