25 lines
556 B
Go
25 lines
556 B
Go
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,
|
|
}
|
|
}
|