You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is fairly niche and I have work arounds, but I figured I'd bring this up just in case there is an easy fix
Assuming the following models:
Class Product < ApplicationRecord
# has attribute currency
has_many :variants
end
Class Variant < ApplicationRecord
belongs_to :product
monetize :price_cents, with_currency: ->(variant) { variant.product.currency }
end
then when creating a variant through the relationship like this assuming a product with currency = "KRW" (South Korean Won - a currency without subunits):
@product.variants.new(price: 20)
I get back a variant with price_cents set to 2000 when it should only be 20 since KRW units and subunits should be equal.
Seems like :price_cents is being converted from :price with the default system currency when the currency through the relationship to product should be used
The text was updated successfully, but these errors were encountered:
This is fairly niche and I have work arounds, but I figured I'd bring this up just in case there is an easy fix
Assuming the following models:
then when creating a variant through the relationship like this assuming a product with currency = "KRW" (South Korean Won - a currency without subunits):
@product.variants.new(price: 20)
I get back a variant with price_cents set to 2000 when it should only be 20 since KRW units and subunits should be equal.
Seems like :price_cents is being converted from :price with the default system currency when the currency through the relationship to product should be used
The text was updated successfully, but these errors were encountered: