Update tariff.go

This commit is contained in:
Mikhail 2023-09-19 21:43:08 +00:00
parent 5b7b2405aa
commit d9761c57b1

@ -7,19 +7,22 @@ import (
)
func TariffsToProductInformations(tarrifs []models.Tariff) []*discount.ProductInformation {
productInformations := make([]*discount.ProductInformation, len(tarrifs))
productInformations := []*discount.ProductInformation{}
for index, tariff := range tarrifs {
productInformations[index] = TariffToProductInformation(tariff)
for _, tariff := range tarrifs {
for _, privilege := range tariff.Privileges {
productInformations = append(productInformations, PrivilegeToProductInformation(tariff))
}
}
return productInformations
}
func TariffToProductInformation(tarrif models.Tariff) *discount.ProductInformation {
func PrivilegeToProductInformation(privilege models.Privilege) *discount.ProductInformation {
return &discount.ProductInformation{
ID: tarrif.ID,
Price: tarrif.Price,
ID: privilege.ID,
Price: privilege.Price,
Group: privilege.ServiceKey,
}
}