From e7a6fb02422e5e24e296eeb4331f8c91a87f511e Mon Sep 17 00:00:00 2001 From: david Date: Wed, 15 Jul 2026 18:53:09 +0200 Subject: [PATCH] Enhance proforma creation and update processes by verifying saved data integrity --- .../application/proformas/services/proforma-creator.ts | 9 ++++++++- .../application/proformas/services/proforma-updater.ts | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/customer-invoices/src/api/application/proformas/services/proforma-creator.ts b/modules/customer-invoices/src/api/application/proformas/services/proforma-creator.ts index 4fe72ee2..fdc37dfa 100644 --- a/modules/customer-invoices/src/api/application/proformas/services/proforma-creator.ts +++ b/modules/customer-invoices/src/api/application/proformas/services/proforma-creator.ts @@ -76,7 +76,14 @@ export class ProformaCreator implements IProformaCreator { return Result.fail(saveResult.error); } - return Result.ok(proforma); + // 4. Verificar creación + const verifyResult = await this.deps.repository.getByIdInCompany(companyId, id, transaction); + + if (verifyResult.isFailure) { + return Result.fail(verifyResult.error); + } + + return Result.ok(verifyResult.data); } private async resolveCreateProps( diff --git a/modules/customer-invoices/src/api/application/proformas/services/proforma-updater.ts b/modules/customer-invoices/src/api/application/proformas/services/proforma-updater.ts index 85786624..a59ea16a 100644 --- a/modules/customer-invoices/src/api/application/proformas/services/proforma-updater.ts +++ b/modules/customer-invoices/src/api/application/proformas/services/proforma-updater.ts @@ -67,7 +67,14 @@ export class ProformaUpdater implements IProformaUpdater { return Result.fail(saveResult.error); } - return Result.ok(proforma); + // Volvemos a recuperar lo guardado para asegurarnos de que los cambios se reflejen correctamente + const verifyResult = await this.deps.repository.getByIdInCompany(companyId, id, transaction); + + if (verifyResult.isFailure) { + return Result.fail(verifyResult.error); + } + + return Result.ok(verifyResult.data); } private async resolvePatchProps(params: {