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

Method computeBalance

model/model.go:119–126  ·  view source on GitHub ↗

computeBalance computes the overall balance for inflight and normal balances. inflight indicates whether the inflight balance or regular balance should be computed.

(inflight bool)

Source from the content-addressed store, hash-verified

117// computeBalance computes the overall balance for inflight and normal balances.
118// inflight indicates whether the inflight balance or regular balance should be computed.
119func (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.

Callers 6

CommitInflightDebitMethod · 0.95
CommitInflightCreditMethod · 0.95
RollbackInflightDebitMethod · 0.95
UpdateBalancesFunction · 0.80

Calls 1

Tested by 1