💄 Round transaction amount to keep 2 decimal places only
This commit is contained in:
parent
9b5f67e677
commit
712ed6c2ae
@ -2,6 +2,7 @@ package services
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
|
|
||||||
"git.solsynth.dev/hypernet/passport/pkg/authkit"
|
"git.solsynth.dev/hypernet/passport/pkg/authkit"
|
||||||
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
|
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
|
||||||
@ -12,6 +13,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func MakeTransaction(amount float64, remark string, payer, payee *models.Wallet) (models.Transaction, error) {
|
func MakeTransaction(amount float64, remark string, payer, payee *models.Wallet) (models.Transaction, error) {
|
||||||
|
// Round amount to keep 2 decimal places
|
||||||
|
amount = math.Round(amount*100) / 100
|
||||||
|
|
||||||
transaction := models.Transaction{
|
transaction := models.Transaction{
|
||||||
Amount: decimal.NewFromFloat(amount),
|
Amount: decimal.NewFromFloat(amount),
|
||||||
Remark: remark,
|
Remark: remark,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user