fix(transaction): #151 float error | -17.49 parsed as -17.48
This commit was merged in pull request #157.
This commit is contained in:
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"spend-sparrow/internal/db"
|
||||
"spend-sparrow/internal/log"
|
||||
"spend-sparrow/internal/types"
|
||||
@@ -465,7 +466,7 @@ func (s TransactionRecurringImpl) validateAndEnrichTransactionRecurring(
|
||||
log.L.Error("transactionRecurring validate", "err", err)
|
||||
return nil, fmt.Errorf("could not parse value: %w", ErrBadRequest)
|
||||
}
|
||||
valueInt := int64(valueFloat * DECIMALS_MULTIPLIER)
|
||||
value := int64(math.Round(valueFloat * DECIMALS_MULTIPLIER))
|
||||
|
||||
if input.Party != "" {
|
||||
err = validateString(input.Party, "party")
|
||||
@@ -512,7 +513,7 @@ func (s TransactionRecurringImpl) validateAndEnrichTransactionRecurring(
|
||||
|
||||
AccountId: accountUuid,
|
||||
TreasureChestId: treasureChestUuid,
|
||||
Value: valueInt,
|
||||
Value: value,
|
||||
|
||||
CreatedAt: createdAt,
|
||||
CreatedBy: createdBy,
|
||||
|
||||
Reference in New Issue
Block a user