parseFixedAmount parses a fixed amount from a distribution
(dist Distribution, precisionDec decimal.Decimal)
| 172 | |
| 173 | // parseFixedAmount parses a fixed amount from a distribution |
| 174 | func parseFixedAmount(dist Distribution, precisionDec decimal.Decimal) (decimal.Decimal, error) { |
| 175 | if dist.PreciseDistribution != "" { |
| 176 | preciseAmount, err := strconv.ParseInt(dist.PreciseDistribution, 10, 64) |
| 177 | if err != nil { |
| 178 | return decimal.Zero, errors.New("invalid precise_distribution format: must be an integer value in minor units") |
| 179 | } |
| 180 | return decimal.NewFromInt(preciseAmount), nil |
| 181 | } |
| 182 | |
| 183 | if dist.Distribution != "" { |
| 184 | fixedAmount, err := strconv.ParseFloat(dist.Distribution, 64) |
| 185 | if err != nil { |
| 186 | return decimal.Zero, errors.New("invalid fixed amount format") |
| 187 | } |
| 188 | return decimal.NewFromFloat(fixedAmount).Mul(precisionDec), nil |
| 189 | } |
| 190 | |
| 191 | return decimal.Zero, nil |
| 192 | } |
| 193 | |
| 194 | // processPercentageDistributions handles the second pass: percentage distributions |
| 195 | func processPercentageDistributions(distributions []Distribution, state *distributionState) error { |
no outgoing calls
no test coverage detected