- Melhora Importação: ignora linhas vazias/inválidas automaticamente. - Filtros Server-Side: busca em todas as páginas (FOT, Nome, etc.). - Colunas Novas: adiciona Curso, Instituição, Ano e Empresa na tabela. - UI/UX: Corrige ordenação (vazios no fim) e adiciona scrollbar no topo.
648 lines
21 KiB
Go
648 lines
21 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 countTransactions = `-- name: CountTransactions :one
|
|
SELECT COUNT(*) FROM financial_transactions
|
|
`
|
|
|
|
func (q *Queries) CountTransactions(ctx context.Context) (int64, error) {
|
|
row := q.db.QueryRow(ctx, countTransactions)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const countTransactionsFiltered = `-- name: CountTransactionsFiltered :one
|
|
SELECT COUNT(*)
|
|
FROM financial_transactions t
|
|
LEFT JOIN cadastro_fot f ON t.fot_id = f.id
|
|
WHERE
|
|
($1::text = '' OR CAST(f.fot AS TEXT) ILIKE '%' || $1 || '%') AND
|
|
($2::text = '' OR CAST(t.data_cobranca AS TEXT) ILIKE '%' || $2 || '%') AND
|
|
($3::text = '' OR t.tipo_evento ILIKE '%' || $3 || '%') AND
|
|
($4::text = '' OR t.tipo_servico ILIKE '%' || $4 || '%') AND
|
|
($5::text = '' OR t.professional_name ILIKE '%' || $5 || '%')
|
|
`
|
|
|
|
type CountTransactionsFilteredParams struct {
|
|
Fot string `json:"fot"`
|
|
Data string `json:"data"`
|
|
Evento string `json:"evento"`
|
|
Servico string `json:"servico"`
|
|
Nome string `json:"nome"`
|
|
}
|
|
|
|
func (q *Queries) CountTransactionsFiltered(ctx context.Context, arg CountTransactionsFilteredParams) (int64, error) {
|
|
row := q.db.QueryRow(ctx, countTransactionsFiltered,
|
|
arg.Fot,
|
|
arg.Data,
|
|
arg.Evento,
|
|
arg.Servico,
|
|
arg.Nome,
|
|
)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
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, profissional_id
|
|
) VALUES (
|
|
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15
|
|
) 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"`
|
|
ProfissionalID pgtype.UUID `json:"profissional_id"`
|
|
}
|
|
|
|
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,
|
|
arg.ProfissionalID,
|
|
)
|
|
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 NULLS LAST
|
|
`
|
|
|
|
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.Text `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.Text `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 listTransactionsPaginated = `-- name: ListTransactionsPaginated :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,
|
|
a.ano_semestre as ano_formatura,
|
|
f.instituicao as instituicao_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
|
|
LEFT JOIN anos_formaturas a ON f.ano_formatura_id = a.id
|
|
ORDER BY t.data_cobranca DESC NULLS LAST
|
|
LIMIT $1 OFFSET $2
|
|
`
|
|
|
|
type ListTransactionsPaginatedParams struct {
|
|
Limit int32 `json:"limit"`
|
|
Offset int32 `json:"offset"`
|
|
}
|
|
|
|
type ListTransactionsPaginatedRow 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.Text `json:"fot_numero"`
|
|
EmpresaNome pgtype.Text `json:"empresa_nome"`
|
|
CursoNome pgtype.Text `json:"curso_nome"`
|
|
AnoFormatura pgtype.Text `json:"ano_formatura"`
|
|
InstituicaoNome pgtype.Text `json:"instituicao_nome"`
|
|
}
|
|
|
|
func (q *Queries) ListTransactionsPaginated(ctx context.Context, arg ListTransactionsPaginatedParams) ([]ListTransactionsPaginatedRow, error) {
|
|
rows, err := q.db.Query(ctx, listTransactionsPaginated, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListTransactionsPaginatedRow
|
|
for rows.Next() {
|
|
var i ListTransactionsPaginatedRow
|
|
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,
|
|
&i.AnoFormatura,
|
|
&i.InstituicaoNome,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listTransactionsPaginatedFiltered = `-- name: ListTransactionsPaginatedFiltered :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,
|
|
a.ano_semestre as ano_formatura,
|
|
f.instituicao as instituicao_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
|
|
LEFT JOIN anos_formaturas a ON f.ano_formatura_id = a.id
|
|
WHERE
|
|
($3::text = '' OR CAST(f.fot AS TEXT) ILIKE '%' || $3 || '%') AND
|
|
($4::text = '' OR CAST(t.data_cobranca AS TEXT) ILIKE '%' || $4 || '%') AND
|
|
($5::text = '' OR t.tipo_evento ILIKE '%' || $5 || '%') AND
|
|
($6::text = '' OR t.tipo_servico ILIKE '%' || $6 || '%') AND
|
|
($7::text = '' OR t.professional_name ILIKE '%' || $7 || '%')
|
|
ORDER BY t.data_cobranca DESC NULLS LAST
|
|
LIMIT $1 OFFSET $2
|
|
`
|
|
|
|
type ListTransactionsPaginatedFilteredParams struct {
|
|
Limit int32 `json:"limit"`
|
|
Offset int32 `json:"offset"`
|
|
Fot string `json:"fot"`
|
|
Data string `json:"data"`
|
|
Evento string `json:"evento"`
|
|
Servico string `json:"servico"`
|
|
Nome string `json:"nome"`
|
|
}
|
|
|
|
type ListTransactionsPaginatedFilteredRow 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.Text `json:"fot_numero"`
|
|
EmpresaNome pgtype.Text `json:"empresa_nome"`
|
|
CursoNome pgtype.Text `json:"curso_nome"`
|
|
AnoFormatura pgtype.Text `json:"ano_formatura"`
|
|
InstituicaoNome pgtype.Text `json:"instituicao_nome"`
|
|
}
|
|
|
|
func (q *Queries) ListTransactionsPaginatedFiltered(ctx context.Context, arg ListTransactionsPaginatedFilteredParams) ([]ListTransactionsPaginatedFilteredRow, error) {
|
|
rows, err := q.db.Query(ctx, listTransactionsPaginatedFiltered,
|
|
arg.Limit,
|
|
arg.Offset,
|
|
arg.Fot,
|
|
arg.Data,
|
|
arg.Evento,
|
|
arg.Servico,
|
|
arg.Nome,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListTransactionsPaginatedFilteredRow
|
|
for rows.Next() {
|
|
var i ListTransactionsPaginatedFilteredRow
|
|
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,
|
|
&i.AnoFormatura,
|
|
&i.InstituicaoNome,
|
|
); 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
|
|
}
|