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

Method CommitInflightDebit

model/model.go:184–196  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
184func (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.
199func (balance *Balance) CommitInflightCredit(transaction *Transaction) {

Callers 2

Calls 3

computeBalanceMethod · 0.95
ApplyPrecisionFunction · 0.85

Tested by 1