private function createNewCurrency(string
$currencyCode): string
{ $id = Uuid::
randomBytes();
$currencyCode = \
mb_strtoupper($currencyCode);
if (!Currencies::
exists($currencyCode)) { throw new ShopConfigurationException(sprintf('Currency with iso code "%s" not found',
$currencyCode));
} $fractionDigits = Currencies::
getFractionDigits($currencyCode);
$roundingIncrement = Currencies::
getRoundingIncrement($currencyCode) === 0 ? 1 : Currencies::
getRoundingIncrement($currencyCode);
$rounding =
[ 'decimals' =>
$fractionDigits,
'interval' =>
$roundingIncrement *
(10
** ($fractionDigits * -1
)),
'roundForNet' => true,
];
$this->connection->
executeStatement('
INSERT INTO `currency` (`id`, `iso_code`, `factor`, `symbol`, `position`, `item_rounding`, `total_rounding`, `created_at`)
VALUES (:id, :currency, 1, :symbol, 1, :rounding, :rounding, NOW())
',
['id' =>
$id, 'currency' =>
$currencyCode, 'symbol' => Currencies::
getSymbol($currencyCode), 'rounding' =>
json_encode($rounding, \JSON_THROW_ON_ERROR
)]);