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

Method UpdateReconciliationStatus

database/reconciliation.go:100–125  ·  view source on GitHub ↗

UpdateReconciliationStatus updates the status, matched transactions, unmatched transactions, and completed_at timestamp of a reconciliation in the database. Parameters: - ctx: Context for managing request and tracing. - id: The reconciliation ID to update. - status: The new status of the reconciliat

(ctx context.Context, id string, status string, matchedCount, unmatchedCount int)

Source from the content-addressed store, hash-verified

98// Returns:
99// - An error if the update fails or the reconciliation is not found.
100func (d Datasource) UpdateReconciliationStatus(ctx context.Context, id string, status string, matchedCount, unmatchedCount int) error {
101 ctx, span := otel.Tracer("reconciliation.database").Start(ctx, "Updating reconciliation status")
102 defer span.End()
103
104 completedAt := sql.NullTime{Time: time.Now(), Valid: status == "completed"}
105
106 result, err := d.Conn.ExecContext(ctx, `
107 UPDATE ledgerforge.reconciliations
108 SET status = $2, matched_transactions = $3, unmatched_transactions = $4, completed_at = $5
109 WHERE reconciliation_id = $1
110 `, id, status, matchedCount, unmatchedCount, completedAt)
111 if err != nil {
112 return apierror.NewAPIError(apierror.ErrInternalServer, "Failed to update reconciliation status", err)
113 }
114
115 rowsAffected, err := result.RowsAffected()
116 if err != nil {
117 return apierror.NewAPIError(apierror.ErrInternalServer, "Failed to get rows affected", err)
118 }
119
120 if rowsAffected == 0 {
121 return apierror.NewAPIError(apierror.ErrNotFound, fmt.Sprintf("Reconciliation with ID '%s' not found", id), nil)
122 }
123
124 return nil
125}
126
127// GetReconciliationsByUploadID retrieves all reconciliations associated with a specific upload ID, ordered by the start date in descending order.
128// Parameters:

Calls 2

NewAPIErrorFunction · 0.92
StartMethod · 0.45