handleSmallAmount assigns entire amount to first distribution for very small amounts
(totalAmountDec decimal.Decimal, totalPreciseAmount *big.Int, distributions []Distribution)
| 392 | |
| 393 | // handleSmallAmount assigns entire amount to first distribution for very small amounts |
| 394 | func handleSmallAmount(totalAmountDec decimal.Decimal, totalPreciseAmount *big.Int, distributions []Distribution) map[string]*big.Int { |
| 395 | minAmountDec := decimal.NewFromInt(1) |
| 396 | if totalAmountDec.Cmp(minAmountDec) > 0 || totalAmountDec.Sign() <= 0 || len(distributions) == 0 { |
| 397 | return nil |
| 398 | } |
| 399 | |
| 400 | result := make(map[string]*big.Int) |
| 401 | result[distributions[0].Identifier] = totalPreciseAmount |
| 402 | for i := 1; i < len(distributions); i++ { |
| 403 | result[distributions[i].Identifier] = big.NewInt(0) |
| 404 | } |
| 405 | return result |
| 406 | } |
| 407 | |
| 408 | // Function to integrate the new CalculateDistributionsPrecise into SplitTransaction |
| 409 | func (transaction *Transaction) SplitTransactionPrecise(ctx context.Context) ([]*Transaction, error) { |
no outgoing calls
no test coverage detected