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
|
||||||
|
|
||||||
|
- Fixed calculation of order total to ensure 8 decimal places
|
||||||
- Fixed test for looking for an order with incorrect ID
|
- Fixed test for looking for an order with incorrect ID
|
||||||
- Fixed payment scan to focus only on new transactions
|
- Fixed payment scan to focus only on new transactions
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ updateOrderTotals o =
|
||||||
(qprice o)
|
(qprice o)
|
||||||
(newTotal o)
|
(newTotal o)
|
||||||
(if qprice o /= 0
|
(if qprice o /= 0
|
||||||
then newTotal o / qprice o
|
then roundZec (newTotal o / qprice o)
|
||||||
else 0)
|
else 0)
|
||||||
(qlines o)
|
(qlines o)
|
||||||
(qpaid o)
|
(qpaid o)
|
||||||
|
@ -215,3 +215,7 @@ markOrderPaid i =
|
||||||
modify
|
modify
|
||||||
(select ["_id" =: (read i :: B.ObjectId)] "orders")
|
(select ["_id" =: (read i :: B.ObjectId)] "orders")
|
||||||
["$set" =: ["paid" =: True]]
|
["$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.Text -> String
|
||||||
encodeHexText t = T.unpack . toText . fromBytes $ E.encodeUtf8 t
|
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
|
-- Types for the ZGo database documents
|
||||||
-- | Type to model a country for the database's country list
|
-- | Type to model a country for the database's country list
|
||||||
data Country =
|
data Country =
|
||||||
|
@ -788,8 +792,7 @@ scanPayments config pipe = do
|
||||||
getOrderId re t = do
|
getOrderId re t = do
|
||||||
let reg = matchAllText re (T.unpack $ zmemo t)
|
let reg = matchAllText re (T.unpack $ zmemo t)
|
||||||
if not (null reg)
|
if not (null reg)
|
||||||
then do
|
then fst $ head reg ! 1
|
||||||
fst $ head reg ! 1
|
|
||||||
else ""
|
else ""
|
||||||
|
|
||||||
-- | RPC methods
|
-- | RPC methods
|
||||||
|
|
Loading…
Reference in a new issue