dividends_estimate.go 2.2 KB
package transform

import (
	"github.com/shopspring/decimal"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
)

func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel *models.DividendsEstimate) (*domain.DividendsEstimate, error) {
	dividendsAmount, _ := decimal.NewFromFloatWithExponent(dividendsEstimateModel.DividendsAmount, -2).Float64()
	return &domain.DividendsEstimate{
		DividendsEstimateId:             dividendsEstimateModel.DividendsEstimateId,
		DividendsAccountStatus:          dividendsEstimateModel.DividendsAccountStatus,
		PaymentStatus:                   dividendsEstimateModel.PaymentStatus,
		DividendsAmount:                 dividendsAmount,
		DividendsEstimateOrderNumber:    dividendsEstimateModel.DividendsEstimateOrderNumber,
		DividendsEstimateTime:           dividendsEstimateModel.DividendsEstimateTime,
		DividendsParticipateType:        dividendsEstimateModel.DividendsParticipateType,
		DividendsType:                   dividendsEstimateModel.DividendsType,
		DividendsTypeName:               dividendsEstimateModel.DividendsTypeName,
		OrderOrReturnedOrderNum:         dividendsEstimateModel.OrderOrReturnedOrderNum,
		CooperationContractNumber:       dividendsEstimateModel.CooperationContractNumber,
		CooperationContractUndertakerId: dividendsEstimateModel.CooperationContractUndertakerId,
		DividendsUser:                   dividendsEstimateModel.DividendsUser,
		DividendsStage:                  dividendsEstimateModel.DividendsStage,
		Org:                             dividendsEstimateModel.Org,
		Company:                         dividendsEstimateModel.Company,
		Operator:                        dividendsEstimateModel.Operator,
		OperateTime:                     dividendsEstimateModel.OperateTime,
		IsCanceled:                      dividendsEstimateModel.IsCanceled,
		OrderGoodId:                     dividendsEstimateModel.OrderGoodId,
		CreatedAt:                       dividendsEstimateModel.CreatedAt,
		DeletedAt:                       dividendsEstimateModel.DeletedAt,
		UpdatedAt:                       dividendsEstimateModel.UpdatedAt,
	}, nil
}