From 712ed6c2ae585f0c5e2fea58e145fcf7a1976c36 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 29 Jan 2025 20:18:29 +0800 Subject: [PATCH] :lipstick: Round transaction amount to keep 2 decimal places only --- pkg/internal/services/payment.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/internal/services/payment.go b/pkg/internal/services/payment.go index 58f9d72..c011f9d 100644 --- a/pkg/internal/services/payment.go +++ b/pkg/internal/services/payment.go @@ -2,6 +2,7 @@ package services import ( "fmt" + "math" "git.solsynth.dev/hypernet/passport/pkg/authkit" "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) { + // Round amount to keep 2 decimal places + amount = math.Round(amount*100) / 100 + transaction := models.Transaction{ Amount: decimal.NewFromFloat(amount), Remark: remark,