Refactor inefficient ID generation (creditnote_id)
In a discussion in the financial working group in the Barcelona 2019 sprint there was the idea to refactor the inefficient generation of the creditnote_id
(see links below).
The general idea is to create a new hook to enable generation of various identifiers, in this instance creditnote_id
and invoice_id
. In the future, potentially even more (e.g. contact_external_identifier
or campaign_external_identifier
)
I suggest the following signature for the new hook:
/**
* This hook allows custom implementation for the generation
* of various identifiers like the invoice_id or the
* creditnote_id
*
* @param string $identifier the identifier to be used, can be manipulated
* @param string $type currently one of 'invoice_id', 'creditnote_id'
* @param array $context list of key-indexed context data,
* @param bool $can_be_null true iff the resulting IDs may be NULL
* @return mixed
*/
public static function generateIdentifier(&$identifier, $type, $context, $can_be_null) {
return self::singleton()->invoke(['identifier', 'type', 'context', 'can_be_null'], $identifier, $type, $context, $can_be_null, self::$_nullObject, self::$_nullObject, 'civicrm_generateIdentifier');
}
Related PR's:
- https://github.com/civicrm/civicrm-core/pull/11110 - closed because it is stale
- https://github.com/civicrm/civicrm-core/pull/15232 - merged
- https://github.com/civicrm/civicrm-core/pull/15235
- https://github.com/civicrm/civicrm-core/pull/16462
Related issues: