package shared

import (
	"strings"

	paymenttypes "github.com/tech/sendico/pkg/payments/types"
	moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
)

func CloneProtoMoneyRaw(src *moneyv1.Money) *moneyv1.Money {
	if src == nil {
		return nil
	}
	return &moneyv1.Money{
		Amount:   src.GetAmount(),
		Currency: src.GetCurrency(),
	}
}

func CloneProtoMoneyTrim(src *moneyv1.Money) *moneyv1.Money {
	if src == nil {
		return nil
	}
	return &moneyv1.Money{
		Amount:   strings.TrimSpace(src.GetAmount()),
		Currency: strings.TrimSpace(src.GetCurrency()),
	}
}

func CloneProtoMoneyTrimUpperCurrency(src *moneyv1.Money) *moneyv1.Money {
	if src == nil {
		return nil
	}
	return &moneyv1.Money{
		Amount:   strings.TrimSpace(src.GetAmount()),
		Currency: strings.ToUpper(strings.TrimSpace(src.GetCurrency())),
	}
}

func CloneModelMoneyRaw(src *paymenttypes.Money) *paymenttypes.Money {
	if src == nil {
		return nil
	}
	return &paymenttypes.Money{
		Amount:   src.GetAmount(),
		Currency: src.GetCurrency(),
	}
}

func CloneModelMoneyTrimUpperCurrency(src *paymenttypes.Money) *paymenttypes.Money {
	if src == nil {
		return nil
	}
	return &paymenttypes.Money{
		Amount:   strings.TrimSpace(src.GetAmount()),
		Currency: strings.ToUpper(strings.TrimSpace(src.GetCurrency())),
	}
}
