Rational
It is a common practice to request customer to put a specific communication/reference/remittance information on their payment.
These references are used to link to the invoice or the party.
There are some standard format (with check digits) for such reference like Creditor Reference - Wikipedia, Febelfin - AOS-OGMVCS etc.
Proposal
On the customer invoice a Function field is added to compute the payment reference for the customer using the invoice number. As some format can only use digits, a digits version of the invoice number is also stored on the invoice. The format used is computed by a property (which allow to implement custom rules). The payment reference is added to the invoice report.
On the supplier invoice fields are added to store the supplier payment reference and its type (for formatting and validation).
On the party a Function field is added to compute a reference based on the party code (like for the customer invoice).
The account configuration is updated to define which payment reference is used for customer invoice (the invoice number or the party code).
The payment modules are updated to use the payment reference instead of the invoice record name when it is filled.
The statement rule module is updated to use the payment reference to find invoice and party (depending on the account configuration).
For that a new keyword payment_reference is added. Each format is tested on this value and when it is valid, the proper “number” is extracted to be searched for as invoice or party.