/*
   This file is part of TALER
   Copyright (C) 2023 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/include/donau-database/insert_receipts_submitted.h
 * @brief implementation of the insert_receipts_submitted function for Postgres
 * @author Johannes Casaburi
 */
#ifndef DONAU_DATABASE_INSERT_RECEIPTS_SUBMITTED_H
#define DONAU_DATABASE_INSERT_RECEIPTS_SUBMITTED_H

#include "donaudb_lib.h"


/**
 * Insert submitted donation receipt from the donor.
 *
 * @param ctx closure
 * @param h_donor_tax_id salted hash of the donors tax number
 * @param num_dr number of donation receipts
 * @param donation_receipts array of donation receipts
 * @param donation_year year of the donation
 * @param[out] conflict_index set to the index of the first receipt that
 *             could NOT be stored because a *different* receipt with the
 *             same nonce already exists, or to @a num_dr if all receipts
 *             were stored (or were idempotent repetitions of this donor's
 *             own receipts)
 * @param[out] unknown_du_index set to the index of the first receipt whose
 *             @e h_donation_unit_pub is not in the donation_units table, or
 *             to @a num_dr if all units are known; if this is not @a num_dr
 *             then *nothing* was written and @a conflict_index is unset
 * @return transaction status code
 */
enum GNUNET_DB_QueryStatus
DONAUDB_insert_receipts_submitted (
  struct DONAUDB_PostgresContext *ctx,
  struct DONAU_HashDonorTaxId *h_donor_tax_id,
  size_t num_dr,
  const struct DONAU_DonationReceipt donation_receipts[static num_dr],
  uint64_t donation_year,
  size_t *conflict_index,
  size_t *unknown_du_index);

#endif
