processTxns handles the processing of transactions based on whether they are split or single. It delegates to the appropriate processing function based on the presence of split transactions. Parameters: - ctx context.Context: The context for the operation. - originalTxn *model.Transaction: The orig
(ctx context.Context, originalTxn *model.Transaction, splitTxns []*model.Transaction, originalTxnID, originalRef string)
| 1908 | // - []*model.Transaction: A slice of processed transactions ready for queueing. |
| 1909 | // - error: An error if the processing fails. |
| 1910 | func (l *LedgerForge) processTxns(ctx context.Context, originalTxn *model.Transaction, splitTxns []*model.Transaction, originalTxnID, originalRef string) ([]*model.Transaction, error) { |
| 1911 | if originalTxn.SkipQueue { |
| 1912 | if len(splitTxns) == 0 { |
| 1913 | recorded, err := l.RecordTransaction(ctx, originalTxn) |
| 1914 | if err != nil { |
| 1915 | return nil, err |
| 1916 | } |
| 1917 | return []*model.Transaction{recorded}, nil |
| 1918 | } else { |
| 1919 | result := make([]*model.Transaction, len(splitTxns)) |
| 1920 | for i, txn := range splitTxns { |
| 1921 | recorded, err := l.RecordTransaction(ctx, txn) |
| 1922 | if err != nil { |
| 1923 | if txn.Atomic { |
| 1924 | l.handleAsyncBulkTransactionFailure(ctx, err, originalTxnID, true, txn.Inflight) |
| 1925 | } |
| 1926 | return nil, fmt.Errorf("failed to record split transaction %d: %w", i, err) |
| 1927 | } |
| 1928 | result[i] = recorded |
| 1929 | } |
| 1930 | return result, nil |
| 1931 | } |
| 1932 | } |
| 1933 | if len(splitTxns) == 0 { |
| 1934 | return l.processSingleTransaction(ctx, originalTxn, originalRef) |
| 1935 | } |
| 1936 | return l.processSplitTransactions(ctx, splitTxns, originalTxnID, originalRef) |
| 1937 | } |
| 1938 | |
| 1939 | // processSingleTransaction handles the processing of a single (non-split) transaction. |
| 1940 | // It prepares the transaction, persists it to the database, and creates a queue copy. |
no test coverage detected