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

Commit fa1114a

Browse files
authored
Merge pull request #2029 from OpenBazaar/brian.fix-scientificnotation-purchases
Fix scientific notation coming out of database for purchases
2 parents 728b107 + f0eb5c3 commit fa1114a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

repo/db/purchases.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"database/sql"
55
"encoding/json"
66
"fmt"
7+
"math/big"
8+
"strings"
79
"sync"
810
"time"
911

@@ -197,6 +199,16 @@ func (p *PurchasesDB) GetAll(stateFilter []pb.OrderState, searchTerm string, sor
197199
coinType = ""
198200
}
199201

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

0 commit comments

Comments
 (0)