diff --git a/src/Services/InfoProviderSystem/Providers/MouserProvider.php b/src/Services/InfoProviderSystem/Providers/MouserProvider.php index a3c83b25..3171c994 100644 --- a/src/Services/InfoProviderSystem/Providers/MouserProvider.php +++ b/src/Services/InfoProviderSystem/Providers/MouserProvider.php @@ -305,6 +305,17 @@ class MouserProvider implements InfoProviderInterface return (float)$val; } + private function mapCurrencyCode(string $currency): string + { + //Mouser uses "RMB" for Chinese Yuan, but the correct ISO code is "CNY" + if ($currency === "RMB") { + return "CNY"; + } + + //For all other currencies, we assume that the ISO code is correct + return $currency; + } + /** * Converts the pricing (StandardPricing field) from the Mouser API to an array of PurchaseInfoDTOs * @param array $price_breaks @@ -321,7 +332,7 @@ class MouserProvider implements InfoProviderInterface $prices[] = new PriceDTO( minimum_discount_amount: $price_break['Quantity'], price: (string)$number, - currency_iso_code: $price_break['Currency'] + currency_iso_code: $this->mapCurrencyCode($price_break['Currency']) ); }