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

Method RecordExternalTransaction

database/reconciliation.go:349–364  ·  view source on GitHub ↗

RecordExternalTransaction inserts a new external transaction into the database. It associates the transaction with an upload ID and records its details. Parameters: - ctx: Context for managing request and tracing. - tx: Pointer to the ExternalTransaction struct containing transaction data. - uploadI

(ctx context.Context, tx *model.ExternalTransaction, uploadID string)

Source from the content-addressed store, hash-verified

347// Returns:
348// - An error if the operation fails, wrapped in an APIError for consistency.
349func (d Datasource) RecordExternalTransaction(ctx context.Context, tx *model.ExternalTransaction, uploadID string) error {
350 ctx, span := otel.Tracer("reconciliation.database").Start(ctx, "Saving external transaction to db")
351 defer span.End()
352
353 _, err := d.Conn.ExecContext(ctx,
354 `INSERT INTO ledgerforge.external_transactions(
355 id, amount, reference, currency, description, date, source, upload_id
356 ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)`,
357 tx.ID, tx.Amount, tx.Reference, tx.Currency, tx.Description, tx.Date, tx.Source, uploadID,
358 )
359 if err != nil {
360 return apierror.NewAPIError(apierror.ErrInternalServer, "Failed to record external transaction", err)
361 }
362
363 return nil
364}
365
366// GetExternalTransactionsByReconciliationID fetches all external transactions associated with a given reconciliation ID.
367// Parameters:

Calls 2

NewAPIErrorFunction · 0.92
StartMethod · 0.45