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

Function prepareRefundTransaction

transaction.go:2314–2335  ·  view source on GitHub ↗

prepareRefundTransaction creates and configures a new transaction object for the refund.

(originalTxn *model.Transaction, skipQueue bool)

Source from the content-addressed store, hash-verified

2312
2313// prepareRefundTransaction creates and configures a new transaction object for the refund.
2314func prepareRefundTransaction(originalTxn *model.Transaction, skipQueue bool) *model.Transaction {
2315 newTransaction := *originalTxn // Create a copy
2316 newTransaction.TransactionID = model.GenerateUUIDWithSuffix("txn")
2317 newTransaction.Reference = model.GenerateUUIDWithSuffix("ref")
2318 newTransaction.ParentTransaction = originalTxn.TransactionID
2319 newTransaction.Source = originalTxn.Destination // Swap source and destination
2320 newTransaction.Destination = originalTxn.Source
2321 newTransaction.AllowOverdraft = true
2322 newTransaction.SkipQueue = skipQueue
2323
2324 // Adjust status based on original status for proper processing
2325 if originalTxn.Status == StatusVoid {
2326 // If original was voided, the refund should process like an inflight reversal
2327 newTransaction.Inflight = true
2328 newTransaction.Status = "" // Reset status to let QueueTransaction handle it
2329 } else {
2330 newTransaction.Status = "" // Reset status for standard queuing
2331 newTransaction.Inflight = false
2332 }
2333
2334 return &newTransaction
2335}
2336
2337// RefundTransaction processes a refund for a given transaction by its ID.
2338// It starts a tracing span, retrieves the original transaction, validates its status, creates a new refund transaction, and queues it.

Callers 1

RefundTransactionMethod · 0.85

Calls 1

GenerateUUIDWithSuffixFunction · 0.92

Tested by

no test coverage detected