developer #4
@ -36,17 +36,33 @@ export function useExtratoDebitosPortal() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
function formatPeriodoRef(date) {
|
||||||
|
if (!date) return '-'
|
||||||
|
const d = new Date(date)
|
||||||
|
if (isNaN(d.getTime())) return '-'
|
||||||
|
return `${String(d.getMonth() + 1).padStart(2, '0')}/${d.getFullYear()}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function labelEstadoConta(codigo) {
|
||||||
|
if (codigo === null || codigo === undefined) return 'Todos'
|
||||||
|
const opt = opcoesEstadoConta.find(o => o.value === Number(codigo))
|
||||||
|
return opt?.label ?? 'Todos'
|
||||||
|
}
|
||||||
|
|
||||||
const totalizadores = computed(() => {
|
const totalizadores = computed(() => {
|
||||||
let principal = 0, multa = 0, juros = 0, valorTotal = 0
|
let lancado = 0, atualizado = 0, multa = 0, juros = 0, desconto = 0, valorTotal = 0
|
||||||
resultados.value.forEach(t => {
|
resultados.value.forEach(t => {
|
||||||
t.selecionados?.forEach(d => {
|
const lista = t.selecionados?.length > 0 ? t.selecionados : t.debitos || []
|
||||||
principal += d.valorAtulPrincipal ?? d.valorPrincipal ?? 0
|
lista.forEach(d => {
|
||||||
|
lancado += d.valorPrincipal ?? 0
|
||||||
|
atualizado += d.valorAtulPrincipal ?? d.valorPrincipal ?? 0
|
||||||
multa += d.valorAtulMulta ?? d.valorMulta ?? 0
|
multa += d.valorAtulMulta ?? d.valorMulta ?? 0
|
||||||
juros += d.valorAtulJuros ?? d.valorJuros ?? 0
|
juros += d.valorAtulJuros ?? d.valorJuros ?? 0
|
||||||
|
desconto += d.valorAtulCorrecao ?? d.valorCorrecao ?? 0
|
||||||
valorTotal += d.valorTotal ?? 0
|
valorTotal += d.valorTotal ?? 0
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return { principal, multa, juros, valorTotal }
|
return { lancado, atualizado, multa, juros, desconto, valorTotal }
|
||||||
})
|
})
|
||||||
|
|
||||||
function mapearDebitos(dados) {
|
function mapearDebitos(dados) {
|
||||||
@ -115,19 +131,61 @@ export function useExtratoDebitosPortal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function montarDtoExtrato(usarSelecionados) {
|
function montarDtoExtrato(usarSelecionados) {
|
||||||
|
const lista = resultados.value.filter(t =>
|
||||||
|
usarSelecionados ? t.selecionados?.length > 0 : t.debitos?.length > 0
|
||||||
|
)
|
||||||
|
const params = montarParametrosTributoConta(lista)
|
||||||
return {
|
return {
|
||||||
listaDebitos: resultados.value
|
listaDebitos: lista.map(t => ({
|
||||||
.filter(t => (usarSelecionados ? t.selecionados?.length > 0 : t.debitos?.length > 0))
|
idTributo: t.idTributo,
|
||||||
.map(t => ({
|
identificador: t.identificador,
|
||||||
idTributo: t.idTributo,
|
descricaoTributo: t.descricaoTributo,
|
||||||
identificador: t.identificador,
|
siglaTributo: t.siglaTributo,
|
||||||
descricaoTributo: t.descricaoTributo,
|
descricaoContaTributo: t.descricaoContaTributo,
|
||||||
siglaTributo: t.siglaTributo,
|
idContaTributo: t.idContaTributo,
|
||||||
descricaoContaTributo: t.descricaoContaTributo,
|
totalPagamentos: t.totalPagamentos,
|
||||||
idContaTributo: t.idContaTributo,
|
debitos: (usarSelecionados ? t.selecionados : t.debitos).map(mapDebitoPayload),
|
||||||
totalPagamentos: t.totalPagamentos,
|
})),
|
||||||
debitos: (usarSelecionados ? t.selecionados : t.debitos).map(mapDebitoPayload),
|
codTributo: params.codTributo,
|
||||||
})),
|
descricaoTributo: params.descricaoTributo,
|
||||||
|
codContaTributo: params.codContaTributo,
|
||||||
|
descricaoContaTributo: params.descricaoContaTributo,
|
||||||
|
periodoInicio: formatPeriodoRef(filtro.value.periodoIni),
|
||||||
|
periodoFim: formatPeriodoRef(filtro.value.periodoFim),
|
||||||
|
inscricaoMunicipal: '-',
|
||||||
|
estadoConta: labelEstadoConta(filtro.value.estadoConta),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function montarParametrosTributoConta(lista) {
|
||||||
|
if (!lista?.length) {
|
||||||
|
return {
|
||||||
|
codTributo: '-',
|
||||||
|
descricaoTributo: '-',
|
||||||
|
codContaTributo: '-',
|
||||||
|
descricaoContaTributo: '-',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const chaves = new Map()
|
||||||
|
for (const item of lista) {
|
||||||
|
const key = `${item.idTributo ?? ''}_${item.idContaTributo ?? ''}`
|
||||||
|
if (!chaves.has(key)) chaves.set(key, item)
|
||||||
|
}
|
||||||
|
if (chaves.size === 1) {
|
||||||
|
const t = [...chaves.values()][0]
|
||||||
|
return {
|
||||||
|
codTributo: t.idTributo != null ? String(t.idTributo) : (t.identificador ?? '-'),
|
||||||
|
descricaoTributo: t.descricaoTributo || '-',
|
||||||
|
codContaTributo: t.idContaTributo != null ? String(t.idContaTributo) : '-',
|
||||||
|
descricaoContaTributo: t.descricaoContaTributo || '-',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const tributos = [...new Set(lista.map(t => t.descricaoTributo).filter(Boolean))]
|
||||||
|
return {
|
||||||
|
codTributo: 'Diversos',
|
||||||
|
descricaoTributo: tributos.length ? tributos.join(', ') : 'Diversos tributos',
|
||||||
|
codContaTributo: '-',
|
||||||
|
descricaoContaTributo: '-',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -124,14 +124,20 @@ function getSegundoNome(texto) {
|
|||||||
<Column field="dataVencimento" header="Vencimento" style="min-width: 95px">
|
<Column field="dataVencimento" header="Vencimento" style="min-width: 95px">
|
||||||
<template #body="{ data }">{{ formatDate(data.dataVencimento) }}</template>
|
<template #body="{ data }">{{ formatDate(data.dataVencimento) }}</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="valorPrincipal" header="Principal" body-class="text-right" style="min-width: 100px">
|
<Column field="valorPrincipal" header="Lançado" body-class="text-right" style="min-width: 100px">
|
||||||
<template #body="{ data }">{{ formatCurrency(data.valorPrincipal) }}</template>
|
<template #body="{ data }">{{ formatCurrency(data.valorPrincipal) }}</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="valorMulta" header="Multa" body-class="text-right" style="min-width: 90px">
|
<Column field="valorAtulPrincipal" header="Atualizado" body-class="text-right" style="min-width: 100px">
|
||||||
<template #body="{ data }">{{ formatCurrency(data.valorMulta) }}</template>
|
<template #body="{ data }">{{ formatCurrency(data.valorAtulPrincipal) }}</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="valorJuros" header="Juros" body-class="text-right" style="min-width: 90px">
|
<Column field="valorAtulMulta" header="Multa" body-class="text-right" style="min-width: 90px">
|
||||||
<template #body="{ data }">{{ formatCurrency(data.valorJuros) }}</template>
|
<template #body="{ data }">{{ formatCurrency(data.valorAtulMulta) }}</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="valorAtulJuros" header="Juros" body-class="text-right" style="min-width: 90px">
|
||||||
|
<template #body="{ data }">{{ formatCurrency(data.valorAtulJuros) }}</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="valorAtulCorrecao" header="Desconto" body-class="text-right" style="min-width: 90px">
|
||||||
|
<template #body="{ data }">{{ formatCurrency(data.valorAtulCorrecao) }}</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="valorTotal" header="Total" body-class="text-right" style="min-width: 100px">
|
<Column field="valorTotal" header="Total" body-class="text-right" style="min-width: 100px">
|
||||||
<template #body="{ data }">
|
<template #body="{ data }">
|
||||||
@ -168,10 +174,14 @@ function getSegundoNome(texto) {
|
|||||||
/>
|
/>
|
||||||
<p v-if="erros.dataVencimento" class="text-xs text-red-500 mt-1">{{ erros.dataVencimento }}</p>
|
<p v-if="erros.dataVencimento" class="text-xs text-red-500 mt-1">{{ erros.dataVencimento }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="sm:col-span-3 grid grid-cols-2 sm:grid-cols-4 gap-3 items-end">
|
<div class="sm:col-span-3 grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3 items-end">
|
||||||
<div>
|
<div>
|
||||||
<p class="text-xs text-slate-500">Principal</p>
|
<p class="text-xs text-slate-500">Lançado</p>
|
||||||
<p class="font-bold">{{ formatCurrency(totalizadores.principal) }}</p>
|
<p class="font-bold">{{ formatCurrency(totalizadores.lancado) }}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="text-xs text-slate-500">Atualizado</p>
|
||||||
|
<p class="font-bold">{{ formatCurrency(totalizadores.atualizado) }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p class="text-xs text-slate-500">Multa</p>
|
<p class="text-xs text-slate-500">Multa</p>
|
||||||
@ -181,6 +191,10 @@ function getSegundoNome(texto) {
|
|||||||
<p class="text-xs text-slate-500">Juros</p>
|
<p class="text-xs text-slate-500">Juros</p>
|
||||||
<p class="font-bold">{{ formatCurrency(totalizadores.juros) }}</p>
|
<p class="font-bold">{{ formatCurrency(totalizadores.juros) }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="text-xs text-slate-500">Desconto</p>
|
||||||
|
<p class="font-bold">{{ formatCurrency(totalizadores.desconto) }}</p>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p class="text-xs text-slate-500">Total a Pagar</p>
|
<p class="text-xs text-slate-500">Total a Pagar</p>
|
||||||
<p class="font-bold text-primary">{{ formatCurrency(totalizadores.valorTotal) }}</p>
|
<p class="font-bold text-primary">{{ formatCurrency(totalizadores.valorTotal) }}</p>
|
||||||
|
|||||||
@ -87,7 +87,7 @@ async function emitirComprovante(pag) {
|
|||||||
<AccordionPanel v-for="(t, index) in tributos" :key="t.idContaTributo ?? index" :value="String(index)">
|
<AccordionPanel v-for="(t, index) in tributos" :key="t.idContaTributo ?? index" :value="String(index)">
|
||||||
<AccordionHeader>
|
<AccordionHeader>
|
||||||
<span class="text-sm font-semibold truncate">
|
<span class="text-sm font-semibold truncate">
|
||||||
{{ t.descricaoTributo }} — {{ t.descricaoContaTributo }}
|
Conta {{ t.idContaTributo }} — {{ t.descricaoContaTributo || '-' }} / {{ t.descricaoTributo }}
|
||||||
({{ t.pagamentos?.length ?? 0 }} pagamentos)
|
({{ t.pagamentos?.length ?? 0 }} pagamentos)
|
||||||
</span>
|
</span>
|
||||||
</AccordionHeader>
|
</AccordionHeader>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user