MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / handleSmallAmount

Function handleSmallAmount

model/transaction.go:394–406  ·  view source on GitHub ↗

handleSmallAmount assigns entire amount to first distribution for very small amounts

(totalAmountDec decimal.Decimal, totalPreciseAmount *big.Int, distributions []Distribution)

Source from the content-addressed store, hash-verified

392
393// handleSmallAmount assigns entire amount to first distribution for very small amounts
394func 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
409func (transaction *Transaction) SplitTransactionPrecise(ctx context.Context) ([]*Transaction, error) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected