photum/backend/internal/db/generated/financial_transactions.sql.go
NANDO9322 943b4f6506 feat(financeiro): implementação do extrato financeiro do profissional e melhorias na agenda
- Backend:
  - Adicionado endpoint para extrato financeiro do profissional (/meus-pagamentos).
  - Atualizada query SQL para incluir nome da empresa e curso nos detalhes da transação.
  - Adicionado retorno de valores (Free, Extra, Descrição) na API.

- Frontend:
  - Nova página "Meus Pagamentos" com modal de detalhes da transação.
  - Removido componente antigo PhotographerFinance.
  - Ajustado filtro de motoristas na Logística para exibir apenas profissionais atribuídos e com carro.
  - Corrigida exibição da função do profissional na Escala (mostra a função atribuída no evento, ex: Cinegrafista).
  - Melhoria no botão de voltar na tela de detalhes do evento.
2026-01-16 16:07:49 -03:00

403 lines
12 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: financial_transactions.sql
package generated
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const createTransaction = `-- name: CreateTransaction :one
INSERT INTO financial_transactions (
fot_id, data_cobranca, tipo_evento, tipo_servico, professional_name,
whatsapp, cpf, tabela_free, valor_free, valor_extra, descricao_extra,
total_pagar, data_pagamento, pgto_ok
) VALUES (
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14
) RETURNING id, fot_id, data_cobranca, tipo_evento, tipo_servico, professional_name, whatsapp, cpf, tabela_free, valor_free, valor_extra, descricao_extra, total_pagar, data_pagamento, pgto_ok, criado_em, atualizado_em, profissional_id
`
type CreateTransactionParams struct {
FotID pgtype.UUID `json:"fot_id"`
DataCobranca pgtype.Date `json:"data_cobranca"`
TipoEvento pgtype.Text `json:"tipo_evento"`
TipoServico pgtype.Text `json:"tipo_servico"`
ProfessionalName pgtype.Text `json:"professional_name"`
Whatsapp pgtype.Text `json:"whatsapp"`
Cpf pgtype.Text `json:"cpf"`
TabelaFree pgtype.Text `json:"tabela_free"`
ValorFree pgtype.Numeric `json:"valor_free"`
ValorExtra pgtype.Numeric `json:"valor_extra"`
DescricaoExtra pgtype.Text `json:"descricao_extra"`
TotalPagar pgtype.Numeric `json:"total_pagar"`
DataPagamento pgtype.Date `json:"data_pagamento"`
PgtoOk pgtype.Bool `json:"pgto_ok"`
}
func (q *Queries) CreateTransaction(ctx context.Context, arg CreateTransactionParams) (FinancialTransaction, error) {
row := q.db.QueryRow(ctx, createTransaction,
arg.FotID,
arg.DataCobranca,
arg.TipoEvento,
arg.TipoServico,
arg.ProfessionalName,
arg.Whatsapp,
arg.Cpf,
arg.TabelaFree,
arg.ValorFree,
arg.ValorExtra,
arg.DescricaoExtra,
arg.TotalPagar,
arg.DataPagamento,
arg.PgtoOk,
)
var i FinancialTransaction
err := row.Scan(
&i.ID,
&i.FotID,
&i.DataCobranca,
&i.TipoEvento,
&i.TipoServico,
&i.ProfessionalName,
&i.Whatsapp,
&i.Cpf,
&i.TabelaFree,
&i.ValorFree,
&i.ValorExtra,
&i.DescricaoExtra,
&i.TotalPagar,
&i.DataPagamento,
&i.PgtoOk,
&i.CriadoEm,
&i.AtualizadoEm,
&i.ProfissionalID,
)
return i, err
}
const deleteTransaction = `-- name: DeleteTransaction :exec
DELETE FROM financial_transactions WHERE id = $1
`
func (q *Queries) DeleteTransaction(ctx context.Context, id pgtype.UUID) error {
_, err := q.db.Exec(ctx, deleteTransaction, id)
return err
}
const getTransaction = `-- name: GetTransaction :one
SELECT id, fot_id, data_cobranca, tipo_evento, tipo_servico, professional_name, whatsapp, cpf, tabela_free, valor_free, valor_extra, descricao_extra, total_pagar, data_pagamento, pgto_ok, criado_em, atualizado_em, profissional_id FROM financial_transactions WHERE id = $1
`
func (q *Queries) GetTransaction(ctx context.Context, id pgtype.UUID) (FinancialTransaction, error) {
row := q.db.QueryRow(ctx, getTransaction, id)
var i FinancialTransaction
err := row.Scan(
&i.ID,
&i.FotID,
&i.DataCobranca,
&i.TipoEvento,
&i.TipoServico,
&i.ProfessionalName,
&i.Whatsapp,
&i.Cpf,
&i.TabelaFree,
&i.ValorFree,
&i.ValorExtra,
&i.DescricaoExtra,
&i.TotalPagar,
&i.DataPagamento,
&i.PgtoOk,
&i.CriadoEm,
&i.AtualizadoEm,
&i.ProfissionalID,
)
return i, err
}
const listTransactions = `-- name: ListTransactions :many
SELECT t.id, t.fot_id, t.data_cobranca, t.tipo_evento, t.tipo_servico, t.professional_name, t.whatsapp, t.cpf, t.tabela_free, t.valor_free, t.valor_extra, t.descricao_extra, t.total_pagar, t.data_pagamento, t.pgto_ok, t.criado_em, t.atualizado_em, t.profissional_id, f.fot as fot_numero
FROM financial_transactions t
LEFT JOIN cadastro_fot f ON t.fot_id = f.id
ORDER BY t.data_cobranca DESC
`
type ListTransactionsRow struct {
ID pgtype.UUID `json:"id"`
FotID pgtype.UUID `json:"fot_id"`
DataCobranca pgtype.Date `json:"data_cobranca"`
TipoEvento pgtype.Text `json:"tipo_evento"`
TipoServico pgtype.Text `json:"tipo_servico"`
ProfessionalName pgtype.Text `json:"professional_name"`
Whatsapp pgtype.Text `json:"whatsapp"`
Cpf pgtype.Text `json:"cpf"`
TabelaFree pgtype.Text `json:"tabela_free"`
ValorFree pgtype.Numeric `json:"valor_free"`
ValorExtra pgtype.Numeric `json:"valor_extra"`
DescricaoExtra pgtype.Text `json:"descricao_extra"`
TotalPagar pgtype.Numeric `json:"total_pagar"`
DataPagamento pgtype.Date `json:"data_pagamento"`
PgtoOk pgtype.Bool `json:"pgto_ok"`
CriadoEm pgtype.Timestamptz `json:"criado_em"`
AtualizadoEm pgtype.Timestamptz `json:"atualizado_em"`
ProfissionalID pgtype.UUID `json:"profissional_id"`
FotNumero pgtype.Int4 `json:"fot_numero"`
}
func (q *Queries) ListTransactions(ctx context.Context) ([]ListTransactionsRow, error) {
rows, err := q.db.Query(ctx, listTransactions)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListTransactionsRow
for rows.Next() {
var i ListTransactionsRow
if err := rows.Scan(
&i.ID,
&i.FotID,
&i.DataCobranca,
&i.TipoEvento,
&i.TipoServico,
&i.ProfessionalName,
&i.Whatsapp,
&i.Cpf,
&i.TabelaFree,
&i.ValorFree,
&i.ValorExtra,
&i.DescricaoExtra,
&i.TotalPagar,
&i.DataPagamento,
&i.PgtoOk,
&i.CriadoEm,
&i.AtualizadoEm,
&i.ProfissionalID,
&i.FotNumero,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listTransactionsByFot = `-- name: ListTransactionsByFot :many
SELECT id, fot_id, data_cobranca, tipo_evento, tipo_servico, professional_name, whatsapp, cpf, tabela_free, valor_free, valor_extra, descricao_extra, total_pagar, data_pagamento, pgto_ok, criado_em, atualizado_em, profissional_id FROM financial_transactions
WHERE fot_id = $1
ORDER BY data_cobranca DESC
`
func (q *Queries) ListTransactionsByFot(ctx context.Context, fotID pgtype.UUID) ([]FinancialTransaction, error) {
rows, err := q.db.Query(ctx, listTransactionsByFot, fotID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []FinancialTransaction
for rows.Next() {
var i FinancialTransaction
if err := rows.Scan(
&i.ID,
&i.FotID,
&i.DataCobranca,
&i.TipoEvento,
&i.TipoServico,
&i.ProfessionalName,
&i.Whatsapp,
&i.Cpf,
&i.TabelaFree,
&i.ValorFree,
&i.ValorExtra,
&i.DescricaoExtra,
&i.TotalPagar,
&i.DataPagamento,
&i.PgtoOk,
&i.CriadoEm,
&i.AtualizadoEm,
&i.ProfissionalID,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listTransactionsByProfessional = `-- name: ListTransactionsByProfessional :many
SELECT t.id, t.fot_id, t.data_cobranca, t.tipo_evento, t.tipo_servico, t.professional_name, t.whatsapp, t.cpf, t.tabela_free, t.valor_free, t.valor_extra, t.descricao_extra, t.total_pagar, t.data_pagamento, t.pgto_ok, t.criado_em, t.atualizado_em, t.profissional_id, f.fot as fot_numero, e.nome as empresa_nome, c.nome as curso_nome
FROM financial_transactions t
LEFT JOIN cadastro_fot f ON t.fot_id = f.id
LEFT JOIN empresas e ON f.empresa_id = e.id
LEFT JOIN cursos c ON f.curso_id = c.id
WHERE
t.profissional_id = $1
OR (
$2::text <> '' AND
REGEXP_REPLACE(t.cpf, '\D', '', 'g') = REGEXP_REPLACE($2, '\D', '', 'g')
)
ORDER BY t.data_cobranca DESC
`
type ListTransactionsByProfessionalParams struct {
ProfissionalID pgtype.UUID `json:"profissional_id"`
Column2 string `json:"column_2"`
}
type ListTransactionsByProfessionalRow struct {
ID pgtype.UUID `json:"id"`
FotID pgtype.UUID `json:"fot_id"`
DataCobranca pgtype.Date `json:"data_cobranca"`
TipoEvento pgtype.Text `json:"tipo_evento"`
TipoServico pgtype.Text `json:"tipo_servico"`
ProfessionalName pgtype.Text `json:"professional_name"`
Whatsapp pgtype.Text `json:"whatsapp"`
Cpf pgtype.Text `json:"cpf"`
TabelaFree pgtype.Text `json:"tabela_free"`
ValorFree pgtype.Numeric `json:"valor_free"`
ValorExtra pgtype.Numeric `json:"valor_extra"`
DescricaoExtra pgtype.Text `json:"descricao_extra"`
TotalPagar pgtype.Numeric `json:"total_pagar"`
DataPagamento pgtype.Date `json:"data_pagamento"`
PgtoOk pgtype.Bool `json:"pgto_ok"`
CriadoEm pgtype.Timestamptz `json:"criado_em"`
AtualizadoEm pgtype.Timestamptz `json:"atualizado_em"`
ProfissionalID pgtype.UUID `json:"profissional_id"`
FotNumero pgtype.Int4 `json:"fot_numero"`
EmpresaNome pgtype.Text `json:"empresa_nome"`
CursoNome pgtype.Text `json:"curso_nome"`
}
func (q *Queries) ListTransactionsByProfessional(ctx context.Context, arg ListTransactionsByProfessionalParams) ([]ListTransactionsByProfessionalRow, error) {
rows, err := q.db.Query(ctx, listTransactionsByProfessional, arg.ProfissionalID, arg.Column2)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListTransactionsByProfessionalRow
for rows.Next() {
var i ListTransactionsByProfessionalRow
if err := rows.Scan(
&i.ID,
&i.FotID,
&i.DataCobranca,
&i.TipoEvento,
&i.TipoServico,
&i.ProfessionalName,
&i.Whatsapp,
&i.Cpf,
&i.TabelaFree,
&i.ValorFree,
&i.ValorExtra,
&i.DescricaoExtra,
&i.TotalPagar,
&i.DataPagamento,
&i.PgtoOk,
&i.CriadoEm,
&i.AtualizadoEm,
&i.ProfissionalID,
&i.FotNumero,
&i.EmpresaNome,
&i.CursoNome,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const sumTotalByFot = `-- name: SumTotalByFot :one
SELECT COALESCE(SUM(total_pagar), 0)::NUMERIC
FROM financial_transactions
WHERE fot_id = $1
`
func (q *Queries) SumTotalByFot(ctx context.Context, fotID pgtype.UUID) (pgtype.Numeric, error) {
row := q.db.QueryRow(ctx, sumTotalByFot, fotID)
var column_1 pgtype.Numeric
err := row.Scan(&column_1)
return column_1, err
}
const updateTransaction = `-- name: UpdateTransaction :one
UPDATE financial_transactions SET
fot_id = $2, data_cobranca = $3, tipo_evento = $4, tipo_servico = $5,
professional_name = $6, whatsapp = $7, cpf = $8, tabela_free = $9,
valor_free = $10, valor_extra = $11, descricao_extra = $12,
total_pagar = $13, data_pagamento = $14, pgto_ok = $15,
atualizado_em = NOW()
WHERE id = $1
RETURNING id, fot_id, data_cobranca, tipo_evento, tipo_servico, professional_name, whatsapp, cpf, tabela_free, valor_free, valor_extra, descricao_extra, total_pagar, data_pagamento, pgto_ok, criado_em, atualizado_em, profissional_id
`
type UpdateTransactionParams struct {
ID pgtype.UUID `json:"id"`
FotID pgtype.UUID `json:"fot_id"`
DataCobranca pgtype.Date `json:"data_cobranca"`
TipoEvento pgtype.Text `json:"tipo_evento"`
TipoServico pgtype.Text `json:"tipo_servico"`
ProfessionalName pgtype.Text `json:"professional_name"`
Whatsapp pgtype.Text `json:"whatsapp"`
Cpf pgtype.Text `json:"cpf"`
TabelaFree pgtype.Text `json:"tabela_free"`
ValorFree pgtype.Numeric `json:"valor_free"`
ValorExtra pgtype.Numeric `json:"valor_extra"`
DescricaoExtra pgtype.Text `json:"descricao_extra"`
TotalPagar pgtype.Numeric `json:"total_pagar"`
DataPagamento pgtype.Date `json:"data_pagamento"`
PgtoOk pgtype.Bool `json:"pgto_ok"`
}
func (q *Queries) UpdateTransaction(ctx context.Context, arg UpdateTransactionParams) (FinancialTransaction, error) {
row := q.db.QueryRow(ctx, updateTransaction,
arg.ID,
arg.FotID,
arg.DataCobranca,
arg.TipoEvento,
arg.TipoServico,
arg.ProfessionalName,
arg.Whatsapp,
arg.Cpf,
arg.TabelaFree,
arg.ValorFree,
arg.ValorExtra,
arg.DescricaoExtra,
arg.TotalPagar,
arg.DataPagamento,
arg.PgtoOk,
)
var i FinancialTransaction
err := row.Scan(
&i.ID,
&i.FotID,
&i.DataCobranca,
&i.TipoEvento,
&i.TipoServico,
&i.ProfessionalName,
&i.Whatsapp,
&i.Cpf,
&i.TabelaFree,
&i.ValorFree,
&i.ValorExtra,
&i.DescricaoExtra,
&i.TotalPagar,
&i.DataPagamento,
&i.PgtoOk,
&i.CriadoEm,
&i.AtualizadoEm,
&i.ProfissionalID,
)
return i, err
}