Ajustes final etapa1 #71

Merged
killer-cf merged 12 commits from ajustes_final_etapa1 into master 2025-12-29 17:28:52 +00:00
13 changed files with 833 additions and 193 deletions
Showing only changes of commit c6a52155ee - Show all commits

View File

@@ -2867,14 +2867,41 @@ export const excluirHomologacao = mutation({
throw new Error('Você não tem permissão para excluir esta homologação');
}
// Se a homologação estiver vinculada a um registro, remover a referência
// Se a homologação estiver vinculada a um registro, restaurar valores originais
if (homologacao.registroId) {
const registro = await ctx.db.get(homologacao.registroId);
if (registro && registro.homologacaoId === args.homologacaoId) {
await ctx.db.patch(homologacao.registroId, {
// Restaurar valores originais se existirem
const patchData: {
homologacaoId: undefined;
editadoPorGestor: boolean;
hora?: number;
minuto?: number;
} = {
homologacaoId: undefined,
editadoPorGestor: false
});
};
// Se a homologação tem valores anteriores, restaurar
if (
homologacao.horaAnterior !== undefined &&
homologacao.minutoAnterior !== undefined
) {
patchData.hora = homologacao.horaAnterior;
patchData.minuto = homologacao.minutoAnterior;
}
await ctx.db.patch(homologacao.registroId, patchData);
// Recalcular banco de horas após restaurar valores
const config = await ctx.db
.query('configuracaoPonto')
.withIndex('by_ativo', (q) => q.eq('ativo', true))
.first();
if (config) {
await atualizarBancoHoras(ctx, registro.funcionarioId, registro.data, config);
}
}
}