All checks were successful
Dev Build & Deploy Portal / build-deploy (push) Successful in 2m58s
Integra débitos, pagamentos e guias emitidas com API via composables e modais de extrato. Simplifica filtros do portal ao escopo do contribuinte logado. Refatora emissão pública de certidão com modelos dinâmicos e contrato idModelo. Corrige status de taxas (2=Paga, 3=Cancelada) e melhorias no proxy BFF/Keycloak. Co-authored-by: Cursor <cursoragent@cursor.com>
140 lines
4.7 KiB
JavaScript
140 lines
4.7 KiB
JavaScript
// Todas as chamadas vão via /api/proxy/** (BFF injeta Bearer + tenant headers).
|
|
|
|
const FETCH_HEADERS = { 'X-Requested-With': 'fetch' }
|
|
|
|
function proxyUrl(path) {
|
|
return `/api/proxy${path}`
|
|
}
|
|
|
|
function limparParams(params) {
|
|
const out = {}
|
|
for (const [k, v] of Object.entries(params)) {
|
|
if (v !== null && v !== undefined && v !== '') out[k] = v
|
|
}
|
|
return out
|
|
}
|
|
|
|
export const portalService = {
|
|
getPainelResumo() {
|
|
return $fetch(proxyUrl('/contribuinte/painel/resumo'), { headers: FETCH_HEADERS })
|
|
},
|
|
|
|
getAtividades(pagina = 0, tamanho = 5) {
|
|
return $fetch(proxyUrl('/contribuinte/painel/atividades'), {
|
|
headers: FETCH_HEADERS,
|
|
query: { pagina, tamanho },
|
|
})
|
|
},
|
|
|
|
// ─── Débitos / Extrato ───────────────────────────────────────────────────
|
|
getDebitosExtrato(params = {}) {
|
|
return $fetch(proxyUrl('/contribuinte/debitos'), {
|
|
headers: FETCH_HEADERS,
|
|
query: limparParams(params),
|
|
})
|
|
},
|
|
|
|
getTransacoes(idContaCorrente) {
|
|
return $fetch(proxyUrl(`/contribuinte/debitos/${idContaCorrente}/transacoes`), { headers: FETCH_HEADERS })
|
|
},
|
|
|
|
gerarGuiaDebitos(dto) {
|
|
return $fetch(proxyUrl('/contribuinte/debitos/gerar-guia'), {
|
|
method: 'POST',
|
|
headers: FETCH_HEADERS,
|
|
body: dto,
|
|
})
|
|
},
|
|
|
|
baixarGuiaPdf(idDoctoArr) {
|
|
return $fetch(proxyUrl(`/contribuinte/debitos/guia/${idDoctoArr}`), {
|
|
headers: FETCH_HEADERS,
|
|
responseType: 'arrayBuffer',
|
|
})
|
|
},
|
|
|
|
emitirGuia(idContaCorrente) {
|
|
return $fetch(proxyUrl(`/contribuinte/debitos/${idContaCorrente}/guia`), {
|
|
headers: FETCH_HEADERS,
|
|
responseType: 'arrayBuffer',
|
|
})
|
|
},
|
|
|
|
gerarExtratoDebitosPdf(dto) {
|
|
return $fetch(proxyUrl('/contribuinte/debitos/extrato-pdf'), {
|
|
method: 'POST',
|
|
headers: FETCH_HEADERS,
|
|
body: dto,
|
|
responseType: 'arrayBuffer',
|
|
})
|
|
},
|
|
|
|
// ─── Certidões ───────────────────────────────────────────────────────────
|
|
getCertidoes() {
|
|
return $fetch(proxyUrl('/contribuinte/certidoes'), { headers: FETCH_HEADERS })
|
|
},
|
|
|
|
reemitirCertidao(idCertidao) {
|
|
return $fetch(proxyUrl(`/contribuinte/certidoes/${idCertidao}/pdf`), {
|
|
headers: FETCH_HEADERS,
|
|
responseType: 'arrayBuffer',
|
|
})
|
|
},
|
|
|
|
// ─── Pagamentos / Extrato ─────────────────────────────────────────────────
|
|
getPagamentosExtrato(params = {}) {
|
|
return $fetch(proxyUrl('/contribuinte/pagamentos'), {
|
|
headers: FETCH_HEADERS,
|
|
query: limparParams(params),
|
|
})
|
|
},
|
|
|
|
gerarExtratoPagamentosPdf(dto) {
|
|
return $fetch(proxyUrl('/contribuinte/pagamentos/extrato-pdf'), {
|
|
method: 'POST',
|
|
headers: FETCH_HEADERS,
|
|
body: dto,
|
|
responseType: 'arrayBuffer',
|
|
})
|
|
},
|
|
|
|
getComprovante(idContaCorrente) {
|
|
return $fetch(proxyUrl(`/contribuinte/pagamentos/${idContaCorrente}/comprovante`), {
|
|
headers: FETCH_HEADERS,
|
|
responseType: 'arrayBuffer',
|
|
})
|
|
},
|
|
|
|
// ─── Guias emitidas ──────────────────────────────────────────────────────
|
|
listarGuias(params = {}) {
|
|
return $fetch(proxyUrl('/contribuinte/guias'), {
|
|
headers: FETCH_HEADERS,
|
|
query: limparParams(params),
|
|
})
|
|
},
|
|
|
|
buscarGuia(id) {
|
|
return $fetch(proxyUrl(`/contribuinte/guias/${id}`), { headers: FETCH_HEADERS })
|
|
},
|
|
|
|
baixarGuiaEmitidaPdf(id) {
|
|
return $fetch(proxyUrl(`/contribuinte/guias/${id}/pdf`), {
|
|
headers: FETCH_HEADERS,
|
|
responseType: 'arrayBuffer',
|
|
})
|
|
},
|
|
|
|
// ─── Dados cadastrais ────────────────────────────────────────────────────
|
|
getDadosCadastrais() {
|
|
return $fetch(proxyUrl('/contribuinte/dados'), { headers: FETCH_HEADERS })
|
|
},
|
|
|
|
atualizarContato(payload) {
|
|
return $fetch(proxyUrl('/contribuinte/dados/contato'), {
|
|
method: 'PUT',
|
|
headers: FETCH_HEADERS,
|
|
body: payload,
|
|
})
|
|
},
|
|
}
|