Increasing trades.price decimal scale (#89)

* Changing trades.price to have a larger scale - a scale of 4 causes destructive rounding when calculating transaction cost; changes to the UI to allow for inputting and showing increased scale trade prices; test case
This commit is contained in:
Michael Studman
2025-10-22 03:22:24 +11:00
committed by GitHub
parent 3aea1513d1
commit ea7ce13a7d
6 changed files with 50 additions and 5 deletions

View File

@@ -48,14 +48,14 @@
inline: true,
placeholder: "100",
value: if options[:value]
sprintf("%.#{currency.default_precision}f", options[:value])
sprintf("%.#{options[:precision].presence || currency.default_precision}f", options[:value])
elsif form.object && form.object.respond_to?(amount_method)
val = form.object.public_send(amount_method)
sprintf("%.#{currency.default_precision}f", val) if val.present?
sprintf("%.#{options[:precision].presence || currency.default_precision}f", val) if val.present?
end,
min: options[:min] || -99999999999999,
max: options[:max] || 99999999999999,
step: currency.step,
step: options[:step] || currency.step,
disabled: options[:disabled],
data: {
"money-field-target": "amount",