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

Method InstantReconciliation

api/reconciliation_api.go:108–145  ·  view source on GitHub ↗

InstantReconciliation initiates a reconciliation process with externally provided transactions without requiring a prior file upload. It processes the transactions directly and returns the reconciliation ID. Parameters: - c: The Gin context containing the request and response. Responses: - 400 Bad

(c *gin.Context)

Source from the content-addressed store, hash-verified

106// - 500 Internal Server Error: If there is an error starting the reconciliation process.
107// - 200 OK: If the reconciliation process is successfully started.
108func (a Api) InstantReconciliation(c *gin.Context) {
109 var req struct {
110 ExternalTransactions []model.ExternalTransaction `json:"external_transactions" binding:"required"`
111 Strategy string `json:"strategy" binding:"required"`
112 GroupingCriteria string `json:"grouping_criteria"`
113 DryRun bool `json:"dry_run"`
114 MatchingRuleIDs []string `json:"matching_rule_ids" binding:"required"`
115 }
116
117 if err := c.ShouldBindJSON(&req); err != nil {
118 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
119 return
120 }
121 if len(req.ExternalTransactions) == 0 {
122 c.JSON(http.StatusBadRequest, gin.H{"error": "external_transactions is required"})
123 return
124 }
125 if len(req.MatchingRuleIDs) == 0 {
126 c.JSON(http.StatusBadRequest, gin.H{"error": "matching_rule_ids is required"})
127 return
128 }
129
130 reconciliationID, err := a.ledgerforge.StartInstantReconciliation(
131 c.Request.Context(),
132 req.ExternalTransactions,
133 req.Strategy,
134 req.GroupingCriteria,
135 req.MatchingRuleIDs,
136 req.DryRun,
137 )
138 if err != nil {
139 logrus.Error(err)
140 c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to start instant reconciliation"})
141 return
142 }
143
144 c.JSON(http.StatusOK, gin.H{"reconciliation_id": reconciliationID})
145}
146
147// GetReconciliation retrieves details about a specific reconciliation by its ID.
148//

Callers

nothing calls this directly

Calls 2

ErrorMethod · 0.45

Tested by

no test coverage detected