// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.27.0
// source: finance_hardening.sql

package db

import (
	"context"

	"github.com/jackc/pgx/v5/pgtype"
	"github.com/shopspring/decimal"
)

const accountBalancesByCode = `-- name: AccountBalancesByCode :many
SELECT a.code, a.name,
       COALESCE(jl.debit, 0)::numeric AS debit,
       COALESCE(jl.credit, 0)::numeric AS credit
FROM accounts a
LEFT JOIN (
    SELECT l.account_id, SUM(l.debit) AS debit, SUM(l.credit) AS credit
    FROM journal_lines l
    JOIN journal_entries e ON e.id = l.journal_entry_id
    WHERE e.status IN ('posted','reversed')
    GROUP BY l.account_id
) jl ON jl.account_id = a.id
WHERE a.code = ANY($1::text[])
`

type AccountBalancesByCodeRow struct {
	Code   string          `json:"code"`
	Name   string          `json:"name"`
	Debit  decimal.Decimal `json:"debit"`
	Credit decimal.Decimal `json:"credit"`
}

// Per-COA-account movement totals (all-time) for the cashflow page's
// "Saldo & Aset" cards. Journal lines count when posted/reversed; cashflow
// lines count against their account_id. Cash accounts (1xxx) read from
// journal lines only since cashflows carry account ids of the COA.
func (q *Queries) AccountBalancesByCode(ctx context.Context, codes []string) ([]AccountBalancesByCodeRow, error) {
	rows, err := q.db.Query(ctx, accountBalancesByCode, codes)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []AccountBalancesByCodeRow
	for rows.Next() {
		var i AccountBalancesByCodeRow
		if err := rows.Scan(
			&i.Code,
			&i.Name,
			&i.Debit,
			&i.Credit,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const accountMovementTotals = `-- name: AccountMovementTotals :one
SELECT COALESCE(SUM(CASE WHEN type='income'  AND transaction_date <  $1::date THEN amount END),0)::numeric AS opening_in,
       COALESCE(SUM(CASE WHEN type='expense' AND transaction_date <  $1::date THEN amount END),0)::numeric AS opening_out,
       COALESCE(SUM(CASE WHEN type='income'  AND transaction_date >= $1::date
                          AND ($2::date IS NULL OR transaction_date <= $2::date) THEN amount END),0)::numeric AS period_in,
       COALESCE(SUM(CASE WHEN type='expense' AND transaction_date >= $1::date
                          AND ($2::date IS NULL OR transaction_date <= $2::date) THEN amount END),0)::numeric AS period_out
FROM cashflows
WHERE ($3::bigint IS NULL OR account_id = $3::bigint)
  -- GET /cashflow-balances. Scoped (migration 000104) for the same reason as
  -- SummarizeCashflows: this is four SUMS over cashflows, so an unscoped
  -- version hands a till operator the company's opening balance and period
  -- movement without showing a single row. Not optional here.
  AND ($4::bigint[] IS NULL OR store_id = ANY($4::bigint[]))
`

type AccountMovementTotalsParams struct {
	DateFrom  pgtype.Date `json:"date_from"`
	DateTo    pgtype.Date `json:"date_to"`
	AccountID int64       `json:"account_id"`
	StoreIds  []int64     `json:"store_ids"`
}

type AccountMovementTotalsRow struct {
	OpeningIn  decimal.Decimal `json:"opening_in"`
	OpeningOut decimal.Decimal `json:"opening_out"`
	PeriodIn   decimal.Decimal `json:"period_in"`
	PeriodOut  decimal.Decimal `json:"period_out"`
}

// Cash/bank balances are derived from authoritative transactions only.
// Generated rows (invoice payments etc.) carry no account yet and are
// reported under the system-wide bucket; manual entries always carry one.
func (q *Queries) AccountMovementTotals(ctx context.Context, arg AccountMovementTotalsParams) (AccountMovementTotalsRow, error) {
	row := q.db.QueryRow(ctx, accountMovementTotals,
		arg.DateFrom,
		arg.DateTo,
		arg.AccountID,
		arg.StoreIds,
	)
	var i AccountMovementTotalsRow
	err := row.Scan(
		&i.OpeningIn,
		&i.OpeningOut,
		&i.PeriodIn,
		&i.PeriodOut,
	)
	return i, err
}

const countPaymentVouchers = `-- name: CountPaymentVouchers :one
SELECT count(*) FROM payment_vouchers WHERE ($1::text IS NULL OR status = $1)
`

func (q *Queries) CountPaymentVouchers(ctx context.Context, status pgtype.Text) (int64, error) {
	row := q.db.QueryRow(ctx, countPaymentVouchers, status)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const createCashAccount = `-- name: CreateCashAccount :one
INSERT INTO cash_accounts (name, account_type, bank_name, bank_account_number, created_by)
VALUES ($1, $2, $3, $4, $5)
RETURNING id, name, account_type, bank_name, bank_account_number, is_active, created_by, created_at, updated_at
`

type CreateCashAccountParams struct {
	Name              string      `json:"name"`
	AccountType       string      `json:"account_type"`
	BankName          pgtype.Text `json:"bank_name"`
	BankAccountNumber pgtype.Text `json:"bank_account_number"`
	CreatedBy         pgtype.Int8 `json:"created_by"`
}

func (q *Queries) CreateCashAccount(ctx context.Context, arg CreateCashAccountParams) (CashAccount, error) {
	row := q.db.QueryRow(ctx, createCashAccount,
		arg.Name,
		arg.AccountType,
		arg.BankName,
		arg.BankAccountNumber,
		arg.CreatedBy,
	)
	var i CashAccount
	err := row.Scan(
		&i.ID,
		&i.Name,
		&i.AccountType,
		&i.BankName,
		&i.BankAccountNumber,
		&i.IsActive,
		&i.CreatedBy,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return i, err
}

const createCashflowV2 = `-- name: CreateCashflowV2 :exec
INSERT INTO cashflows (transaction_number, type, category, transaction_date, amount, description,
  reference_type, reference_id, created_by, account_id, counterpart_account_id, flow_type, payment_method)
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13)
`

type CreateCashflowV2Params struct {
	TransactionNumber    string          `json:"transaction_number"`
	Type                 string          `json:"type"`
	Category             string          `json:"category"`
	TransactionDate      pgtype.Date     `json:"transaction_date"`
	Amount               decimal.Decimal `json:"amount"`
	Description          pgtype.Text     `json:"description"`
	ReferenceType        pgtype.Text     `json:"reference_type"`
	ReferenceID          pgtype.Int8     `json:"reference_id"`
	CreatedBy            pgtype.Int8     `json:"created_by"`
	AccountID            pgtype.Int8     `json:"account_id"`
	CounterpartAccountID pgtype.Int8     `json:"counterpart_account_id"`
	FlowType             pgtype.Text     `json:"flow_type"`
	PaymentMethod        pgtype.Text     `json:"payment_method"`
}

func (q *Queries) CreateCashflowV2(ctx context.Context, arg CreateCashflowV2Params) error {
	_, err := q.db.Exec(ctx, createCashflowV2,
		arg.TransactionNumber,
		arg.Type,
		arg.Category,
		arg.TransactionDate,
		arg.Amount,
		arg.Description,
		arg.ReferenceType,
		arg.ReferenceID,
		arg.CreatedBy,
		arg.AccountID,
		arg.CounterpartAccountID,
		arg.FlowType,
		arg.PaymentMethod,
	)
	return err
}

const createPaymentVoucher = `-- name: CreatePaymentVoucher :one
INSERT INTO payment_vouchers (voucher_number, voucher_date, account_id, payee, payment_method,
  reference, description, total_amount, status, created_by)
VALUES ($1, $2, $3, $4, $5, $7, $8, $6, 'draft', $9)
RETURNING id, voucher_number, voucher_date, account_id, payee, payment_method, reference, description, total_amount, status, attachment_key, created_by, approved_by, approved_at, created_at, updated_at
`

type CreatePaymentVoucherParams struct {
	VoucherNumber string          `json:"voucher_number"`
	VoucherDate   pgtype.Date     `json:"voucher_date"`
	AccountID     int64           `json:"account_id"`
	Payee         string          `json:"payee"`
	PaymentMethod string          `json:"payment_method"`
	TotalAmount   decimal.Decimal `json:"total_amount"`
	Reference     pgtype.Text     `json:"reference"`
	Description   pgtype.Text     `json:"description"`
	CreatedBy     pgtype.Int8     `json:"created_by"`
}

func (q *Queries) CreatePaymentVoucher(ctx context.Context, arg CreatePaymentVoucherParams) (PaymentVoucher, error) {
	row := q.db.QueryRow(ctx, createPaymentVoucher,
		arg.VoucherNumber,
		arg.VoucherDate,
		arg.AccountID,
		arg.Payee,
		arg.PaymentMethod,
		arg.TotalAmount,
		arg.Reference,
		arg.Description,
		arg.CreatedBy,
	)
	var i PaymentVoucher
	err := row.Scan(
		&i.ID,
		&i.VoucherNumber,
		&i.VoucherDate,
		&i.AccountID,
		&i.Payee,
		&i.PaymentMethod,
		&i.Reference,
		&i.Description,
		&i.TotalAmount,
		&i.Status,
		&i.AttachmentKey,
		&i.CreatedBy,
		&i.ApprovedBy,
		&i.ApprovedAt,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return i, err
}

const createPaymentVoucherLine = `-- name: CreatePaymentVoucherLine :one
INSERT INTO payment_voucher_lines (voucher_id, account_id, description, amount, reference)
VALUES ($1, $2, $4, $3, $5)
RETURNING id, voucher_id, account_id, description, amount, reference
`

type CreatePaymentVoucherLineParams struct {
	VoucherID   int64           `json:"voucher_id"`
	AccountID   int64           `json:"account_id"`
	Amount      decimal.Decimal `json:"amount"`
	Description pgtype.Text     `json:"description"`
	Reference   pgtype.Text     `json:"reference"`
}

func (q *Queries) CreatePaymentVoucherLine(ctx context.Context, arg CreatePaymentVoucherLineParams) (PaymentVoucherLine, error) {
	row := q.db.QueryRow(ctx, createPaymentVoucherLine,
		arg.VoucherID,
		arg.AccountID,
		arg.Amount,
		arg.Description,
		arg.Reference,
	)
	var i PaymentVoucherLine
	err := row.Scan(
		&i.ID,
		&i.VoucherID,
		&i.AccountID,
		&i.Description,
		&i.Amount,
		&i.Reference,
	)
	return i, err
}

const execSetPVStatus = `-- name: ExecSetPVStatus :execrows
UPDATE payment_vouchers SET status=$2,
  approved_by=COALESCE($3, approved_by),
  approved_at=CASE WHEN $2='posted' THEN now() ELSE approved_at END,
  updated_at=now()
WHERE id=$1
`

type ExecSetPVStatusParams struct {
	ID         int64       `json:"id"`
	Status     string      `json:"status"`
	ApprovedBy pgtype.Int8 `json:"approved_by"`
}

func (q *Queries) ExecSetPVStatus(ctx context.Context, arg ExecSetPVStatusParams) (int64, error) {
	result, err := q.db.Exec(ctx, execSetPVStatus, arg.ID, arg.Status, arg.ApprovedBy)
	if err != nil {
		return 0, err
	}
	return result.RowsAffected(), nil
}

const execUpdateVoucherTotal = `-- name: ExecUpdateVoucherTotal :execrows
UPDATE payment_vouchers SET total_amount=$2, updated_at=now() WHERE id=$1
`

type ExecUpdateVoucherTotalParams struct {
	ID          int64           `json:"id"`
	TotalAmount decimal.Decimal `json:"total_amount"`
}

func (q *Queries) ExecUpdateVoucherTotal(ctx context.Context, arg ExecUpdateVoucherTotalParams) (int64, error) {
	result, err := q.db.Exec(ctx, execUpdateVoucherTotal, arg.ID, arg.TotalAmount)
	if err != nil {
		return 0, err
	}
	return result.RowsAffected(), nil
}

const getCashAccount = `-- name: GetCashAccount :one
SELECT id, name, account_type, bank_name, bank_account_number, is_active
FROM cash_accounts WHERE id=$1
`

type GetCashAccountRow struct {
	ID                int64       `json:"id"`
	Name              string      `json:"name"`
	AccountType       string      `json:"account_type"`
	BankName          pgtype.Text `json:"bank_name"`
	BankAccountNumber pgtype.Text `json:"bank_account_number"`
	IsActive          bool        `json:"is_active"`
}

func (q *Queries) GetCashAccount(ctx context.Context, id int64) (GetCashAccountRow, error) {
	row := q.db.QueryRow(ctx, getCashAccount, id)
	var i GetCashAccountRow
	err := row.Scan(
		&i.ID,
		&i.Name,
		&i.AccountType,
		&i.BankName,
		&i.BankAccountNumber,
		&i.IsActive,
	)
	return i, err
}

const getPaymentVoucher = `-- name: GetPaymentVoucher :one
SELECT id, voucher_number, voucher_date, account_id, payee, payment_method, reference, description, total_amount, status, attachment_key, created_by, approved_by, approved_at, created_at, updated_at FROM payment_vouchers WHERE id=$1
`

func (q *Queries) GetPaymentVoucher(ctx context.Context, id int64) (PaymentVoucher, error) {
	row := q.db.QueryRow(ctx, getPaymentVoucher, id)
	var i PaymentVoucher
	err := row.Scan(
		&i.ID,
		&i.VoucherNumber,
		&i.VoucherDate,
		&i.AccountID,
		&i.Payee,
		&i.PaymentMethod,
		&i.Reference,
		&i.Description,
		&i.TotalAmount,
		&i.Status,
		&i.AttachmentKey,
		&i.CreatedBy,
		&i.ApprovedBy,
		&i.ApprovedAt,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return i, err
}

const getPaymentVoucherForUpdate = `-- name: GetPaymentVoucherForUpdate :one
SELECT id, voucher_number, voucher_date, account_id, payee, payment_method, reference, description, total_amount, status, attachment_key, created_by, approved_by, approved_at, created_at, updated_at FROM payment_vouchers WHERE id=$1 FOR UPDATE
`

func (q *Queries) GetPaymentVoucherForUpdate(ctx context.Context, id int64) (PaymentVoucher, error) {
	row := q.db.QueryRow(ctx, getPaymentVoucherForUpdate, id)
	var i PaymentVoucher
	err := row.Scan(
		&i.ID,
		&i.VoucherNumber,
		&i.VoucherDate,
		&i.AccountID,
		&i.Payee,
		&i.PaymentMethod,
		&i.Reference,
		&i.Description,
		&i.TotalAmount,
		&i.Status,
		&i.AttachmentKey,
		&i.CreatedBy,
		&i.ApprovedBy,
		&i.ApprovedAt,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return i, err
}

const listAccounts = `-- name: ListAccounts :many
SELECT id, code, name, type, is_active FROM accounts
WHERE ($1::bool IS NULL OR is_active = $1::bool) ORDER BY code
`

type ListAccountsRow struct {
	ID       int64  `json:"id"`
	Code     string `json:"code"`
	Name     string `json:"name"`
	Type     string `json:"type"`
	IsActive bool   `json:"is_active"`
}

func (q *Queries) ListAccounts(ctx context.Context, active pgtype.Bool) ([]ListAccountsRow, error) {
	rows, err := q.db.Query(ctx, listAccounts, active)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []ListAccountsRow
	for rows.Next() {
		var i ListAccountsRow
		if err := rows.Scan(
			&i.ID,
			&i.Code,
			&i.Name,
			&i.Type,
			&i.IsActive,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listCashAccounts = `-- name: ListCashAccounts :many
SELECT id, name, account_type, bank_name, bank_account_number, is_active
FROM cash_accounts WHERE ($1::bool IS NULL OR is_active = $1::bool)
ORDER BY account_type, name
`

type ListCashAccountsRow struct {
	ID                int64       `json:"id"`
	Name              string      `json:"name"`
	AccountType       string      `json:"account_type"`
	BankName          pgtype.Text `json:"bank_name"`
	BankAccountNumber pgtype.Text `json:"bank_account_number"`
	IsActive          bool        `json:"is_active"`
}

func (q *Queries) ListCashAccounts(ctx context.Context, active pgtype.Bool) ([]ListCashAccountsRow, error) {
	rows, err := q.db.Query(ctx, listCashAccounts, active)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []ListCashAccountsRow
	for rows.Next() {
		var i ListCashAccountsRow
		if err := rows.Scan(
			&i.ID,
			&i.Name,
			&i.AccountType,
			&i.BankName,
			&i.BankAccountNumber,
			&i.IsActive,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listCashflowsByRef = `-- name: ListCashflowsByRef :many
SELECT id, transaction_number, type, category, amount, description, reference_type, reference_id,
       account_id, counterpart_account_id, flow_type, payment_method
FROM cashflows WHERE reference_type=$1 AND reference_id=$2 ORDER BY id
`

type ListCashflowsByRefParams struct {
	ReferenceType pgtype.Text `json:"reference_type"`
	ReferenceID   pgtype.Int8 `json:"reference_id"`
}

type ListCashflowsByRefRow struct {
	ID                   int64           `json:"id"`
	TransactionNumber    string          `json:"transaction_number"`
	Type                 string          `json:"type"`
	Category             string          `json:"category"`
	Amount               decimal.Decimal `json:"amount"`
	Description          pgtype.Text     `json:"description"`
	ReferenceType        pgtype.Text     `json:"reference_type"`
	ReferenceID          pgtype.Int8     `json:"reference_id"`
	AccountID            pgtype.Int8     `json:"account_id"`
	CounterpartAccountID pgtype.Int8     `json:"counterpart_account_id"`
	FlowType             pgtype.Text     `json:"flow_type"`
	PaymentMethod        pgtype.Text     `json:"payment_method"`
}

func (q *Queries) ListCashflowsByRef(ctx context.Context, arg ListCashflowsByRefParams) ([]ListCashflowsByRefRow, error) {
	rows, err := q.db.Query(ctx, listCashflowsByRef, arg.ReferenceType, arg.ReferenceID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []ListCashflowsByRefRow
	for rows.Next() {
		var i ListCashflowsByRefRow
		if err := rows.Scan(
			&i.ID,
			&i.TransactionNumber,
			&i.Type,
			&i.Category,
			&i.Amount,
			&i.Description,
			&i.ReferenceType,
			&i.ReferenceID,
			&i.AccountID,
			&i.CounterpartAccountID,
			&i.FlowType,
			&i.PaymentMethod,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listPaymentVoucherLines = `-- name: ListPaymentVoucherLines :many
SELECT l.id, l.voucher_id, l.account_id, a.code AS account_code, a.name AS account_name,
       l.description, l.amount, l.reference
FROM payment_voucher_lines l JOIN accounts a ON a.id = l.account_id
WHERE l.voucher_id=$1 ORDER BY l.id
`

type ListPaymentVoucherLinesRow struct {
	ID          int64           `json:"id"`
	VoucherID   int64           `json:"voucher_id"`
	AccountID   int64           `json:"account_id"`
	AccountCode string          `json:"account_code"`
	AccountName string          `json:"account_name"`
	Description pgtype.Text     `json:"description"`
	Amount      decimal.Decimal `json:"amount"`
	Reference   pgtype.Text     `json:"reference"`
}

func (q *Queries) ListPaymentVoucherLines(ctx context.Context, voucherID int64) ([]ListPaymentVoucherLinesRow, error) {
	rows, err := q.db.Query(ctx, listPaymentVoucherLines, voucherID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []ListPaymentVoucherLinesRow
	for rows.Next() {
		var i ListPaymentVoucherLinesRow
		if err := rows.Scan(
			&i.ID,
			&i.VoucherID,
			&i.AccountID,
			&i.AccountCode,
			&i.AccountName,
			&i.Description,
			&i.Amount,
			&i.Reference,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listPaymentVouchers = `-- name: ListPaymentVouchers :many
SELECT pv.id, pv.voucher_number, pv.voucher_date, pv.account_id, pv.payee, pv.payment_method, pv.reference, pv.description, pv.total_amount, pv.status, pv.attachment_key, pv.created_by, pv.approved_by, pv.approved_at, pv.created_at, pv.updated_at, ca.name AS account_name
FROM payment_vouchers pv JOIN cash_accounts ca ON ca.id = pv.account_id
WHERE ($3::text IS NULL OR pv.status = $3)
ORDER BY pv.id DESC LIMIT $1 OFFSET $2
`

type ListPaymentVouchersParams struct {
	Limit  int32       `json:"limit"`
	Offset int32       `json:"offset"`
	Status pgtype.Text `json:"status"`
}

type ListPaymentVouchersRow struct {
	ID            int64              `json:"id"`
	VoucherNumber string             `json:"voucher_number"`
	VoucherDate   pgtype.Date        `json:"voucher_date"`
	AccountID     int64              `json:"account_id"`
	Payee         string             `json:"payee"`
	PaymentMethod string             `json:"payment_method"`
	Reference     pgtype.Text        `json:"reference"`
	Description   pgtype.Text        `json:"description"`
	TotalAmount   decimal.Decimal    `json:"total_amount"`
	Status        string             `json:"status"`
	AttachmentKey pgtype.Text        `json:"attachment_key"`
	CreatedBy     pgtype.Int8        `json:"created_by"`
	ApprovedBy    pgtype.Int8        `json:"approved_by"`
	ApprovedAt    pgtype.Timestamptz `json:"approved_at"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	UpdatedAt     pgtype.Timestamptz `json:"updated_at"`
	AccountName   string             `json:"account_name"`
}

func (q *Queries) ListPaymentVouchers(ctx context.Context, arg ListPaymentVouchersParams) ([]ListPaymentVouchersRow, error) {
	rows, err := q.db.Query(ctx, listPaymentVouchers, arg.Limit, arg.Offset, arg.Status)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []ListPaymentVouchersRow
	for rows.Next() {
		var i ListPaymentVouchersRow
		if err := rows.Scan(
			&i.ID,
			&i.VoucherNumber,
			&i.VoucherDate,
			&i.AccountID,
			&i.Payee,
			&i.PaymentMethod,
			&i.Reference,
			&i.Description,
			&i.TotalAmount,
			&i.Status,
			&i.AttachmentKey,
			&i.CreatedBy,
			&i.ApprovedBy,
			&i.ApprovedAt,
			&i.CreatedAt,
			&i.UpdatedAt,
			&i.AccountName,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const setPaymentVoucherStatus = `-- name: SetPaymentVoucherStatus :execrows
UPDATE payment_vouchers SET status=$2, approved_by=$4,
  approved_at=CASE WHEN $2='posted' THEN now() ELSE approved_at END, updated_at=now()
WHERE id=$1 AND status=$3
`

type SetPaymentVoucherStatusParams struct {
	ID         int64       `json:"id"`
	Status     string      `json:"status"`
	Status_2   string      `json:"status_2"`
	ApprovedBy pgtype.Int8 `json:"approved_by"`
}

func (q *Queries) SetPaymentVoucherStatus(ctx context.Context, arg SetPaymentVoucherStatusParams) (int64, error) {
	result, err := q.db.Exec(ctx, setPaymentVoucherStatus,
		arg.ID,
		arg.Status,
		arg.Status_2,
		arg.ApprovedBy,
	)
	if err != nil {
		return 0, err
	}
	return result.RowsAffected(), nil
}
