computeBalance computes the overall balance for inflight and normal balances. inflight indicates whether the inflight balance or regular balance should be computed.
(inflight bool)
| 117 | // computeBalance computes the overall balance for inflight and normal balances. |
| 118 | // inflight indicates whether the inflight balance or regular balance should be computed. |
| 119 | func (balance *Balance) computeBalance(inflight bool) { |
| 120 | balance.InitializeBalanceFields() |
| 121 | if inflight { |
| 122 | balance.InflightBalance.Sub(balance.InflightCreditBalance, balance.InflightDebitBalance) |
| 123 | return |
| 124 | } |
| 125 | balance.Balance.Sub(balance.CreditBalance, balance.DebitBalance) |
| 126 | } |
| 127 | |
| 128 | // canProcessTransaction checks if a transaction can be processed given the source balance. |
| 129 | // It returns an error if the balance is insufficient and overdraft is not allowed. |