medusa: Adding a custom currency makes the backend fail

Bug report

Describe the bug

We are using medusa for an internal company store, where users are assigned points to shop for, rather than using real money. Instead of using one of the built in currencies, we wanted to create a “points” currency, as described in this article: https://docs.medusajs.com/modules/regions-and-currencies/currencies

After adding a new currency in the database, we can easily add it to a region, but after adding it to the region and trying to set a price on a product, we get the following error: Unexpected Application Error! Cannot read properties of undefined (reading 'name') TypeError: Cannot read properties of undefined (reading 'name') at wg (https://nordicsemi-medusa-admin.azurewebsites.net/app/251.d7cdb615.chunk.js:1:1246731) at aS (https://nordicsemi-medusa-admin.azurewebsites.net/app/main.f7477009.js:18:60913) at l (https://nordicsemi-medusa-admin.azurewebsites.net/app/main.f7477009.js:18:119434) at sq (https://nordicsemi-medusa-admin.azurewebsites.net/app/main.f7477009.js:18:99087) at https://nordicsemi-medusa-admin.azurewebsites.net/app/main.f7477009.js:18:98954 at sN (https://nordicsemi-medusa-admin.azurewebsites.net/app/main.f7477009.js:18:98961) at sO (https://nordicsemi-medusa-admin.azurewebsites.net/app/main.f7477009.js:18:95713) at sC (https://nordicsemi-medusa-admin.azurewebsites.net/app/main.f7477009.js:18:94268) at P (https://nordicsemi-medusa-admin.azurewebsites.net/app/main.f7477009.js:51:1364) at MessagePort.R (https://nordicsemi-medusa-admin.azurewebsites.net/app/main.f7477009.js:51:1894)

Looking into the code, I can see that both backend-admin and api (which in turn means frontend) uses the values directly from the currency.ts rather than taking it from the database. In addition to this, currency.ts holds more properties than can be added to the database.

I tried just changing the name and symbols of an already created currency in the database, to see if I would be able to use it this way - but the symbols are still grabbed from the file rather than the database.

It looks to me like it would not be possible for us to use points, without having them added to the currencies.ts file

I am guessing, a non-valid currency (points) is unwelcome as a pull request? Do you see any way for us to have this working properly, other than hardcoding everything in our storefront and ignoring the currency backend?

System information

Medusa version (including plugins): 1.14 Node.js version: 18.16 Database: postgres Operating system: linux on prod, windows development Browser (if relevant):

Steps to reproduce the behavior

  1. Create a migration for a new currency
  2. Enable the currency in the market
  3. Try to add a price in this currency

Expected behavior

Being able to add and utilize currencies like documentation states

Screenshots

admin error: image

doc: image

About this issue

  • Original URL
  • State: open
  • Created 10 months ago
  • Reactions: 1
  • Comments: 17 (7 by maintainers)

Most upvoted comments

+1 support in Admin UI for all currencies in the db will be a great addition.