Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 740068a

Browse files
authored
Merge pull request #2013 from OpenBazaar/brian.fix-dbstrings
Values from DB that get reflected into scientific notation are kept as strings
2 parents 35d2694 + dc8e250 commit 740068a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

repo/db/sales.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8+
"strings"
9+
"math/big"
810
"sync"
911
"time"
1012

@@ -198,6 +200,16 @@ func (s *SalesDB) GetAll(stateFilter []pb.OrderState, searchTerm string, sortByA
198200
coinType = ""
199201
}
200202

203+
if strings.Contains(totalStr, "e") {
204+
flt, _, err := big.ParseFloat(totalStr, 10, 0, big.ToNearestEven)
205+
if err != nil {
206+
return nil, 0, err
207+
}
208+
var i = new(big.Int)
209+
i, _ = flt.Int(i)
210+
totalStr = i.String()
211+
}
212+
201213
cv, err := repo.NewCurrencyValueWithLookup(totalStr, paymentCoin)
202214
if err != nil {
203215
return nil, 0, err

0 commit comments

Comments
 (0)