UDT-011: Localización Temporal Argentina (infra transversal) #25
@@ -2,6 +2,7 @@
|
|||||||
// Modal de edición / creación de TipoDeIva
|
// Modal de edición / creación de TipoDeIva
|
||||||
// CRÍTICO: NO incluye campo Porcentaje (inmutable, cambiar via NuevaVersion)
|
// CRÍTICO: NO incluye campo Porcentaje (inmutable, cambiar via NuevaVersion)
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
|
import { todayArgentina } from '@/lib/dateFormat'
|
||||||
import { useForm } from 'react-hook-form'
|
import { useForm } from 'react-hook-form'
|
||||||
import { zodResolver } from '@hookform/resolvers/zod'
|
import { zodResolver } from '@hookform/resolvers/zod'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
@@ -98,7 +99,7 @@ export function TipoDeIvaFormModal({
|
|||||||
aplicaIVA: true,
|
aplicaIVA: true,
|
||||||
activo: true,
|
activo: true,
|
||||||
porcentajeCreate: undefined,
|
porcentajeCreate: undefined,
|
||||||
vigenciaDesde: '',
|
vigenciaDesde: todayArgentina(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -119,7 +120,7 @@ export function TipoDeIvaFormModal({
|
|||||||
aplicaIVA: true,
|
aplicaIVA: true,
|
||||||
activo: true,
|
activo: true,
|
||||||
porcentajeCreate: undefined,
|
porcentajeCreate: undefined,
|
||||||
vigenciaDesde: '',
|
vigenciaDesde: todayArgentina(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
createMutation.reset()
|
createMutation.reset()
|
||||||
@@ -158,7 +159,7 @@ export function TipoDeIvaFormModal({
|
|||||||
codigo: values.codigo,
|
codigo: values.codigo,
|
||||||
descripcion: values.descripcion,
|
descripcion: values.descripcion,
|
||||||
porcentaje: values.porcentajeCreate,
|
porcentaje: values.porcentajeCreate,
|
||||||
vigenciaDesde: values.vigenciaDesde ?? new Date().toISOString().slice(0, 10),
|
vigenciaDesde: values.vigenciaDesde ?? todayArgentina(),
|
||||||
aplicaIVA: values.aplicaIVA,
|
aplicaIVA: values.aplicaIVA,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// T600.5 — TDD: TipoDeIvaFormModal
|
// T600.5 — TDD: TipoDeIvaFormModal
|
||||||
// CRÍTICO: verifica que el modal de Editar NO tiene campo Porcentaje [REQ-UI-003]
|
// CRÍTICO: verifica que el modal de Editar NO tiene campo Porcentaje [REQ-UI-003]
|
||||||
|
// T600.10 — BUG-FE-03 regression: default vigenciaDesde usa todayArgentina (no UTC)
|
||||||
import { describe, it, expect, beforeAll, afterAll, afterEach, vi } from 'vitest'
|
import { describe, it, expect, beforeAll, afterAll, afterEach, vi } from 'vitest'
|
||||||
import { render, screen, waitFor } from '@testing-library/react'
|
import { render, screen, waitFor } from '@testing-library/react'
|
||||||
import userEvent from '@testing-library/user-event'
|
import userEvent from '@testing-library/user-event'
|
||||||
@@ -131,3 +132,21 @@ describe('TipoDeIvaFormModal — validación', () => {
|
|||||||
expect(onClose).toHaveBeenCalledTimes(1)
|
expect(onClose).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('TipoDeIvaFormModal — BUG-FE-03 regression: vigenciaDesde usa todayArgentina', () => {
|
||||||
|
// A las 22:30 ART del 30/04, UTC ya es 01:30 del 01/05.
|
||||||
|
// new Date().toISOString().slice(0,10) devolvería "2026-05-01" (UTC) — INCORRECTO.
|
||||||
|
// todayArgentina() debe devolver "2026-04-30" — CORRECTO.
|
||||||
|
it('modo create: campo vigenciaDesde refleja fecha ART, no UTC, a las 22:30 ART del 30/04', () => {
|
||||||
|
vi.useFakeTimers()
|
||||||
|
vi.setSystemTime(new Date('2026-05-01T01:30:00.000Z')) // 22:30 ART del 30/04
|
||||||
|
|
||||||
|
renderModal({ item: null })
|
||||||
|
|
||||||
|
const vigenciaInput = screen.getByLabelText(/vigencia desde/i) as HTMLInputElement
|
||||||
|
// El input debe tener value="2026-04-30" (fecha ART), no "2026-05-01" (UTC)
|
||||||
|
expect(vigenciaInput.value).toBe('2026-04-30')
|
||||||
|
|
||||||
|
vi.useRealTimers()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user