reconciliation

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	StatusStarted    = "started"     // Indicates the process has started.
	StatusInProgress = "in_progress" // Indicates the process is ongoing.
	StatusCompleted  = "completed"   // Indicates the process is finished successfully.
	StatusFailed     = "failed"      // Indicates the process has failed.
)

Status constants representing the various states a process can be in.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxWorkers       int
	BatchSize        int
	ProgressInterval int
}

Config controls reconciliation workers and checkpoint frequency.

type FetchTransactions

type FetchTransactions func(context.Context, string, int, int64) ([]*model.Transaction, error)

type ProcessTransaction

type ProcessTransaction func(context.Context, *model.Transaction) error

type Repository

type Repository interface {
	GetTransactionsPaginated(ctx context.Context, id string, batchSize int, offset int64) ([]*model.Transaction, error)
	GroupTransactions(ctx context.Context, groupCriteria string, batchSize int, offset int64) (map[string][]*model.Transaction, error)
	GetTransactionsByCriteria(ctx context.Context, minAmount, maxAmount *float64, currency *string, minDate, maxDate *time.Time, limit int, offset int64) ([]*model.Transaction, error)
	RecordReconciliation(ctx context.Context, rec *model.Reconciliation) error
	GetReconciliation(ctx context.Context, id string) (*model.Reconciliation, error)
	UpdateReconciliationStatus(ctx context.Context, id string, status string, matchedCount, unmatchedCount int) error
	GetExternalTransactionsPaginated(ctx context.Context, uploadID string, batchSize int, offset int64) ([]*model.ExternalTransaction, error)
	RecordExternalTransaction(ctx context.Context, tx *model.ExternalTransaction, reconciliationID string) error
	RecordMatchingRule(ctx context.Context, rule *model.MatchingRule) error
	GetMatchingRules(ctx context.Context) ([]*model.MatchingRule, error)
	GetMatchingRule(ctx context.Context, id string) (*model.MatchingRule, error)
	UpdateMatchingRule(ctx context.Context, rule *model.MatchingRule) error
	DeleteMatchingRule(ctx context.Context, id string) error
	SaveReconciliationProgress(ctx context.Context, reconciliationID string, progress model.ReconciliationProgress) error
	LoadReconciliationProgress(ctx context.Context, reconciliationID string) (model.ReconciliationProgress, error)
	RecordMatches(ctx context.Context, reconciliationID string, matches []model.Match) error
	RecordUnmatched(ctx context.Context, reconciliationID string, results []string) error
	FetchAndGroupExternalTransactions(ctx context.Context, uploadID string, groupCriteria string, batchSize int, offset int64) (map[string][]*model.Transaction, error)
}

Repository contains only the persistence operations reconciliation consumes.

type RunBatches

RunBatches adapts the existing transaction batch runner without owning it. It must wait for every worker before returning.

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(repository Repository, configuration func() Config, runBatches RunBatches,
	updateMetadata func(context.Context, string, map[string]interface{}) error,
	indexReconciliation func(model.Reconciliation),
) *Service

func (*Service) CreateMatchingRule

func (s *Service) CreateMatchingRule(ctx context.Context, rule model.MatchingRule) (*model.MatchingRule, error)

CreateMatchingRule creates a new matching rule after validating it. Parameters: - ctx: The context for managing the request. - rule: The matching rule to be created. Returns the created rule, or an error if validation or storage fails.

func (*Service) DeleteMatchingRule

func (s *Service) DeleteMatchingRule(ctx context.Context, id string) error

DeleteMatchingRule deletes a matching rule by its ID. Parameters: - ctx: The context for managing the request. - id: The ID of the rule to delete. Returns an error if deletion fails.

func (*Service) GetMatchingRule

func (s *Service) GetMatchingRule(ctx context.Context, id string) (*model.MatchingRule, error)

GetMatchingRule retrieves a matching rule by its ID. Parameters: - ctx: The context for managing the request. - id: The ID of the matching rule to retrieve. Returns the matching rule, or an error if retrieval fails.

func (*Service) GetReconciliation

func (s *Service) GetReconciliation(ctx context.Context, reconciliationID string) (*model.Reconciliation, error)

GetReconciliation retrieves a reconciliation by its ID. Parameters: - ctx: The context controlling the request. - reconciliationID: The ID of the reconciliation to retrieve. Returns: - *model.Reconciliation: The retrieved reconciliation object. - error: If the reconciliation cannot be found or if retrieval fails.

func (*Service) ListMatchingRules

func (s *Service) ListMatchingRules(ctx context.Context) ([]*model.MatchingRule, error)

ListMatchingRules retrieves all matching rules. Parameters: - ctx: The context for managing the request. Returns a list of matching rules, or an error if retrieval fails.

func (*Service) StartInstantReconciliation

func (s *Service) StartInstantReconciliation(ctx context.Context, externalTransactions []model.ExternalTransaction,
	strategy string, groupCriteria string, matchingRuleIDs []string, isDryRun bool,
) (string, error)

StartInstantReconciliation initiates a reconciliation process directly with provided transactions instead of loading them from an uploaded file. Parameters: - ctx: The context controlling the reconciliation process. - externalTransactions: The array of external transactions to reconcile. - strategy: The reconciliation strategy to be used (e.g., "one_to_one"). - groupCriteria: Criteria to group transactions (optional). - matchingRuleIDs: The IDs of the rules used for matching transactions. - isDryRun: If true, the reconciliation will not commit changes (useful for testing). Returns: - string: The ID of the reconciliation process. - error: If the reconciliation fails to start.

func (*Service) StartReconciliation

func (s *Service) StartReconciliation(ctx context.Context, uploadID string, strategy string, groupCriteria string, matchingRuleIDs []string, isDryRun bool) (string, error)

StartReconciliation initiates the reconciliation process by creating a new reconciliation entry and starting the process asynchronously. The process is detached to run in the background. Parameters: - ctx: The context controlling the reconciliation process. - uploadID: The ID of the uploaded transaction file to reconcile. - strategy: The reconciliation strategy to be used (e.g., "one_to_one"). - groupCriteria: Criteria to group transactions (optional). - matchingRuleIDs: The IDs of the rules used for matching transactions. - isDryRun: If true, the reconciliation will not commit changes (useful for testing). Returns: - string: The ID of the reconciliation process. - error: If the reconciliation fails to start.

func (*Service) UpdateMatchingRule

func (s *Service) UpdateMatchingRule(ctx context.Context, rule model.MatchingRule) (*model.MatchingRule, error)

UpdateMatchingRule updates an existing matching rule. It retrieves the existing rule, validates the new data, and then updates the rule. Parameters: - ctx: The context for managing the request. - rule: The updated rule data. Returns the updated rule, or an error if validation or update fails.

func (*Service) UploadExternalData

func (s *Service) UploadExternalData(ctx context.Context, source string, reader io.Reader, filename string) (string, int, error)

UploadExternalData handles the process of uploading external data by detecting file type, parsing, and storing it. Parameters: - ctx: The context for controlling execution. - source: The source of the external data. - reader: An io.Reader for reading the data. - filename: The name of the file being uploaded. Returns: - string: The ID of the upload. - int: The total number of records processed. - error: If any step of the process fails.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL