finalizeReconciliation finalizes the reconciliation process by updating its status and recording the final match/unmatch counts. Parameters: - ctx: The context controlling the request. - reconciliation: The reconciliation object representing the current process. - matchCount: The number of matched t
(ctx context.Context, reconciliation model.Reconciliation, matchCount, unmatchedCount int)
| 584 | // Returns: |
| 585 | // - error: If any error occurs during finalization. |
| 586 | func (s *LedgerForge) finalizeReconciliation(ctx context.Context, reconciliation model.Reconciliation, matchCount, unmatchedCount int) error { |
| 587 | // Update the reconciliation status to "completed". |
| 588 | reconciliation.Status = StatusCompleted |
| 589 | reconciliation.UnmatchedTransactions = unmatchedCount |
| 590 | reconciliation.MatchedTransactions = matchCount |
| 591 | reconciliation.CompletedAt = ptr.Time(time.Now()) |
| 592 | |
| 593 | logrus.Infof("Finalizing reconciliation. Matches: %d, Unmatched: %d", matchCount, unmatchedCount) |
| 594 | |
| 595 | if !reconciliation.IsDryRun { |
| 596 | s.postReconciliationActions(ctx, reconciliation) |
| 597 | } else { |
| 598 | logrus.Infof("Dry run completed. Matches: %d, Unmatched: %d", matchCount, unmatchedCount) |
| 599 | } |
| 600 | |
| 601 | // Update the final reconciliation status and counts in the data source. |
| 602 | err := s.datasource.UpdateReconciliationStatus(ctx, reconciliation.ReconciliationID, StatusCompleted, matchCount, unmatchedCount) |
| 603 | if err != nil { |
| 604 | logrus.Errorf("Error updating reconciliation status: %v", err) |
| 605 | return err |
| 606 | } |
| 607 | |
| 608 | logrus.Infof("Reconciliation %s completed. Total matches: %d, Total unmatched: %d", reconciliation.ReconciliationID, matchCount, unmatchedCount) |
| 609 | |
| 610 | return nil |
| 611 | } |
| 612 | |
| 613 | // oneToOneReconciliation performs a one-to-one reconciliation, where each external transaction is matched against |
| 614 | // a single internal transaction. The process is parallelized using goroutines. |
no test coverage detected