2026-06-25 11:49:59 +00:00
|
|
|
import { type SetupParams, buildTransactionManager } from "@erp/core/api";
|
2026-05-04 18:33:24 +00:00
|
|
|
import type { IProformaPublicServices } from "@erp/customer-invoices/api";
|
|
|
|
|
import type { ICustomerPublicServices } from "@erp/customers/api";
|
2026-03-16 17:45:45 +00:00
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
buildCreateProformaFromFactugesUseCase,
|
|
|
|
|
buildFactugesInputMappers,
|
|
|
|
|
} from "../../application/di";
|
2026-06-25 11:49:59 +00:00
|
|
|
import { buildFactuGESCatalogResolvers } from "../../application/di/factuges-catalog-resolvers.di";
|
2026-05-05 18:37:29 +00:00
|
|
|
import { buildFactuGESFinder } from "../../application/di/factuges-finder.di";
|
|
|
|
|
import { buildFactuGESLinker } from "../../application/di/factuges-linker.di";
|
2026-06-25 11:49:59 +00:00
|
|
|
import { createFactuGESPaymentReferenceProvider } from "../../application/services/json-data";
|
2026-03-16 17:45:45 +00:00
|
|
|
import type { CreateProformaFromFactugesUseCase } from "../../application/use-cases";
|
|
|
|
|
|
2026-06-25 11:49:59 +00:00
|
|
|
import { resolveFactuGESCatalogsDeps } from "./factuges-catalog-deps.di";
|
2026-05-05 18:37:29 +00:00
|
|
|
import { buildFactuGESPersistenceMappers } from "./factuges-persistence-mappers.di";
|
|
|
|
|
import { buildFactugesRepository } from "./factuges-repositories.di";
|
|
|
|
|
|
2026-03-16 17:45:45 +00:00
|
|
|
export type FactugesInternalDeps = {
|
|
|
|
|
useCases: {
|
|
|
|
|
createProforma: (publicServices: {
|
2026-05-04 18:33:24 +00:00
|
|
|
customerServices: ICustomerPublicServices;
|
|
|
|
|
proformaServices: IProformaPublicServices;
|
2026-03-16 17:45:45 +00:00
|
|
|
}) => CreateProformaFromFactugesUseCase;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function buildFactugesDependencies(params: SetupParams): FactugesInternalDeps {
|
2026-08-24 21:43:00 +00:00
|
|
|
const { database, transactionContext } = params;
|
2026-03-16 17:45:45 +00:00
|
|
|
|
2026-06-25 11:49:59 +00:00
|
|
|
const catalogs = resolveFactuGESCatalogsDeps(params);
|
|
|
|
|
|
2026-03-16 17:45:45 +00:00
|
|
|
// Infrastructure
|
2026-08-24 21:43:00 +00:00
|
|
|
const transactionManager = buildTransactionManager(database, transactionContext);
|
2026-06-25 11:49:59 +00:00
|
|
|
const inputMappers = buildFactugesInputMappers();
|
2026-05-05 18:37:29 +00:00
|
|
|
const persistenceMappers = buildFactuGESPersistenceMappers();
|
|
|
|
|
|
|
|
|
|
const repository = buildFactugesRepository({ database, mappers: persistenceMappers });
|
2026-03-16 17:45:45 +00:00
|
|
|
|
2026-06-25 11:49:59 +00:00
|
|
|
const paymentReferenceProvider = createFactuGESPaymentReferenceProvider();
|
|
|
|
|
|
|
|
|
|
const catalogResolvers = buildFactuGESCatalogResolvers({
|
|
|
|
|
taxDefinitionFinder: catalogs.taxDefinition.finder,
|
|
|
|
|
taxRegimeFinder: catalogs.taxRegime.finder,
|
|
|
|
|
paymentMethodFinder: catalogs.paymentMethod.finder,
|
|
|
|
|
paymentTermFinder: catalogs.paymentTerm.finder,
|
|
|
|
|
paymentReferenceProvider: paymentReferenceProvider,
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-16 17:45:45 +00:00
|
|
|
// Application helpers
|
2026-05-05 18:37:29 +00:00
|
|
|
const finder = buildFactuGESFinder({ repository });
|
|
|
|
|
const linker = buildFactuGESLinker({ repository });
|
2026-03-16 17:45:45 +00:00
|
|
|
|
|
|
|
|
// Internal use cases (factories)
|
|
|
|
|
return {
|
|
|
|
|
useCases: {
|
2026-05-06 11:10:47 +00:00
|
|
|
createProforma: (publicServices: {
|
|
|
|
|
customerServices: ICustomerPublicServices;
|
|
|
|
|
proformaServices: IProformaPublicServices;
|
|
|
|
|
}) =>
|
2026-03-28 21:10:05 +00:00
|
|
|
buildCreateProformaFromFactugesUseCase({
|
2026-05-05 18:37:29 +00:00
|
|
|
linker,
|
|
|
|
|
finder,
|
2026-03-16 17:45:45 +00:00
|
|
|
dtoMapper: inputMappers.createInputMapper,
|
2026-06-25 11:49:59 +00:00
|
|
|
catalogResolvers: catalogResolvers,
|
2026-03-16 17:45:45 +00:00
|
|
|
publicServices,
|
|
|
|
|
transactionManager,
|
2026-03-28 21:10:05 +00:00
|
|
|
}),
|
2026-03-16 17:45:45 +00:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|