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: {
|
export function buildCreateProformaUseCase(deps: {
|
||||||
creator: IProformaCreator;
|
creator: IProformaCreator;
|
||||||
|
finder: IProformaFinder;
|
||||||
dtoMapper: ICreateProformaInputMapper;
|
dtoMapper: ICreateProformaInputMapper;
|
||||||
fullReadModelAssembler: IProformaFullReadModelAssembler;
|
fullReadModelAssembler: IProformaFullReadModelAssembler;
|
||||||
fullSnapshotBuilder: IProformaFullSnapshotBuilder;
|
fullSnapshotBuilder: IProformaFullSnapshotBuilder;
|
||||||
@ -106,6 +107,7 @@ export function buildCreateProformaUseCase(deps: {
|
|||||||
return new CreateProformaUseCase({
|
return new CreateProformaUseCase({
|
||||||
dtoMapper: deps.dtoMapper,
|
dtoMapper: deps.dtoMapper,
|
||||||
creator: deps.creator,
|
creator: deps.creator,
|
||||||
|
finder: deps.finder,
|
||||||
fullReadModelAssembler: deps.fullReadModelAssembler,
|
fullReadModelAssembler: deps.fullReadModelAssembler,
|
||||||
fullSnapshotBuilder: deps.fullSnapshotBuilder,
|
fullSnapshotBuilder: deps.fullSnapshotBuilder,
|
||||||
transactionManager: deps.transactionManager,
|
transactionManager: deps.transactionManager,
|
||||||
|
|||||||
@ -4,7 +4,11 @@ import { Result } from "@repo/rdx-utils";
|
|||||||
|
|
||||||
import type { CreateProformaRequestDTO } from "../../../../common";
|
import type { CreateProformaRequestDTO } from "../../../../common";
|
||||||
import type { ICreateProformaInputMapper } from "../mappers";
|
import type { ICreateProformaInputMapper } from "../mappers";
|
||||||
import type { IProformaCreator, IProformaFullReadModelAssembler } from "../services";
|
import type {
|
||||||
|
IProformaCreator,
|
||||||
|
IProformaFinder,
|
||||||
|
IProformaFullReadModelAssembler,
|
||||||
|
} from "../services";
|
||||||
import type { IProformaFullSnapshotBuilder } from "../snapshot-builders";
|
import type { IProformaFullSnapshotBuilder } from "../snapshot-builders";
|
||||||
|
|
||||||
type CreateProformaUseCaseInput = {
|
type CreateProformaUseCaseInput = {
|
||||||
@ -17,6 +21,7 @@ export class CreateProformaUseCase {
|
|||||||
private readonly deps: {
|
private readonly deps: {
|
||||||
dtoMapper: ICreateProformaInputMapper;
|
dtoMapper: ICreateProformaInputMapper;
|
||||||
creator: IProformaCreator;
|
creator: IProformaCreator;
|
||||||
|
finder: IProformaFinder;
|
||||||
fullReadModelAssembler: IProformaFullReadModelAssembler;
|
fullReadModelAssembler: IProformaFullReadModelAssembler;
|
||||||
fullSnapshotBuilder: IProformaFullSnapshotBuilder;
|
fullSnapshotBuilder: IProformaFullSnapshotBuilder;
|
||||||
transactionManager: ITransactionManager;
|
transactionManager: ITransactionManager;
|
||||||
@ -42,9 +47,19 @@ export class CreateProformaUseCase {
|
|||||||
return Result.fail(createResult.error);
|
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({
|
const readModelResult = await this.deps.fullReadModelAssembler.assemble({
|
||||||
companyId,
|
companyId,
|
||||||
proforma: createResult.data,
|
proforma: proformaResult.data,
|
||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { type ModuleParams, buildTransactionManager } from "@erp/core/api";
|
import { type ModuleParams, buildTransactionManager } from "@erp/core/api";
|
||||||
import type { ICompanyPublicServices } from "../../../../../../companies/src/api";
|
|
||||||
|
|
||||||
|
import type { ICompanyPublicServices } from "../../../../../../companies/src/api";
|
||||||
import {
|
import {
|
||||||
type ChangeStatusProformaUseCase,
|
type ChangeStatusProformaUseCase,
|
||||||
type CreateProformaUseCase,
|
type CreateProformaUseCase,
|
||||||
@ -31,8 +31,8 @@ import {
|
|||||||
buildReportProformaPdfUseCase,
|
buildReportProformaPdfUseCase,
|
||||||
buildUpdateProformaUseCase,
|
buildUpdateProformaUseCase,
|
||||||
} from "../../../application";
|
} from "../../../application";
|
||||||
|
|
||||||
import { CompanyReportProfileFinder } from "../adapters/company-report-profile-finder";
|
import { CompanyReportProfileFinder } from "../adapters/company-report-profile-finder";
|
||||||
|
|
||||||
import { buildProformaDocumentServices } from "./proforma-documents.di";
|
import { buildProformaDocumentServices } from "./proforma-documents.di";
|
||||||
import { buildProformaNumberGenerator } from "./proforma-number-generator.di";
|
import { buildProformaNumberGenerator } from "./proforma-number-generator.di";
|
||||||
import { buildProformaPersistenceMappers } from "./proforma-persistence-mappers.di";
|
import { buildProformaPersistenceMappers } from "./proforma-persistence-mappers.di";
|
||||||
@ -144,6 +144,7 @@ export function buildProformasDependencies(params: ModuleParams): ProformasInter
|
|||||||
createProforma: () =>
|
createProforma: () =>
|
||||||
buildCreateProformaUseCase({
|
buildCreateProformaUseCase({
|
||||||
creator,
|
creator,
|
||||||
|
finder,
|
||||||
dtoMapper: inputMappers.createInputMapper,
|
dtoMapper: inputMappers.createInputMapper,
|
||||||
fullReadModelAssembler: readModelAssemblers.full,
|
fullReadModelAssembler: readModelAssemblers.full,
|
||||||
fullSnapshotBuilder: snapshotBuilders.full,
|
fullSnapshotBuilder: snapshotBuilders.full,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user