Following class is responsible for generating increment_id
Magento/SalesSequence/Model/Sequence.php
/**
* Retrieve next value
*
* @return string
*/
public function getNextValue()
{
$this->connection->insert($this->meta->getSequenceTable(), []);
$this->lastIncrementId = $this->connection->lastInsertId($this->meta->getSequenceTable());
return $this->getCurrentValue();
}
So you can use plugin for any modification. Its global function for order, invoice, shipment, creditmemo.
You can pass registry param from
\Magento\SalesSequence\Model\Manager
As an example:
/**
* Returns sequence for given entityType and store
*
* @param string $entityType
* @param int $storeId
* @return \Magento\Framework\DB\Sequence\SequenceInterface
*/
public function aroundGetSequence(
\Magento\SalesSequence\Model\Manager $subject,
\Closure $proceed,
$entityType,
$storeId
)
{
// $entityType is 'order' or 'shipment' or 'invoice' or 'creditmemo'
$this->_objectManager->get('Magento\Framework\Registry')->register('sr_entityType', $entityType);
return $proceed($entityType, $storeId);
}
Now you get this registry param from getNextValue and modify your own way.