This looks like a bug to me.
When I am creating a new customer I can add something called “Customer number”. I would like to use it in an invoice template, however I cannot find it in the available template variables. customer_vat_number is there (in the docs on the page) but not customer_number.
Thanks for letting us know.
Just to confirm, are you referring to the “Company number” field?