feat: add period adjustment fields to point processing and PDF generation, enhancing data capture and display for time adjustments
This commit is contained in:
@@ -541,20 +541,48 @@ function gerarSecaoAjustesPDF(doc: jsPDF, yPosition: number, dias: DiaFichaPonto
|
||||
doc.setTextColor(0, 0, 0);
|
||||
yPosition += 10;
|
||||
|
||||
// Função auxiliar para formatar período do ajuste
|
||||
const formatarPeriodoAjuste = (ajuste: (typeof todosAjustes)[number]): string => {
|
||||
if (
|
||||
ajuste.dataInicio &&
|
||||
ajuste.horaInicio !== undefined &&
|
||||
ajuste.minutoInicio !== undefined &&
|
||||
ajuste.dataFim &&
|
||||
ajuste.horaFim !== undefined &&
|
||||
ajuste.minutoFim !== undefined
|
||||
) {
|
||||
const inicioStr = `${formatarDataDDMMAAAA(ajuste.dataInicio)} ${formatarHoraPonto(
|
||||
ajuste.horaInicio,
|
||||
ajuste.minutoInicio
|
||||
)}`;
|
||||
const fimStr = `${formatarDataDDMMAAAA(ajuste.dataFim)} ${formatarHoraPonto(
|
||||
ajuste.horaFim,
|
||||
ajuste.minutoFim
|
||||
)}`;
|
||||
return `${inicioStr} a ${fimStr}`;
|
||||
}
|
||||
// Fallback para ajustes antigos sem período
|
||||
return formatarDataDDMMAAAA(ajuste.data);
|
||||
};
|
||||
|
||||
const ajustesData = todosAjustes.map((ajuste) => [
|
||||
formatarDataDDMMAAAA(ajuste.data),
|
||||
ajuste.tipo === 'abonar' ? 'Abonar' : ajuste.tipo === 'descontar' ? 'Descontar' : 'Compensar',
|
||||
formatarMinutos(ajuste.valorMinutos),
|
||||
formatarPeriodoAjuste(ajuste),
|
||||
ajuste.motivoDescricao || '-'
|
||||
]);
|
||||
|
||||
autoTable(doc, {
|
||||
startY: yPosition,
|
||||
head: [['Data', 'Tipo', 'Valor', 'Motivo']],
|
||||
head: [['Data Aplicação', 'Tipo', 'Valor', 'Período', 'Motivo']],
|
||||
body: ajustesData,
|
||||
theme: 'grid',
|
||||
headStyles: { fillColor: [41, 128, 185], fontStyle: 'bold' },
|
||||
styles: { fontSize: 9 }
|
||||
styles: { fontSize: 9 },
|
||||
columnStyles: {
|
||||
3: { cellWidth: 'auto', minCellWidth: 60 } // Coluna de período com largura maior
|
||||
}
|
||||
});
|
||||
|
||||
type JsPDFWithAutoTable = jsPDF & {
|
||||
|
||||
@@ -598,7 +598,13 @@ export async function processarDadosFichaPonto(
|
||||
tipo: a.tipo,
|
||||
valorMinutos: a.valorMinutos,
|
||||
motivoDescricao: a.motivoDescricao,
|
||||
gestorId: a.gestorId
|
||||
gestorId: a.gestorId,
|
||||
dataInicio: a.dataInicio,
|
||||
horaInicio: a.horaInicio,
|
||||
minutoInicio: a.minutoInicio,
|
||||
dataFim: a.dataFim,
|
||||
horaFim: a.horaFim,
|
||||
minutoFim: a.minutoFim
|
||||
})),
|
||||
inconsistencias: inconsistenciasDia.map((i) => ({
|
||||
_id: i._id,
|
||||
|
||||
@@ -60,6 +60,13 @@ export interface DiaFichaPonto {
|
||||
valorMinutos: number;
|
||||
motivoDescricao?: string;
|
||||
gestorId?: Id<'usuarios'>;
|
||||
// Período do ajuste
|
||||
dataInicio?: string; // YYYY-MM-DD
|
||||
horaInicio?: number; // 0-23
|
||||
minutoInicio?: number; // 0-59
|
||||
dataFim?: string; // YYYY-MM-DD
|
||||
horaFim?: number; // 0-23
|
||||
minutoFim?: number; // 0-59
|
||||
}>;
|
||||
inconsistencias: Array<{
|
||||
_id: Id<'inconsistenciasBancoHoras'>;
|
||||
|
||||
@@ -264,6 +264,10 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Converter hora formato HH:mm para hora e minuto
|
||||
const { hora: horaInicio, minuto: minutoInicio } = timeParaHoraMinuto(horaInicioAjuste);
|
||||
const { hora: horaFim, minuto: minutoFim } = timeParaHoraMinuto(horaFimAjuste);
|
||||
|
||||
try {
|
||||
await client.mutation(api.pontos.ajustarBancoHoras, {
|
||||
funcionarioId: funcionarioSelecionado,
|
||||
@@ -271,6 +275,13 @@
|
||||
periodoDias: dias,
|
||||
periodoHoras: horas,
|
||||
periodoMinutos: minutos,
|
||||
dataAplicacao: dataInicioAjuste, // Data escolhida pelo usuário
|
||||
dataInicio: dataInicioAjuste,
|
||||
horaInicio,
|
||||
minutoInicio,
|
||||
dataFim: dataFimAjuste,
|
||||
horaFim,
|
||||
minutoFim,
|
||||
motivoId: motivoId || undefined,
|
||||
motivoTipo: motivoTipo || undefined,
|
||||
motivoDescricao: motivoDescricao || undefined,
|
||||
@@ -910,7 +921,11 @@
|
||||
{#each homologacoes as homologacao (homologacao._id)}
|
||||
<tr>
|
||||
<td>
|
||||
{new Date(homologacao.criadoEm).toLocaleDateString('pt-BR')}
|
||||
{#if homologacao.dataAplicacaoAjuste}
|
||||
{new Date(homologacao.dataAplicacaoAjuste + 'T00:00:00').toLocaleDateString('pt-BR')}
|
||||
{:else}
|
||||
{new Date(homologacao.criadoEm).toLocaleDateString('pt-BR')}
|
||||
{/if}
|
||||
</td>
|
||||
{#if !funcionarioSelecionado}
|
||||
<td>
|
||||
@@ -958,9 +973,16 @@
|
||||
</span>
|
||||
</div>
|
||||
{:else if homologacao.ajusteMinutos}
|
||||
<div class="text-sm">
|
||||
{homologacao.periodoDias || 0}d {homologacao.periodoHoras || 0}h
|
||||
{homologacao.periodoMinutos || 0}min
|
||||
<div class="text-sm space-y-1">
|
||||
<div>
|
||||
{homologacao.periodoDias || 0}d {homologacao.periodoHoras || 0}h
|
||||
{homologacao.periodoMinutos || 0}min
|
||||
</div>
|
||||
{#if homologacao.periodoAjuste?.dataInicio && homologacao.periodoAjuste?.horaInicio !== undefined && homologacao.periodoAjuste?.minutoInicio !== undefined && homologacao.periodoAjuste?.dataFim && homologacao.periodoAjuste?.horaFim !== undefined && homologacao.periodoAjuste?.minutoFim !== undefined}
|
||||
<div class="text-xs text-base-content/60">
|
||||
{new Date(homologacao.periodoAjuste.dataInicio + 'T00:00:00').toLocaleDateString('pt-BR')} {formatarHoraPonto(homologacao.periodoAjuste.horaInicio, homologacao.periodoAjuste.minutoInicio)} a {new Date(homologacao.periodoAjuste.dataFim + 'T00:00:00').toLocaleDateString('pt-BR')} {formatarHoraPonto(homologacao.periodoAjuste.horaFim, homologacao.periodoAjuste.minutoFim)}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</td>
|
||||
@@ -1026,13 +1048,18 @@
|
||||
<div class="grid grid-cols-2 gap-4 text-sm">
|
||||
<div>
|
||||
<span class="font-medium">Data: </span>
|
||||
{new Date(homologacaoSelecionada.criadoEm).toLocaleDateString('pt-BR', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
})}
|
||||
{#if homologacaoSelecionada.dataAplicacaoAjuste}
|
||||
{new Date(homologacaoSelecionada.dataAplicacaoAjuste + 'T00:00:00').toLocaleDateString('pt-BR')}
|
||||
<span class="text-base-content/60 text-xs"> (Aplicado em)</span>
|
||||
{:else}
|
||||
{new Date(homologacaoSelecionada.criadoEm).toLocaleDateString('pt-BR', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
})}
|
||||
{/if}
|
||||
</div>
|
||||
<div>
|
||||
<span class="font-medium">Funcionário:</span>
|
||||
@@ -1124,6 +1151,16 @@
|
||||
{homologacaoSelecionada.periodoHoras || 0}h
|
||||
{homologacaoSelecionada.periodoMinutos || 0}min
|
||||
</div>
|
||||
{#if homologacaoSelecionada.periodoAjuste?.dataInicio && homologacaoSelecionada.periodoAjuste?.horaInicio !== undefined && homologacaoSelecionada.periodoAjuste?.minutoInicio !== undefined && homologacaoSelecionada.periodoAjuste?.dataFim && homologacaoSelecionada.periodoAjuste?.horaFim !== undefined && homologacaoSelecionada.periodoAjuste?.minutoFim !== undefined}
|
||||
<div>
|
||||
<span class="font-medium">Data/Hora Início: </span>
|
||||
{new Date(homologacaoSelecionada.periodoAjuste.dataInicio + 'T00:00:00').toLocaleDateString('pt-BR')} {formatarHoraPonto(homologacaoSelecionada.periodoAjuste.horaInicio, homologacaoSelecionada.periodoAjuste.minutoInicio)}
|
||||
</div>
|
||||
<div>
|
||||
<span class="font-medium">Data/Hora Fim: </span>
|
||||
{new Date(homologacaoSelecionada.periodoAjuste.dataFim + 'T00:00:00').toLocaleDateString('pt-BR')} {formatarHoraPonto(homologacaoSelecionada.periodoAjuste.horaFim, homologacaoSelecionada.periodoAjuste.minutoFim)}
|
||||
</div>
|
||||
{/if}
|
||||
{#if homologacaoSelecionada.ajusteMinutos}
|
||||
<div>
|
||||
<span class="font-medium">Ajuste Total: </span>
|
||||
|
||||
Reference in New Issue
Block a user