CommitInflightDebit commits a debit from the inflight balance and adds it to the debit balance. This is part of the finalization process for inflight transactions.
(transaction *Transaction)
| 182 | // CommitInflightDebit commits a debit from the inflight balance and adds it to the debit balance. |
| 183 | // This is part of the finalization process for inflight transactions. |
| 184 | func (balance *Balance) CommitInflightDebit(transaction *Transaction) { |
| 185 | balance.InitializeBalanceFields() |
| 186 | preciseAmount := ApplyPrecision(transaction) // Apply precision to the transaction amount. |
| 187 | transactionAmount := preciseAmount // Convert to *big.Int. |
| 188 | |
| 189 | if balance.InflightDebitBalance.Cmp(transactionAmount) >= 0 { |
| 190 | // Deduct from inflight and add to regular debit balance. |
| 191 | balance.InflightDebitBalance.Sub(balance.InflightDebitBalance, transactionAmount) |
| 192 | balance.DebitBalance.Add(balance.DebitBalance, transactionAmount) |
| 193 | balance.computeBalance(true) // Recompute inflight balance. |
| 194 | balance.computeBalance(false) // Recompute regular balance. |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | // CommitInflightCredit commits a credit from the inflight balance and adds it to the credit balance. |
| 199 | func (balance *Balance) CommitInflightCredit(transaction *Transaction) { |