InitializeBalanceFields initializes all the fields of the Balance struct that might be nil. This ensures that all balance-related fields have valid *big.Int values for further operations.
()
| 71 | // InitializeBalanceFields initializes all the fields of the Balance struct that might be nil. |
| 72 | // This ensures that all balance-related fields have valid *big.Int values for further operations. |
| 73 | func (balance *Balance) InitializeBalanceFields() { |
| 74 | if balance.InflightDebitBalance == nil { |
| 75 | balance.InflightDebitBalance = big.NewInt(0) |
| 76 | } |
| 77 | if balance.InflightCreditBalance == nil { |
| 78 | balance.InflightCreditBalance = big.NewInt(0) |
| 79 | } |
| 80 | if balance.InflightBalance == nil { |
| 81 | balance.InflightBalance = big.NewInt(0) |
| 82 | } |
| 83 | if balance.DebitBalance == nil { |
| 84 | balance.DebitBalance = big.NewInt(0) |
| 85 | } |
| 86 | if balance.CreditBalance == nil { |
| 87 | balance.CreditBalance = big.NewInt(0) |
| 88 | } |
| 89 | if balance.Balance == nil { |
| 90 | balance.Balance = big.NewInt(0) |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | // addCredit adds the specified amount to the credit balances (either inflight or regular). |
| 95 | // inflight indicates whether the credit is inflight or not. |
no outgoing calls
no test coverage detected