"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.CustomersController = 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 customers_service_1 = require("./customers.service"); const customer_dto_1 = require("./dto/customer.dto"); let CustomersController = class CustomersController { constructor(customersService) { this.customersService = customersService; } findAll(req) { return this.customersService.findAll(req.user.tenantId); } getWithFiados(req) { return this.customersService.getWithFiados(req.user.tenantId); } findByPhone(req, phone) { return this.customersService.findByPhone(req.user.tenantId, phone); } findOne(req, id) { return this.customersService.findOne(req.user.tenantId, id); } getStats(req, id) { return this.customersService.getCustomerStats(req.user.tenantId, id); } create(req, dto) { return this.customersService.create(req.user.tenantId, dto); } update(req, id, dto) { return this.customersService.update(req.user.tenantId, id, dto); } toggleActive(req, id) { return this.customersService.toggleActive(req.user.tenantId, id); } getFiados(req, customerId) { return this.customersService.getFiados(req.user.tenantId, customerId); } getPendingFiados(req) { return this.customersService.getPendingFiados(req.user.tenantId); } createFiado(req, dto) { return this.customersService.createFiado(req.user.tenantId, dto); } payFiado(req, id, dto) { return this.customersService.payFiado(req.user.tenantId, id, dto, req.user.id); } cancelFiado(req, id) { return this.customersService.cancelFiado(req.user.tenantId, id); } }; exports.CustomersController = CustomersController; __decorate([ (0, common_1.Get)(), (0, swagger_1.ApiOperation)({ summary: 'Listar todos los clientes' }), __param(0, (0, common_1.Request)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], CustomersController.prototype, "findAll", null); __decorate([ (0, common_1.Get)('with-fiados'), (0, swagger_1.ApiOperation)({ summary: 'Listar clientes con fiado habilitado' }), __param(0, (0, common_1.Request)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], CustomersController.prototype, "getWithFiados", null); __decorate([ (0, common_1.Get)('phone/:phone'), (0, swagger_1.ApiOperation)({ summary: 'Buscar cliente por teléfono' }), __param(0, (0, common_1.Request)()), __param(1, (0, common_1.Param)('phone')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String]), __metadata("design:returntype", void 0) ], CustomersController.prototype, "findByPhone", null); __decorate([ (0, common_1.Get)(':id'), (0, swagger_1.ApiOperation)({ summary: 'Obtener cliente por ID' }), __param(0, (0, common_1.Request)()), __param(1, (0, common_1.Param)('id')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String]), __metadata("design:returntype", void 0) ], CustomersController.prototype, "findOne", null); __decorate([ (0, common_1.Get)(':id/stats'), (0, swagger_1.ApiOperation)({ summary: 'Obtener estadísticas del cliente' }), __param(0, (0, common_1.Request)()), __param(1, (0, common_1.Param)('id')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String]), __metadata("design:returntype", void 0) ], CustomersController.prototype, "getStats", null); __decorate([ (0, common_1.Post)(), (0, swagger_1.ApiOperation)({ summary: 'Crear nuevo cliente' }), __param(0, (0, common_1.Request)()), __param(1, (0, common_1.Body)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, customer_dto_1.CreateCustomerDto]), __metadata("design:returntype", void 0) ], CustomersController.prototype, "create", null); __decorate([ (0, common_1.Put)(':id'), (0, swagger_1.ApiOperation)({ summary: 'Actualizar cliente' }), __param(0, (0, common_1.Request)()), __param(1, (0, common_1.Param)('id')), __param(2, (0, common_1.Body)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, customer_dto_1.UpdateCustomerDto]), __metadata("design:returntype", void 0) ], CustomersController.prototype, "update", null); __decorate([ (0, common_1.Patch)(':id/toggle-active'), (0, swagger_1.ApiOperation)({ summary: 'Activar/desactivar cliente' }), __param(0, (0, common_1.Request)()), __param(1, (0, common_1.Param)('id')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String]), __metadata("design:returntype", void 0) ], CustomersController.prototype, "toggleActive", null); __decorate([ (0, common_1.Get)('fiados/all'), (0, swagger_1.ApiOperation)({ summary: 'Listar todos los fiados' }), (0, swagger_1.ApiQuery)({ name: 'customerId', required: false }), __param(0, (0, common_1.Request)()), __param(1, (0, common_1.Query)('customerId')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String]), __metadata("design:returntype", void 0) ], CustomersController.prototype, "getFiados", null); __decorate([ (0, common_1.Get)('fiados/pending'), (0, swagger_1.ApiOperation)({ summary: 'Listar fiados pendientes' }), __param(0, (0, common_1.Request)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], CustomersController.prototype, "getPendingFiados", null); __decorate([ (0, common_1.Post)('fiados'), (0, swagger_1.ApiOperation)({ summary: 'Crear nuevo fiado' }), __param(0, (0, common_1.Request)()), __param(1, (0, common_1.Body)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, customer_dto_1.CreateFiadoDto]), __metadata("design:returntype", void 0) ], CustomersController.prototype, "createFiado", null); __decorate([ (0, common_1.Post)('fiados/:id/pay'), (0, swagger_1.ApiOperation)({ summary: 'Registrar pago de fiado' }), __param(0, (0, common_1.Request)()), __param(1, (0, common_1.Param)('id')), __param(2, (0, common_1.Body)()), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String, customer_dto_1.PayFiadoDto]), __metadata("design:returntype", void 0) ], CustomersController.prototype, "payFiado", null); __decorate([ (0, common_1.Patch)('fiados/:id/cancel'), (0, swagger_1.ApiOperation)({ summary: 'Cancelar fiado' }), __param(0, (0, common_1.Request)()), __param(1, (0, common_1.Param)('id')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String]), __metadata("design:returntype", void 0) ], CustomersController.prototype, "cancelFiado", null); exports.CustomersController = CustomersController = __decorate([ (0, swagger_1.ApiTags)('customers'), (0, swagger_1.ApiBearerAuth)(), (0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard), (0, common_1.Controller)('v1/customers'), __metadata("design:paramtypes", [customers_service_1.CustomersService]) ], CustomersController); //# sourceMappingURL=customers.controller.js.map