matchSingleTransaction attempts to match a single transaction with a group of transactions based on matching rules. If a match is found, it sends the match to the match channel and marks the group as processed. Parameters: - singleTxn: The single transaction to match. - groupedTxns: The grouped tran
(singleTxn *model.Transaction, groupedTxns map[string][]*model.Transaction, groupMap map[string]bool, matchingRules []model.MatchingRule, isExternalGrouped bool, matchChan chan model.Match)
| 865 | // Returns: |
| 866 | // - bool: True if a match is found, false otherwise. |
| 867 | func (s *LedgerForge) matchSingleTransaction(singleTxn *model.Transaction, groupedTxns map[string][]*model.Transaction, groupMap map[string]bool, matchingRules []model.MatchingRule, isExternalGrouped bool, matchChan chan model.Match) bool { |
| 868 | for groupKey := range groupMap { |
| 869 | if s.matchesGroup(singleTxn, groupedTxns[groupKey], matchingRules) { |
| 870 | for _, groupedTxn := range groupedTxns[groupKey] { |
| 871 | var externalID, internalID string |
| 872 | if isExternalGrouped { |
| 873 | externalID = groupedTxn.TransactionID |
| 874 | internalID = singleTxn.TransactionID |
| 875 | } else { |
| 876 | externalID = singleTxn.TransactionID |
| 877 | internalID = groupedTxn.TransactionID |
| 878 | } |
| 879 | // Send the match result to the channel. |
| 880 | matchChan <- model.Match{ |
| 881 | ExternalTransactionID: externalID, |
| 882 | InternalTransactionID: internalID, |
| 883 | Amount: groupedTxn.Amount, |
| 884 | Date: groupedTxn.CreatedAt, |
| 885 | } |
| 886 | } |
| 887 | delete(groupMap, groupKey) // Mark the group as processed. |
| 888 | return true |
| 889 | } |
| 890 | } |
| 891 | return false |
| 892 | } |
| 893 | |
| 894 | // oneToMany performs the core logic for one-to-many reconciliation. |
| 895 | // Parameters are similar to `manyToOne`, but it processes transactions in reverse (one external to many internal). |
no test coverage detected