Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Use BigDecimal with precision to qvoid Ruby 3.0 comparision issues

Damian Legawiecec541f95d525
diff --git a/core/app/models/spree/store_credit.rb b/core/app/models/spree/store_credit.rb
index e032f1c714..2009380d9d 100644
--- a/core/app/models/spree/store_credit.rb
+++ b/core/app/models/spree/store_credit.rb
@@ -68,7 +68,7 @@ module Spree
end
def validate_authorization(amount, order_currency)
- if amount_remaining.to_d < amount.to_d
+ if BigDecimal(amount_remaining, 3) < BigDecimal(amount, 3)
errors.add(:base, Spree.t('store_credit_payment_method.insufficient_funds'))
elsif currency != order_currency
errors.add(:base, Spree.t('store_credit_payment_method.currency_mismatch'))