Orchestrator refactoring + planned amounts
This commit is contained in:
24
api/payments/orchestrator/internal/service/shared/money.go
Normal file
24
api/payments/orchestrator/internal/service/shared/money.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package shared
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
paymenttypes "github.com/tech/sendico/pkg/payments/types"
|
||||
)
|
||||
|
||||
// CloneMoneyTrimNonEmpty clones a money value after trimming fields.
|
||||
// It returns nil when amount or currency is missing.
|
||||
func CloneMoneyTrimNonEmpty(src *paymenttypes.Money) *paymenttypes.Money {
|
||||
if src == nil {
|
||||
return nil
|
||||
}
|
||||
amount := strings.TrimSpace(src.GetAmount())
|
||||
currency := strings.TrimSpace(src.GetCurrency())
|
||||
if amount == "" || currency == "" {
|
||||
return nil
|
||||
}
|
||||
return &paymenttypes.Money{
|
||||
Amount: amount,
|
||||
Currency: currency,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user