- Prefijo v2: MCH - TRACEABILITY-MASTER.yml creado - Listo para integracion como submodulo Workspace: v2.0.0 | SIMCO: v4.0.0
153 lines
7.2 KiB
JavaScript
153 lines
7.2 KiB
JavaScript
"use strict";
|
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.InvoicesController = void 0;
|
|
const common_1 = require("@nestjs/common");
|
|
const swagger_1 = require("@nestjs/swagger");
|
|
const jwt_auth_guard_1 = require("../auth/guards/jwt-auth.guard");
|
|
const invoices_service_1 = require("./invoices.service");
|
|
const create_invoice_dto_1 = require("./dto/create-invoice.dto");
|
|
const invoice_entity_1 = require("./entities/invoice.entity");
|
|
let InvoicesController = class InvoicesController {
|
|
constructor(invoicesService) {
|
|
this.invoicesService = invoicesService;
|
|
}
|
|
async getTaxConfig(req) {
|
|
return this.invoicesService.getTaxConfig(req.user.tenantId);
|
|
}
|
|
async saveTaxConfig(req, data) {
|
|
return this.invoicesService.saveTaxConfig(req.user.tenantId, data);
|
|
}
|
|
async createInvoice(req, dto) {
|
|
return this.invoicesService.createInvoice(req.user.tenantId, dto);
|
|
}
|
|
async getInvoices(req, status, from, to, limit) {
|
|
return this.invoicesService.getInvoices(req.user.tenantId, {
|
|
status,
|
|
from: from ? new Date(from) : undefined,
|
|
to: to ? new Date(to) : undefined,
|
|
limit: limit ? Number(limit) : undefined,
|
|
});
|
|
}
|
|
async getSummary(req, month) {
|
|
return this.invoicesService.getSummary(req.user.tenantId, month ? new Date(month) : undefined);
|
|
}
|
|
async getInvoice(id) {
|
|
return this.invoicesService.getInvoice(id);
|
|
}
|
|
async stampInvoice(id) {
|
|
return this.invoicesService.stampInvoice(id);
|
|
}
|
|
async cancelInvoice(id, body) {
|
|
return this.invoicesService.cancelInvoice(id, body.reason, body.uuidReplacement);
|
|
}
|
|
async sendInvoice(id, body) {
|
|
return this.invoicesService.sendInvoice(id, body.email);
|
|
}
|
|
};
|
|
exports.InvoicesController = InvoicesController;
|
|
__decorate([
|
|
(0, common_1.Get)('tax-config'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Obtener configuracion fiscal del tenant' }),
|
|
__param(0, (0, common_1.Request)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object]),
|
|
__metadata("design:returntype", Promise)
|
|
], InvoicesController.prototype, "getTaxConfig", null);
|
|
__decorate([
|
|
(0, common_1.Post)('tax-config'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Guardar/actualizar configuracion fiscal' }),
|
|
__param(0, (0, common_1.Request)()),
|
|
__param(1, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object, Object]),
|
|
__metadata("design:returntype", Promise)
|
|
], InvoicesController.prototype, "saveTaxConfig", null);
|
|
__decorate([
|
|
(0, common_1.Post)(),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Crear nueva factura' }),
|
|
__param(0, (0, common_1.Request)()),
|
|
__param(1, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object, create_invoice_dto_1.CreateInvoiceDto]),
|
|
__metadata("design:returntype", Promise)
|
|
], InvoicesController.prototype, "createInvoice", null);
|
|
__decorate([
|
|
(0, common_1.Get)(),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Listar facturas del tenant' }),
|
|
(0, swagger_1.ApiQuery)({ name: 'status', required: false, enum: invoice_entity_1.InvoiceStatus }),
|
|
(0, swagger_1.ApiQuery)({ name: 'from', required: false, type: String }),
|
|
(0, swagger_1.ApiQuery)({ name: 'to', required: false, type: String }),
|
|
(0, swagger_1.ApiQuery)({ name: 'limit', required: false, type: Number }),
|
|
__param(0, (0, common_1.Request)()),
|
|
__param(1, (0, common_1.Query)('status')),
|
|
__param(2, (0, common_1.Query)('from')),
|
|
__param(3, (0, common_1.Query)('to')),
|
|
__param(4, (0, common_1.Query)('limit')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object, String, String, String, Number]),
|
|
__metadata("design:returntype", Promise)
|
|
], InvoicesController.prototype, "getInvoices", null);
|
|
__decorate([
|
|
(0, common_1.Get)('summary'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Obtener resumen de facturacion del mes' }),
|
|
(0, swagger_1.ApiQuery)({ name: 'month', required: false, type: String, description: 'YYYY-MM-DD' }),
|
|
__param(0, (0, common_1.Request)()),
|
|
__param(1, (0, common_1.Query)('month')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object, String]),
|
|
__metadata("design:returntype", Promise)
|
|
], InvoicesController.prototype, "getSummary", null);
|
|
__decorate([
|
|
(0, common_1.Get)(':id'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Obtener factura por ID' }),
|
|
__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String]),
|
|
__metadata("design:returntype", Promise)
|
|
], InvoicesController.prototype, "getInvoice", null);
|
|
__decorate([
|
|
(0, common_1.Post)(':id/stamp'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Timbrar factura (enviar al SAT)' }),
|
|
__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String]),
|
|
__metadata("design:returntype", Promise)
|
|
], InvoicesController.prototype, "stampInvoice", null);
|
|
__decorate([
|
|
(0, common_1.Post)(':id/cancel'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Cancelar factura' }),
|
|
__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
|
|
__param(1, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, Object]),
|
|
__metadata("design:returntype", Promise)
|
|
], InvoicesController.prototype, "cancelInvoice", null);
|
|
__decorate([
|
|
(0, common_1.Post)(':id/send'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Enviar factura por email' }),
|
|
__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
|
|
__param(1, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, Object]),
|
|
__metadata("design:returntype", Promise)
|
|
], InvoicesController.prototype, "sendInvoice", null);
|
|
exports.InvoicesController = InvoicesController = __decorate([
|
|
(0, swagger_1.ApiTags)('Invoices'),
|
|
(0, swagger_1.ApiBearerAuth)(),
|
|
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
(0, common_1.Controller)('invoices'),
|
|
__metadata("design:paramtypes", [invoices_service_1.InvoicesService])
|
|
], InvoicesController);
|
|
//# sourceMappingURL=invoices.controller.js.map
|