updateTransactionDetails updates the details of a transaction, including source and destination balances and status. It starts a tracing span, creates a new transaction object with updated details, and records relevant events. Parameters: - ctx context.Context: The context for the operation. - tran
(ctx context.Context, transaction *model.Transaction, sourceBalance, destinationBalance *model.Balance)
| 296 | // Returns: |
| 297 | // - *model.Transaction: A pointer to the new transaction object with updated details. |
| 298 | func (l *LedgerForge) updateTransactionDetails(ctx context.Context, transaction *model.Transaction, sourceBalance, destinationBalance *model.Balance) *model.Transaction { |
| 299 | _, span := tracer.Start(ctx, "Updating Transaction Details") |
| 300 | defer span.End() |
| 301 | |
| 302 | // Create a new transaction object with updated details (immutable pattern) |
| 303 | newTransaction := *transaction // Copy the original transaction |
| 304 | newTransaction.Source = sourceBalance.BalanceID |
| 305 | newTransaction.Destination = destinationBalance.BalanceID |
| 306 | |
| 307 | // Update the status based on the current status and inflight flag |
| 308 | applicableStatus := map[string]string{ |
| 309 | StatusQueued: StatusApplied, |
| 310 | StatusApplied: StatusApplied, |
| 311 | StatusScheduled: StatusApplied, |
| 312 | StatusCommit: StatusApplied, |
| 313 | StatusVoid: StatusVoid, |
| 314 | } |
| 315 | newTransaction.Status = applicableStatus[transaction.Status] |
| 316 | if transaction.Inflight { |
| 317 | newTransaction.Status = StatusInflight |
| 318 | } |
| 319 | |
| 320 | span.AddEvent("Transaction details updated") |
| 321 | return &newTransaction |
| 322 | } |
| 323 | |
| 324 | // postTransactionActions performs post-processing actions for a transaction. |
| 325 | // It starts a tracing span, queues the transaction and balance data for indexing in dependency order, |
no test coverage detected