Al crear una proforma, devolver la proforma recuperandola completa del repositorio.
This commit is contained in:
parent
b286edd5c0
commit
32888fa7a4
@ -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,
|
||||
|
||||
@ -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,
|
||||
});
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user