Correct total calculator to use 8 decimals
This commit is contained in:
parent
20061285a2
commit
80c6fe6b71
3 changed files with 11 additions and 3 deletions
|
@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Fixed
|
||||
|
||||
- Fixed calculation of order total to ensure 8 decimal places
|
||||
- Fixed test for looking for an order with incorrect ID
|
||||
- Fixed payment scan to focus only on new transactions
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ updateOrderTotals o =
|
|||
(qprice o)
|
||||
(newTotal o)
|
||||
(if qprice o /= 0
|
||||
then newTotal o / qprice o
|
||||
then roundZec (newTotal o / qprice o)
|
||||
else 0)
|
||||
(qlines o)
|
||||
(qpaid o)
|
||||
|
@ -215,3 +215,7 @@ markOrderPaid i =
|
|||
modify
|
||||
(select ["_id" =: (read i :: B.ObjectId)] "orders")
|
||||
["$set" =: ["paid" =: True]]
|
||||
|
||||
-- | Helper function to round to 8 decimal places
|
||||
roundZec :: Double -> Double
|
||||
roundZec n = fromInteger (round $ n * (10 ^ 8)) / (10.0 ^^ 8)
|
||||
|
|
|
@ -294,6 +294,10 @@ decodeHexText h = E.decodeUtf8With lenientDecode $ BS.pack $ hexRead h
|
|||
encodeHexText :: T.Text -> String
|
||||
encodeHexText t = T.unpack . toText . fromBytes $ E.encodeUtf8 t
|
||||
|
||||
-- | Helper function to round to 8 decimal places
|
||||
roundZec :: Double -> Double
|
||||
roundZec n = fromInteger (round $ n * (10 ^ 8)) / (10.0 ^^ 8)
|
||||
|
||||
-- Types for the ZGo database documents
|
||||
-- | Type to model a country for the database's country list
|
||||
data Country =
|
||||
|
@ -788,8 +792,7 @@ scanPayments config pipe = do
|
|||
getOrderId re t = do
|
||||
let reg = matchAllText re (T.unpack $ zmemo t)
|
||||
if not (null reg)
|
||||
then do
|
||||
fst $ head reg ! 1
|
||||
then fst $ head reg ! 1
|
||||
else ""
|
||||
|
||||
-- | RPC methods
|
||||
|
|
Loading…
Reference in a new issue