// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.30.0
// source: finance.sql

package generated

import (
	"context"

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

const bulkUpdateExtras = `-- name: BulkUpdateExtras :exec
UPDATE financial_transactions
SET 
  valor_extra = COALESCE(valor_extra, 0) + $1,
  descricao_extra = CASE 
    WHEN descricao_extra IS NULL OR descricao_extra = '' THEN $2 
    ELSE descricao_extra || ' + ' || $2 
  END,
  total_pagar = valor_free + (COALESCE(valor_extra, 0) + $1)
WHERE id = ANY($3::uuid[])
`

type BulkUpdateExtrasParams struct {
	ValorExtra     pgtype.Numeric `json:"valor_extra"`
	DescricaoExtra pgtype.Text    `json:"descricao_extra"`
	Ids            []pgtype.UUID  `json:"ids"`
}

func (q *Queries) BulkUpdateExtras(ctx context.Context, arg BulkUpdateExtrasParams) error {
	_, err := q.db.Exec(ctx, bulkUpdateExtras, arg.ValorExtra, arg.DescricaoExtra, arg.Ids)
	return err
}
