From 5db5de65ad2a44e06c997b6b4d3a053d85937dbd Mon Sep 17 00:00:00 2001 From: George Date: Tue, 20 Oct 2026 08:19:55 -0500 Subject: [PATCH] fix(web): las fechas con hora que trae SAP se ven en los campos de fecha de los maestros Co-Authored-By: Claude Sonnet 5.5 --- .../web/src/app/features/masters/lotes/lotes.spec.ts | 12 +++++++++--- apps/web/src/app/features/masters/master-field.ts | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/web/src/app/features/masters/lotes/lotes.spec.ts b/apps/web/src/app/features/masters/lotes/lotes.spec.ts index c17a570..5da3dc7 100644 --- a/apps/web/src/app/features/masters/lotes/lotes.spec.ts +++ b/apps/web/src/app/features/masters/lotes/lotes.spec.ts @@ -17,9 +17,9 @@ const lote = (over: Record = {}) => ({ Status: 'bdsStatus_Released', BatchAttribute1: 'PROV-1', BatchAttribute2: null, - AdmissionDate: '2026-01-05', - ManufacturingDate: '2025-12-01', - ExpirationDate: '2028-12-01', + AdmissionDate: '2026-01-05T00:00:00Z', + ManufacturingDate: '2025-12-01T00:00:00Z', + ExpirationDate: '2028-12-01T00:00:00Z', Details: null, ...over, }); @@ -73,6 +73,12 @@ describe('Lotes (BatchNumberDetails)', () => { expect([...el().querySelectorAll('[role=tab]')].map((t) => t.textContent?.trim())).toEqual(['General', 'Detalles']); }); + it('las fechas que trae SAP con hora se ven en el selector de fecha', async () => { + await open('74701', lote()); + const dates = [...el().querySelectorAll('input[type=date]')].map((i) => i.value); + expect(dates).toEqual(['2026-01-05', '2025-12-01', '2028-12-01']); + }); + it('un lote bloqueado se ve como tal', async () => { await open('74701', lote({ Status: 'bdsStatus_Locked' })); expect(el().querySelector('.badge.tone-warn')?.textContent?.trim()).toBe('Bloqueado'); diff --git a/apps/web/src/app/features/masters/master-field.ts b/apps/web/src/app/features/masters/master-field.ts index 3bfe672..dd5cba7 100644 --- a/apps/web/src/app/features/masters/master-field.ts +++ b/apps/web/src/app/features/masters/master-field.ts @@ -101,7 +101,8 @@ export class MasterField { const f = this.field(); return f.type === 'lookup' && f.lookup.valueType === 'number' && /^\d+$/.test(code.trim()) ? Number(code) : code; } - protected readonly str = computed(() => text(this.value())); + /** El texto del campo; una fecha de SAP llega como `2031-10-31T00:00:00Z` y el selector de fecha pide `yyyy-MM-dd`. */ + protected readonly str = computed(() => (this.field().type === 'date' ? text(this.value()).slice(0, 10) : text(this.value()))); protected readonly num = computed(() => (this.value() === '' || this.value() === null || this.value() === undefined ? null : Number(this.value()))); protected readonly required = computed(() => { const f = this.field();