diff --git a/apps/server/package.json b/apps/server/package.json index b142122a..17bdeca3 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -1,6 +1,6 @@ { "name": "@erp/factuges-server", - "version": "0.0.12", + "version": "0.0.13", "private": true, "scripts": { "build": "tsup src/index.ts --config tsup.config.ts", diff --git a/apps/server/src/config/index.ts b/apps/server/src/config/index.ts index e9923651..298eacd5 100644 --- a/apps/server/src/config/index.ts +++ b/apps/server/src/config/index.ts @@ -1,4 +1,5 @@ import dotenv from "dotenv"; + import { asBoolean, asNumber, required } from "./config-helpers"; // Carga de variables de entorno (.env). Si ya están en el entorno, no se sobreescriben. diff --git a/apps/web/package.json b/apps/web/package.json index a44bf312..af791688 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -1,7 +1,7 @@ { "name": "@erp/factuges-web", "private": true, - "version": "0.0.12", + "version": "0.0.13", "type": "module", "scripts": { "dev": "vite --host --clearScreen false", diff --git a/modules/auth/package.json b/modules/auth/package.json index ee2aa2b3..26cf2ae1 100644 --- a/modules/auth/package.json +++ b/modules/auth/package.json @@ -1,6 +1,6 @@ { "name": "@erp/auth", - "version": "0.0.12", + "version": "0.0.13", "private": true, "type": "module", "sideEffects": false, diff --git a/modules/core/package.json b/modules/core/package.json index 2e3a73a3..a90b34f7 100644 --- a/modules/core/package.json +++ b/modules/core/package.json @@ -1,6 +1,6 @@ { "name": "@erp/core", - "version": "0.0.12", + "version": "0.0.13", "private": true, "type": "module", "sideEffects": false, diff --git a/modules/customer-invoices/package.json b/modules/customer-invoices/package.json index b7b296d7..73572492 100644 --- a/modules/customer-invoices/package.json +++ b/modules/customer-invoices/package.json @@ -1,6 +1,6 @@ { "name": "@erp/customer-invoices", - "version": "0.0.12", + "version": "0.0.13", "private": true, "type": "module", "sideEffects": false, diff --git a/modules/customer-invoices/src/api/application/use-cases/issue-invoices/index.ts b/modules/customer-invoices/src/api/application/use-cases/issue-invoices/index.ts index 159e84e8..5b88288d 100644 --- a/modules/customer-invoices/src/api/application/use-cases/issue-invoices/index.ts +++ b/modules/customer-invoices/src/api/application/use-cases/issue-invoices/index.ts @@ -1,2 +1,3 @@ export * from "./get-issue-invoice.use-case"; +export * from "./list-issue-invoices.use-case"; export * from "./report-issue-invoice.use-case"; diff --git a/modules/customer-invoices/src/api/application/use-cases/issue-invoices/list-issue-invoices.use-case.ts b/modules/customer-invoices/src/api/application/use-cases/issue-invoices/list-issue-invoices.use-case.ts new file mode 100644 index 00000000..45be42aa --- /dev/null +++ b/modules/customer-invoices/src/api/application/use-cases/issue-invoices/list-issue-invoices.use-case.ts @@ -0,0 +1,56 @@ +import type { IPresenterRegistry, ITransactionManager } from "@erp/core/api"; +import type { Criteria } from "@repo/rdx-criteria/server"; +import type { UniqueID } from "@repo/rdx-ddd"; +import { Result } from "@repo/rdx-utils"; +import type { Transaction } from "sequelize"; + +import type { ListIssueInvoicesResponseDTO } from "../../../../common/dto"; +import type { ListCustomerInvoicesPresenter } from "../../presenters"; +import type { CustomerInvoiceApplicationService } from "../../services"; + +type ListIssueInvoicesUseCaseInput = { + companyId: UniqueID; + criteria: Criteria; +}; + +export class ListIssueInvoicesUseCase { + constructor( + private readonly service: CustomerInvoiceApplicationService, + private readonly transactionManager: ITransactionManager, + private readonly presenterRegistry: IPresenterRegistry + ) {} + + public execute( + params: ListIssueInvoicesUseCaseInput + ): Promise> { + const { criteria, companyId } = params; + const presenter = this.presenterRegistry.getPresenter({ + resource: "customer-invoice", + projection: "LIST", + }) as ListCustomerInvoicesPresenter; + + return this.transactionManager.complete(async (transaction: Transaction) => { + try { + const result = await this.service.findIssueInvoiceByCriteriaInCompany( + companyId, + criteria, + transaction + ); + + if (result.isFailure) { + return Result.fail(result.error); + } + + const invoices = result.data; + const dto = presenter.toOutput({ + customerInvoices: invoices, + criteria, + }); + + return Result.ok(dto); + } catch (error: unknown) { + return Result.fail(error as Error); + } + }); + } +} diff --git a/modules/customer-invoices/src/api/application/use-cases/proformas/list-proformas.use-case.ts b/modules/customer-invoices/src/api/application/use-cases/proformas/list-proformas.use-case.ts index 600bf4df..1e9b3681 100644 --- a/modules/customer-invoices/src/api/application/use-cases/proformas/list-proformas.use-case.ts +++ b/modules/customer-invoices/src/api/application/use-cases/proformas/list-proformas.use-case.ts @@ -41,9 +41,9 @@ export class ListProformasUseCase { return Result.fail(result.error); } - const customerInvoices = result.data; + const proformas = result.data; const dto = presenter.toOutput({ - customerInvoices, + customerInvoices: proformas, criteria, }); diff --git a/modules/customer-invoices/src/api/application/use-cases/proformas/report-proforma/report-proforma.use-case.ts b/modules/customer-invoices/src/api/application/use-cases/proformas/report-proforma/report-proforma.use-case.ts index ce881f8b..c011cb7c 100644 --- a/modules/customer-invoices/src/api/application/use-cases/proformas/report-proforma/report-proforma.use-case.ts +++ b/modules/customer-invoices/src/api/application/use-cases/proformas/report-proforma/report-proforma.use-case.ts @@ -27,7 +27,7 @@ export class ReportProformaUseCase { return Result.fail(idOrError.error); } - const invoiceId = idOrError.data; + const proformaId = idOrError.data; const pdfPresenter = this.presenterRegistry.getPresenter({ resource: "customer-invoice", projection: "REPORT", @@ -38,7 +38,7 @@ export class ReportProformaUseCase { try { const proformaOrError = await this.service.getProformaByIdInCompany( companyId, - invoiceId, + proformaId, transaction ); if (proformaOrError.isFailure) { diff --git a/modules/customer-invoices/src/api/application/use-cases/proformas/report-proforma/reporter/customer-invoice.report.html.ts b/modules/customer-invoices/src/api/application/use-cases/proformas/report-proforma/reporter/customer-invoice.report.html.ts index 90e2f18b..9ceae5dd 100644 --- a/modules/customer-invoices/src/api/application/use-cases/proformas/report-proforma/reporter/customer-invoice.report.html.ts +++ b/modules/customer-invoices/src/api/application/use-cases/proformas/report-proforma/reporter/customer-invoice.report.html.ts @@ -1,8 +1,9 @@ import { readFileSync } from "node:fs"; -import path from "node:path"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; import { Presenter } from "@erp/core/api"; -import * as handlebars from "handlebars"; +import Handlebars from "handlebars"; import type { CustomerInvoice } from "../../../../../domain"; import type { @@ -10,6 +11,18 @@ import type { CustomerInvoiceReportPresenter, } from "../../../../presenters"; +/** Helper para trabajar relativo al fichero actual (ESM) */ +export function fromHere(metaUrl: string) { + const file = fileURLToPath(metaUrl); + const dir = dirname(file); + return { + file, // ruta absoluta al fichero actual + dir, // ruta absoluta al directorio actual + resolve: (...parts: string[]) => resolve(dir, ...parts), + join: (...parts: string[]) => join(dir, ...parts), + }; +} + export class CustomerInvoiceReportHTMLPresenter extends Presenter { toOutput(customerInvoice: CustomerInvoice): string { const dtoPresenter = this.presenterRegistry.getPresenter({ @@ -27,10 +40,11 @@ export class CustomerInvoiceReportHTMLPresenter extends Presenter { const prettyDTO = prePresenter.toOutput(invoiceDTO); // Obtener y compilar la plantilla HTML - const templateHtml = readFileSync( - path.join(__dirname, "./templates/customer-invoice/template.hbs") - ).toString(); - const template = handlebars.compile(templateHtml, {}); + const here = fromHere(import.meta.url); + + const templatePath = here.resolve("./templates/customer-invoice/template.hbs"); + const templateHtml = readFileSync(templatePath).toString(); + const template = Handlebars.compile(templateHtml, {}); return template(prettyDTO); } } diff --git a/modules/customer-invoices/src/api/application/use-cases/proformas/report-proforma/reporter/customer-invoice.report.pdf.ts b/modules/customer-invoices/src/api/application/use-cases/proformas/report-proforma/reporter/customer-invoice.report.pdf.ts index 3e25611c..da15949f 100644 --- a/modules/customer-invoices/src/api/application/use-cases/proformas/report-proforma/reporter/customer-invoice.report.pdf.ts +++ b/modules/customer-invoices/src/api/application/use-cases/proformas/report-proforma/reporter/customer-invoice.report.pdf.ts @@ -24,6 +24,8 @@ export class CustomerInvoiceReportPDFPresenter extends Presenter< // Generar el PDF con Puppeteer const browser = await puppeteer.launch({ + executablePath: process.env.PUPPETEER_EXECUTABLE_PATH, + headless: true, args: [ "--disable-extensions", "--no-sandbox", diff --git a/modules/customer-invoices/src/api/infrastructure/dependencies.ts b/modules/customer-invoices/src/api/infrastructure/dependencies.ts index 8dd35659..1a530474 100644 --- a/modules/customer-invoices/src/api/infrastructure/dependencies.ts +++ b/modules/customer-invoices/src/api/infrastructure/dependencies.ts @@ -20,11 +20,14 @@ import { CustomerInvoiceReportPresenter, CustomerInvoiceTaxesReportPresenter, DeleteProformaUseCase, + GetIssueInvoiceUseCase, GetProformaUseCase, IssueProformaInvoiceUseCase, ListCustomerInvoicesPresenter, + ListIssueInvoicesUseCase, ListProformasUseCase, RecipientInvoiceFullPresenter, + ReportIssueInvoiceUseCase, ReportProformaUseCase, UpdateProformaUseCase, } from "../application"; @@ -51,6 +54,10 @@ export type CustomerInvoiceDeps = { report_proforma: () => ReportProformaUseCase; issue_proforma: () => IssueProformaInvoiceUseCase; changeStatus_proforma: () => ChangeStatusProformaUseCase; + + list_issue_invoices: () => ListIssueInvoicesUseCase; + get_issue_invoice: () => GetIssueInvoiceUseCase; + report_issue_invoice: () => ReportIssueInvoiceUseCase; }; }; @@ -125,6 +132,7 @@ export function buildCustomerInvoiceDependencies(params: ModuleParams): Customer ]); const useCases: CustomerInvoiceDeps["useCases"] = { + // Proformas list_proformas: () => new ListProformasUseCase(appService, transactionManager, presenterRegistry), get_proforma: () => new GetProformaUseCase(appService, transactionManager, presenterRegistry), @@ -138,6 +146,14 @@ export function buildCustomerInvoiceDependencies(params: ModuleParams): Customer issue_proforma: () => new IssueProformaInvoiceUseCase(appService, transactionManager, presenterRegistry), changeStatus_proforma: () => new ChangeStatusProformaUseCase(appService, transactionManager), + + // Issue Invoices + list_issue_invoices: () => + new ListIssueInvoicesUseCase(appService, transactionManager, presenterRegistry), + get_issue_invoice: () => + new GetIssueInvoiceUseCase(appService, transactionManager, presenterRegistry), + report_issue_invoice: () => + new ReportIssueInvoiceUseCase(appService, transactionManager, presenterRegistry), }; return { diff --git a/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/get-issue-invoice.controller.ts b/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/get-issue-invoice.controller.ts index f8d72c27..6bb2fd44 100644 --- a/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/get-issue-invoice.controller.ts +++ b/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/get-issue-invoice.controller.ts @@ -1,10 +1,10 @@ import { ExpressController, authGuard, forbidQueryFieldGuard, tenantGuard } from "@erp/core/api"; -import type { GetProformaUseCase } from "../../../../application"; +import type { GetIssueInvoiceUseCase } from "../../../../application"; import { customerInvoicesApiErrorMapper } from "../../customer-invoices-api-error-mapper"; export class GetIssueInvoiceController extends ExpressController { - public constructor(private readonly useCase: GetProformaUseCase) { + public constructor(private readonly useCase: GetIssueInvoiceUseCase) { super(); this.errorMapper = customerInvoicesApiErrorMapper; @@ -19,7 +19,7 @@ export class GetIssueInvoiceController extends ExpressController { } const { invoice_id } = this.req.params; - const result = await this.useCase.execute({ proforma_id: invoice_id, companyId }); + const result = await this.useCase.execute({ invoice_id, companyId }); return result.match( (data) => this.ok(data), diff --git a/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/index.ts b/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/index.ts index fc35aeab..ebf6e6c8 100644 --- a/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/index.ts +++ b/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/index.ts @@ -1,2 +1,3 @@ export * from "./get-issue-invoice.controller"; export * from "./list-issue-invoices.controller"; +export * from "./report-issue-invoice.controller"; diff --git a/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/list-issue-invoices.controller.ts b/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/list-issue-invoices.controller.ts index 40481385..24a9f150 100644 --- a/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/list-issue-invoices.controller.ts +++ b/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/list-issue-invoices.controller.ts @@ -1,11 +1,11 @@ import { ExpressController, authGuard, forbidQueryFieldGuard, tenantGuard } from "@erp/core/api"; import { Criteria } from "@repo/rdx-criteria/server"; -import type { ListProformasUseCase } from "../../../../application"; +import type { ListIssueInvoicesUseCase } from "../../../../application"; import { customerInvoicesApiErrorMapper } from "../../customer-invoices-api-error-mapper"; export class ListIssueInvoicesController extends ExpressController { - public constructor(private readonly useCase: ListProformasUseCase) { + public constructor(private readonly useCase: ListIssueInvoicesUseCase) { super(); this.errorMapper = customerInvoicesApiErrorMapper; diff --git a/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/report-issue-invoice.controller.ts b/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/report-issue-invoice.controller.ts new file mode 100644 index 00000000..b46f2dcc --- /dev/null +++ b/modules/customer-invoices/src/api/infrastructure/express/controllers/issue-invoices/report-issue-invoice.controller.ts @@ -0,0 +1,29 @@ +import { ExpressController, authGuard, forbidQueryFieldGuard, tenantGuard } from "@erp/core/api"; + +import type { ReportIssueInvoiceUseCase } from "../../../../application"; +import { customerInvoicesApiErrorMapper } from "../../customer-invoices-api-error-mapper"; + +export class ReportIssueInvoiceController extends ExpressController { + public constructor(private readonly useCase: ReportIssueInvoiceUseCase) { + super(); + this.errorMapper = customerInvoicesApiErrorMapper; + + // 🔐 Reutiliza guards de auth/tenant y prohíbe 'companyId' en query + this.registerGuards(authGuard(), tenantGuard(), forbidQueryFieldGuard("companyId")); + } + + protected async executeImpl() { + const companyId = this.getTenantId(); + if (!companyId) { + return this.forbiddenError("Tenant ID not found"); + } + const { invoice_id } = this.req.params; + + const result = await this.useCase.execute({ invoice_id, companyId }); + + return result.match( + ({ data, filename }) => this.downloadPDF(data, filename), + (err) => this.handleError(err) + ); + } +} diff --git a/modules/customer-invoices/src/api/infrastructure/express/issue-invoices.routes.ts b/modules/customer-invoices/src/api/infrastructure/express/issue-invoices.routes.ts index 9cb369c8..98fa1fd7 100644 --- a/modules/customer-invoices/src/api/infrastructure/express/issue-invoices.routes.ts +++ b/modules/customer-invoices/src/api/infrastructure/express/issue-invoices.routes.ts @@ -12,9 +12,9 @@ import { import { buildCustomerInvoiceDependencies } from "../dependencies"; import { - GetProformaController, - ListProformasController, - ReportProformaController, + GetIssueInvoiceController, + ListIssueInvoicesController, + ReportIssueInvoiceController, } from "./controllers"; export const issueInvoicesRouter = (params: ModuleParams) => { @@ -51,8 +51,8 @@ export const issueInvoicesRouter = (params: ModuleParams) => { //checkTabContext, validateRequest(ListIssueInvoicesRequestSchema, "params"), async (req: Request, res: Response, next: NextFunction) => { - const useCase = deps.useCases.list_proformas(); - const controller = new ListProformasController(useCase /*, deps.presenters.list */); + const useCase = deps.useCases.list_issue_invoices(); + const controller = new ListIssueInvoicesController(useCase /*, deps.presenters.list */); return controller.execute(req, res, next); } ); @@ -62,8 +62,8 @@ export const issueInvoicesRouter = (params: ModuleParams) => { //checkTabContext, validateRequest(GetIssueInvoiceByIdRequestSchema, "params"), (req: Request, res: Response, next: NextFunction) => { - const useCase = deps.useCases.get_proforma(); - const controller = new GetProformaController(useCase); + const useCase = deps.useCases.get_issue_invoice(); + const controller = new GetIssueInvoiceController(useCase); return controller.execute(req, res, next); } ); @@ -73,11 +73,11 @@ export const issueInvoicesRouter = (params: ModuleParams) => { //checkTabContext, validateRequest(ReportIssueInvoiceByIdRequestSchema, "params"), (req: Request, res: Response, next: NextFunction) => { - const useCase = deps.useCases.report_proforma(); - const controller = new ReportProformaController(useCase); + const useCase = deps.useCases.report_issue_invoice(); + const controller = new ReportIssueInvoiceController(useCase); return controller.execute(req, res, next); } ); - app.use(`${baseRoutePath}/customer-invoices`, router); + app.use(`${baseRoutePath}/issue-invoices`, router); }; diff --git a/modules/customer-invoices/src/api/infrastructure/sequelize/index.ts b/modules/customer-invoices/src/api/infrastructure/sequelize/index.ts index a632cff3..535f7a8a 100644 --- a/modules/customer-invoices/src/api/infrastructure/sequelize/index.ts +++ b/modules/customer-invoices/src/api/infrastructure/sequelize/index.ts @@ -1,7 +1,7 @@ -import customerInvoiceItemTaxesModelInit from "./models/customer-invoice-item-tax.model"; -import customerInvoiceItemModelInit from "./models/customer-invoice-item.model"; -import customerInvoiceTaxesModelInit from "./models/customer-invoice-tax.model"; import customerInvoiceModelInit from "./models/customer-invoice.model"; +import customerInvoiceItemModelInit from "./models/customer-invoice-item.model"; +import customerInvoiceItemTaxesModelInit from "./models/customer-invoice-item-tax.model"; +import customerInvoiceTaxesModelInit from "./models/customer-invoice-tax.model"; export * from "./customer-invoice.repository"; export * from "./models"; diff --git a/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-criteria-whitelist.ts b/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-criteria-whitelist.ts index 9276afe7..006af1b3 100644 --- a/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-criteria-whitelist.ts +++ b/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-criteria-whitelist.ts @@ -1,5 +1,5 @@ import type { Criteria } from "@repo/rdx-criteria/server"; -import { literal, Op, OrderItem, WhereOptions } from "sequelize"; +import { Op, type OrderItem, type WhereOptions, literal } from "sequelize"; // Campos físicos (DB) que permitimos filtrar/ordenar const ALLOWED_FILTERS = { diff --git a/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-item-tax.model.ts b/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-item-tax.model.ts index 024b44ad..905fc0b3 100644 --- a/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-item-tax.model.ts +++ b/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-item-tax.model.ts @@ -1,12 +1,13 @@ import { DataTypes, - InferAttributes, - InferCreationAttributes, + type InferAttributes, + type InferCreationAttributes, Model, - NonAttribute, - Sequelize, + type NonAttribute, + type Sequelize, } from "sequelize"; -import { CustomerInvoiceItem } from "../../../domain"; + +import type { CustomerInvoiceItem } from "../../../domain"; export type CustomerInvoiceItemTaxCreationAttributes = InferCreationAttributes< CustomerInvoiceItemTaxModel, diff --git a/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-item.model.ts b/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-item.model.ts index d398bf88..7dcd0221 100644 --- a/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-item.model.ts +++ b/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-item.model.ts @@ -1,17 +1,18 @@ import { - CreationOptional, + type CreationOptional, DataTypes, - InferAttributes, - InferCreationAttributes, + type InferAttributes, + type InferCreationAttributes, Model, - NonAttribute, - Sequelize, + type NonAttribute, + type Sequelize, } from "sequelize"; -import { + +import type { CustomerInvoiceModel } from "./customer-invoice.model"; +import type { CustomerInvoiceItemTaxCreationAttributes, CustomerInvoiceItemTaxModel, } from "./customer-invoice-item-tax.model"; -import { CustomerInvoiceModel } from "./customer-invoice.model"; export type CustomerInvoiceItemCreationAttributes = InferCreationAttributes< CustomerInvoiceItemModel, diff --git a/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-tax.model.ts b/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-tax.model.ts index 3b35e63c..4c56bb70 100644 --- a/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-tax.model.ts +++ b/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice-tax.model.ts @@ -1,12 +1,13 @@ import { DataTypes, - InferAttributes, - InferCreationAttributes, + type InferAttributes, + type InferCreationAttributes, Model, - NonAttribute, - Sequelize, + type NonAttribute, + type Sequelize, } from "sequelize"; -import { CustomerInvoice } from "../../../domain"; + +import type { CustomerInvoice } from "../../../domain"; export type CustomerInvoiceTaxCreationAttributes = InferCreationAttributes< CustomerInvoiceTaxModel, diff --git a/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice.model.ts b/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice.model.ts index e28f2928..f5fb217d 100644 --- a/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice.model.ts +++ b/modules/customer-invoices/src/api/infrastructure/sequelize/models/customer-invoice.model.ts @@ -1,20 +1,19 @@ -import { CustomerModel } from "@erp/customers/api"; +import type { CustomerModel } from "@erp/customers/api"; import { - CreationOptional, + type CreationOptional, DataTypes, - InferAttributes, - InferCreationAttributes, + type InferAttributes, + type InferCreationAttributes, Model, - NonAttribute, - Sequelize, + type NonAttribute, + type Sequelize, } from "sequelize"; -import { +import type { CustomerInvoiceItemCreationAttributes, CustomerInvoiceItemModel, } from "./customer-invoice-item.model"; - -import { +import type { CustomerInvoiceTaxCreationAttributes, CustomerInvoiceTaxModel, } from "./customer-invoice-tax.model"; diff --git a/modules/customer-invoices/src/api/infrastructure/services/sequelize-invoice-number-generator.ts b/modules/customer-invoices/src/api/infrastructure/services/sequelize-invoice-number-generator.ts index ad54dd25..9dbebc87 100644 --- a/modules/customer-invoices/src/api/infrastructure/services/sequelize-invoice-number-generator.ts +++ b/modules/customer-invoices/src/api/infrastructure/services/sequelize-invoice-number-generator.ts @@ -1,10 +1,11 @@ -import { UniqueID } from "@repo/rdx-ddd"; -import { Maybe, Result } from "@repo/rdx-utils"; -import { literal, Transaction, WhereOptions } from "sequelize"; +import type { UniqueID } from "@repo/rdx-ddd"; +import { type Maybe, Result } from "@repo/rdx-utils"; +import { type Transaction, type WhereOptions, literal } from "sequelize"; + import { CustomerInvoiceNumber, - CustomerInvoiceSerie, - ICustomerInvoiceNumberGenerator, + type CustomerInvoiceSerie, + type ICustomerInvoiceNumberGenerator, } from "../../domain"; import { CustomerInvoiceModel } from "../sequelize"; diff --git a/modules/customer-invoices/src/web/adapters/index.ts b/modules/customer-invoices/src/web/adapters/index.ts new file mode 100644 index 00000000..92b523d1 --- /dev/null +++ b/modules/customer-invoices/src/web/adapters/index.ts @@ -0,0 +1,2 @@ +export * from "./invoice-dto.adapter"; +export * from "./invoice-resume-dto.adapter"; diff --git a/modules/customer-invoices/src/web/schemas/invoice-dto.adapter.ts b/modules/customer-invoices/src/web/adapters/invoice-dto.adapter.ts similarity index 97% rename from modules/customer-invoices/src/web/schemas/invoice-dto.adapter.ts rename to modules/customer-invoices/src/web/adapters/invoice-dto.adapter.ts index f66ca42e..9698a3c6 100644 --- a/modules/customer-invoices/src/web/schemas/invoice-dto.adapter.ts +++ b/modules/customer-invoices/src/web/adapters/invoice-dto.adapter.ts @@ -5,8 +5,7 @@ import type { UpdateCustomerInvoiceByIdRequestDTO, } from "../../common"; import type { InvoiceContextValue } from "../context"; - -import type { InvoiceFormData } from "./invoice.form.schema"; +import type { InvoiceFormData } from "../schemas/invoice.form.schema"; /** * Convierte el DTO completo de API a datos numéricos para el formulario. diff --git a/modules/customer-invoices/src/web/schemas/invoice-resume-dto.adapter.ts b/modules/customer-invoices/src/web/adapters/invoice-resume-dto.adapter.ts similarity index 92% rename from modules/customer-invoices/src/web/schemas/invoice-resume-dto.adapter.ts rename to modules/customer-invoices/src/web/adapters/invoice-resume-dto.adapter.ts index c4c0f1a2..82871b7c 100644 --- a/modules/customer-invoices/src/web/schemas/invoice-resume-dto.adapter.ts +++ b/modules/customer-invoices/src/web/adapters/invoice-resume-dto.adapter.ts @@ -1,7 +1,7 @@ import { MoneyDTOHelper, PercentageDTOHelper, formatCurrency } from "@erp/core"; -import type { InvoiceSummaryFormData } from "./invoice-resume.form.schema"; -import type { CustomerInvoiceSummary } from "./invoices.api.schema"; +import type { InvoiceSummaryFormData } from "../schemas/invoice-resume.form.schema"; +import type { CustomerInvoiceSummary } from "../schemas/invoices.api.schema"; /** * Convierte el DTO completo de API a datos numéricos para el formulario. diff --git a/modules/customer-invoices/src/web/components/customer-invoice-editor-skeleton.tsx b/modules/customer-invoices/src/web/components/customer-invoice-editor-skeleton.tsx deleted file mode 100644 index 2f451ee0..00000000 --- a/modules/customer-invoices/src/web/components/customer-invoice-editor-skeleton.tsx +++ /dev/null @@ -1,34 +0,0 @@ -// components/CustomerSkeleton.tsx -import { AppContent, BackHistoryButton } from "@repo/rdx-ui/components"; -import { Button } from "@repo/shadcn-ui/components"; -import { useTranslation } from "../i18n"; - -export const CustomerInvoiceEditorSkeleton = () => { - const { t } = useTranslation(); - return ( - <> - -
-