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

Method processReconciliation

reconciliation.go:334–369  ·  view source on GitHub ↗

processReconciliation manages the full reconciliation process by executing each step: updating the status, fetching rules, processing transactions, and finalizing the reconciliation. Parameters: - ctx: The context controlling the process. - reconciliation: The reconciliation object representing the

(ctx context.Context, reconciliation model.Reconciliation, strategy string, groupCriteria string, matchingRuleIDs []string)

Source from the content-addressed store, hash-verified

332// Returns:
333// - error: If any step in the reconciliation process fails.
334func (s *LedgerForge) processReconciliation(ctx context.Context, reconciliation model.Reconciliation, strategy string, groupCriteria string, matchingRuleIDs []string) error {
335 // Update the reconciliation status to "in progress".
336 if err := s.updateReconciliationStatus(ctx, reconciliation.ReconciliationID, StatusInProgress); err != nil {
337 return fmt.Errorf("failed to update reconciliation status: %w", err)
338 }
339
340 // Retrieve the matching rules that apply to the reconciliation.
341 matchingRules, err := s.getMatchingRules(ctx, matchingRuleIDs)
342 if err != nil {
343 return fmt.Errorf("failed to get matching rules: %w", err)
344 }
345
346 // Initialize the reconciliation progress.
347 progress, err := s.initializeReconciliationProgress(ctx, reconciliation.ReconciliationID)
348 if err != nil {
349 return fmt.Errorf("failed to initialize reconciliation progress: %w", err)
350 }
351
352 // Create the reconciler function based on the strategy and rules.
353 reconciler := s.createReconciler(strategy, reconciliation.UploadID, groupCriteria, matchingRules)
354
355 // Create a transaction processor to handle the reconciliation logic.
356 processor := s.createTransactionProcessor(reconciliation, progress, reconciler)
357
358 // Process the transactions for reconciliation based on the chosen strategy.
359 err = s.processTransactions(ctx, reconciliation.UploadID, processor, strategy)
360 if err != nil {
361 return fmt.Errorf("failed to process transactions: %w", err)
362 }
363
364 // After processing, retrieve the results (matched and unmatched counts).
365 matched, unmatched := processor.getResults()
366
367 // Finalize the reconciliation by updating the status and recording the results.
368 return s.finalizeReconciliation(ctx, reconciliation, matched, unmatched)
369}
370
371// updateReconciliationStatus updates the status of a reconciliation process in the database.
372// Parameters:

Callers 2

StartReconciliationMethod · 0.95

Calls 8

getMatchingRulesMethod · 0.95
createReconcilerMethod · 0.95
processTransactionsMethod · 0.95
getResultsMethod · 0.80

Tested by

no test coverage detected