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

Method RecordMatch

database/reconciliation.go:279–294  ·  view source on GitHub ↗

RecordMatch inserts a single match into the database. It is used to record the match between external and internal transactions during reconciliation. Parameters: - ctx: Context for managing request and tracing. - match: A pointer to the Match struct containing details of the external and internal t

(ctx context.Context, match *model.Match)

Source from the content-addressed store, hash-verified

277// Returns:
278// - An error if the operation fails, wrapped in an APIError for consistency.
279func (d Datasource) RecordMatch(ctx context.Context, match *model.Match) error {
280 ctx, span := otel.Tracer("reconciliation.database").Start(ctx, "Saving match to db")
281 defer span.End()
282
283 _, err := d.Conn.ExecContext(ctx,
284 `INSERT INTO ledgerforge.matches(
285 external_transaction_id, internal_transaction_id, reconciliation_id, amount, date
286 ) VALUES ($1, $2, $3, $4, $5)`,
287 match.ExternalTransactionID, match.InternalTransactionID, match.ReconciliationID, match.Amount, match.Date,
288 )
289 if err != nil {
290 return apierror.NewAPIError(apierror.ErrInternalServer, "Failed to record match", err)
291 }
292
293 return nil
294}
295
296// GetMatchesByReconciliationID retrieves all matches associated with a given reconciliation ID.
297// It joins the matches table with external transactions to filter matches by reconciliation ID.

Callers 2

TestRecordMatch_SuccessFunction · 0.95
TestRecordMatch_ErrorFunction · 0.95

Calls 2

NewAPIErrorFunction · 0.92
StartMethod · 0.45

Tested by 2

TestRecordMatch_SuccessFunction · 0.76
TestRecordMatch_ErrorFunction · 0.76