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

Method CreateMatchingRule

reconciliation.go:1112–1130  ·  view source on GitHub ↗

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.

(ctx context.Context, rule model.MatchingRule)

Source from the content-addressed store, hash-verified

1110// - rule: The matching rule to be created.
1111// Returns the created rule, or an error if validation or storage fails.
1112func (s *LedgerForge) CreateMatchingRule(ctx context.Context, rule model.MatchingRule) (*model.MatchingRule, error) {
1113 rule.RuleID = model.GenerateUUIDWithSuffix("rule") // Generate a unique rule ID.
1114 rule.CreatedAt = time.Now()
1115 rule.UpdatedAt = time.Now()
1116
1117 // Validate the rule before storing it.
1118 err := s.validateRule(&rule)
1119 if err != nil {
1120 return nil, err
1121 }
1122
1123 // Store the rule in the datasource.
1124 err = s.datasource.RecordMatchingRule(ctx, &rule)
1125 if err != nil {
1126 return nil, err
1127 }
1128
1129 return &rule, nil
1130}
1131
1132// GetMatchingRule retrieves a matching rule by its ID.
1133// Parameters:

Callers

nothing calls this directly

Calls 3

validateRuleMethod · 0.95
GenerateUUIDWithSuffixFunction · 0.92
RecordMatchingRuleMethod · 0.65

Tested by

no test coverage detected