processSingleTransaction handles the processing of a single (non-split) transaction. It prepares the transaction, persists it to the database, and creates a queue copy. Parameters: - ctx context.Context: The context for the operation. - transaction *model.Transaction: The single transaction to proc
(ctx context.Context, transaction *model.Transaction, originalRef string)
| 1948 | // - []*model.Transaction: A slice containing the processed transaction ready for queueing. |
| 1949 | // - error: An error if the transaction processing fails. |
| 1950 | func (l *LedgerForge) processSingleTransaction(ctx context.Context, transaction *model.Transaction, originalRef string) ([]*model.Transaction, error) { |
| 1951 | if len(transaction.Sources) == 0 && len(transaction.Destinations) == 0 { |
| 1952 | preparedTxn, err := l.prepareTransactionForQueue(ctx, transaction) |
| 1953 | if err != nil { |
| 1954 | return nil, err |
| 1955 | } |
| 1956 | transaction = preparedTxn |
| 1957 | } |
| 1958 | |
| 1959 | persistedTxn, err := l.datasource.RecordTransaction(ctx, transaction) |
| 1960 | if err != nil { |
| 1961 | return nil, fmt.Errorf("failed to persist original transaction: %w", err) |
| 1962 | } |
| 1963 | |
| 1964 | queueTxn := createQueueCopy(persistedTxn, originalRef) |
| 1965 | return []*model.Transaction{queueTxn}, nil |
| 1966 | } |
| 1967 | |
| 1968 | // processSplitTransactions handles the processing of multiple split transactions. |
| 1969 | // It prepares each split transaction, persists them to the database, and creates queue copies. |
no test coverage detected