Al crear una proforma, devolver la proforma recuperandola completa del repositorio.

This commit is contained in:
David Arranz 2026-07-08 19:22:44 +02:00
parent b286edd5c0
commit 32888fa7a4
3 changed files with 22 additions and 4 deletions

View File

@ -98,6 +98,7 @@ export function buildPreviewProformaReportUseCase(deps: {
export function buildCreateProformaUseCase(deps: {
creator: IProformaCreator;
finder: IProformaFinder;
dtoMapper: ICreateProformaInputMapper;
fullReadModelAssembler: IProformaFullReadModelAssembler;
fullSnapshotBuilder: IProformaFullSnapshotBuilder;
@ -106,6 +107,7 @@ export function buildCreateProformaUseCase(deps: {
return new CreateProformaUseCase({
dtoMapper: deps.dtoMapper,
creator: deps.creator,
finder: deps.finder,
fullReadModelAssembler: deps.fullReadModelAssembler,
fullSnapshotBuilder: deps.fullSnapshotBuilder,
transactionManager: deps.transactionManager,

View File

@ -4,7 +4,11 @@ import { Result } from "@repo/rdx-utils";
import type { CreateProformaRequestDTO } from "../../../../common";
import type { ICreateProformaInputMapper } from "../mappers";
import type { IProformaCreator, IProformaFullReadModelAssembler } from "../services";
import type {
IProformaCreator,
IProformaFinder,
IProformaFullReadModelAssembler,
} from "../services";
import type { IProformaFullSnapshotBuilder } from "../snapshot-builders";
type CreateProformaUseCaseInput = {
@ -17,6 +21,7 @@ export class CreateProformaUseCase {
private readonly deps: {
dtoMapper: ICreateProformaInputMapper;
creator: IProformaCreator;
finder: IProformaFinder;
fullReadModelAssembler: IProformaFullReadModelAssembler;
fullSnapshotBuilder: IProformaFullSnapshotBuilder;
transactionManager: ITransactionManager;
@ -42,9 +47,19 @@ export class CreateProformaUseCase {
return Result.fail(createResult.error);
}
const proformaResult = await this.deps.finder.findProformaById(
companyId,
createResult.data.id,
transaction
);
if (proformaResult.isFailure) {
return Result.fail(proformaResult.error);
}
const readModelResult = await this.deps.fullReadModelAssembler.assemble({
companyId,
proforma: createResult.data,
proforma: proformaResult.data,
transaction,
});

View File

@ -1,6 +1,6 @@
import { type ModuleParams, buildTransactionManager } from "@erp/core/api";
import type { ICompanyPublicServices } from "../../../../../../companies/src/api";
import type { ICompanyPublicServices } from "../../../../../../companies/src/api";
import {
type ChangeStatusProformaUseCase,
type CreateProformaUseCase,
@ -31,8 +31,8 @@ import {
buildReportProformaPdfUseCase,
buildUpdateProformaUseCase,
} from "../../../application";
import { CompanyReportProfileFinder } from "../adapters/company-report-profile-finder";
import { buildProformaDocumentServices } from "./proforma-documents.di";
import { buildProformaNumberGenerator } from "./proforma-number-generator.di";
import { buildProformaPersistenceMappers } from "./proforma-persistence-mappers.di";
@ -144,6 +144,7 @@ export function buildProformasDependencies(params: ModuleParams): ProformasInter
createProforma: () =>
buildCreateProformaUseCase({
creator,
finder,
dtoMapper: inputMappers.createInputMapper,
fullReadModelAssembler: readModelAssemblers.full,
fullSnapshotBuilder: snapshotBuilders.full,