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

Method InitializeBalanceFields

model/model.go:73–92  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

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.
73func (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.

Callers 9

addCreditMethod · 0.95
addDebitMethod · 0.95
computeBalanceMethod · 0.95
CommitInflightDebitMethod · 0.95
CommitInflightCreditMethod · 0.95
RollbackInflightDebitMethod · 0.95
canProcessTransactionFunction · 0.80
UpdateBalancesFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected