| | |
| | | } |
| | | } |
| | | if len(slf.MoreUnitList) != 0 { |
| | | str, err := json.Marshal(slf.MoreUnitList) |
| | | items := make([]UnitItems, 0) |
| | | for k, item := range slf.MoreUnitList { |
| | | if item.Unit != "" && !item.Amount.IsZero() { |
| | | items = append(items, slf.MoreUnitList[k]) |
| | | } |
| | | } |
| | | |
| | | str, err := json.Marshal(items) |
| | | if err != nil { |
| | | return err |
| | | } |
| | |
| | | func CreateMoreUnit(amount decimal.Decimal, units []models.UnitItems) []models.UnitItems { |
| | | moreValueArr := make([]models.UnitItems, 0, len(units)) |
| | | for _, unitItem := range units { |
| | | if unitItem.Amount.IsZero() { |
| | | continue |
| | | } |
| | | moreValueArr = append(moreValueArr, models.UnitItems{ |
| | | Amount: amount.Div(unitItem.Amount), |
| | | Unit: unitItem.Unit, |