26 lines
851 B
TypeScript
26 lines
851 B
TypeScript
import { ExpressController, authGuard, forbidQueryFieldGuard, tenantGuard } from "@erp/core/api";
|
|
import { IssueCustomerInvoiceUseCase } from "../../../application";
|
|
|
|
export class IssueCustomerInvoiceController extends ExpressController {
|
|
public constructor(
|
|
private readonly useCase: IssueCustomerInvoiceUseCase
|
|
/* private readonly presenter: any */
|
|
) {
|
|
super();
|
|
// 🔐 Reutiliza guards de auth/tenant y prohíbe 'companyId' en query
|
|
this.useGuards(authGuard(), tenantGuard(), forbidQueryFieldGuard("companyId"));
|
|
}
|
|
|
|
async executeImpl() {
|
|
const tenantId = this.getTenantId()!; // garantizado por tenantGuard
|
|
const { id } = this.req.params;
|
|
|
|
const result = await this.useCase.execute({ id, tenantId });
|
|
|
|
return result.match(
|
|
(data) => this.ok(data),
|
|
(err) => this.handleError(err)
|
|
);
|
|
}
|
|
}
|