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

Method oneToMany

reconciliation.go:898–924  ·  view source on GitHub ↗

oneToMany performs the core logic for one-to-many reconciliation. Parameters are similar to `manyToOne`, but it processes transactions in reverse (one external to many internal). Returns: - error: If any error occurs during processing.

(ctx context.Context, singleTxn []*model.Transaction, matchingRules []model.MatchingRule, isExternalGrouped bool, wg *sync.WaitGroup, groupingCriteria string, batchSize int, matchChan chan model.Match, unMatchChan chan string)

Source from the content-addressed store, hash-verified

896// Returns:
897// - error: If any error occurs during processing.
898func (s *LedgerForge) oneToMany(ctx context.Context, singleTxn []*model.Transaction, matchingRules []model.MatchingRule, isExternalGrouped bool, wg *sync.WaitGroup, groupingCriteria string, batchSize int, matchChan chan model.Match, unMatchChan chan string) error {
899 offset := int64(0)
900 ctx, span := otel.Tracer("ledgerforge.reconciliation").Start(ctx, "ProcessOneToMany")
901 defer span.End()
902
903 for {
904 txns, err := s.groupInternalTransactions(ctx, groupingCriteria, batchSize, offset)
905 if err != nil {
906 logrus.Errorf("Error grouping internal transactions: %v", err)
907 break
908 }
909 if len(txns) == 0 {
910 span.AddEvent("No more grouped transactions to process")
911 break
912 }
913 groupMap := s.buildGroupMap(txns)
914 err = s.processGroupedTransactions(singleTxn, txns, groupMap, matchingRules, isExternalGrouped, wg, matchChan, unMatchChan)
915 if err != nil {
916 logrus.Errorf("Error in one-to-many reconciliation: %v", err)
917 }
918 if len(groupMap) == 0 {
919 break
920 }
921 offset += int64(batchSize)
922 }
923 return nil
924}
925
926// buildGroupMap creates a map for tracking unprocessed transaction groups.
927// Parameters:

Callers 1

Calls 4

buildGroupMapMethod · 0.95
StartMethod · 0.45

Tested by

no test coverage detected