/*
   This file is part of TALER
   Copyright (C) 2026 Taler Systems SA

   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU General Public License as published by the Free Software
   Foundation; either version 3, or (at your option) any later version.

   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

   You should have received a copy of the GNU General Public License along with
   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */
/**
 * @file src/auditordb/insert_kycauth_in_inconsistency.c
 * @brief Implementation of the insert_kycauth_in_inconsistency function for Postgres
 * @author Christian Grothoff
 */
#include "taler/taler_pq_lib.h"
#include "pg_helper.h"
#include "auditor-database/insert_kycauth_in_inconsistency.h"


enum GNUNET_DB_QueryStatus
TALER_AUDITORDB_insert_kycauth_in_inconsistency (
  struct TALER_AUDITORDB_PostgresContext *pg,
  const struct TALER_AUDITORDB_KycauthInInconsistency *dc)
{
  struct GNUNET_PQ_QueryParam params[] = {
    GNUNET_PQ_query_param_uint64 (&dc->bank_row_id),
    TALER_PQ_query_param_amount (pg->conn,
                                 &dc->amount_exchange_expected),
    TALER_PQ_query_param_amount (pg->conn,
                                 &dc->amount_wired),
    GNUNET_PQ_query_param_auto_from_type (&dc->account_pub),
    GNUNET_PQ_query_param_absolute_time (&dc->timestamp),
    GNUNET_PQ_query_param_string (dc->account.full_payto),
    GNUNET_PQ_query_param_string (dc->diagnostic),
    GNUNET_PQ_query_param_end
  };

  PREPARE (pg,
           "insert_kycauth_in_inconsistency",
           "INSERT INTO auditor_kycauth_in_inconsistency "
           "(bank_row_id,"
           " amount_exchange_expected,"
           " amount_wired,"
           " account_pub,"
           " timestamp,"
           " account,"
           " diagnostic"
           ") VALUES ($1,$2,$3,$4,$5,$6,$7);"
           );
  return GNUNET_PQ_eval_prepared_non_select (
    pg->conn,
    "insert_kycauth_in_inconsistency",
    params);
}
