"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.ExpensesController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const expenses_service_1 = require("./expenses.service");
const create_expense_dto_1 = require("./dto/create-expense.dto");
const update_expense_dto_1 = require("./dto/update-expense.dto");
const expense_query_dto_1 = require("./dto/expense-query.dto");
const expense_response_dto_1 = require("./dto/expense-response.dto");
const current_user_decorator_1 = require("../../common/decorators/current-user.decorator");
const group_member_guard_1 = require("../../common/guards/group-member.guard");
let ExpensesController = class ExpensesController {
    constructor(expensesService) {
        this.expensesService = expensesService;
    }
    createExpense(groupId, user, dto) {
        return this.expensesService.createExpense(groupId, user.id, dto);
    }
    listGroupExpenses(groupId, query) {
        return this.expensesService.listGroupExpenses(groupId, query);
    }
    listMyExpenses(user, query) {
        return this.expensesService.listMyExpenses(user.id, query);
    }
    getExpense(expenseId, user) {
        return this.expensesService.getExpense(expenseId, user.id);
    }
    updateExpense(expenseId, user, dto) {
        return this.expensesService.updateExpense(expenseId, user.id, dto);
    }
    deleteExpense(expenseId, user) {
        return this.expensesService.deleteExpense(expenseId, user.id);
    }
};
exports.ExpensesController = ExpensesController;
__decorate([
    (0, common_1.Post)('groups/:id/expenses'),
    (0, common_1.UseGuards)(group_member_guard_1.GroupMemberGuard),
    (0, swagger_1.ApiParam)({ name: 'id', description: 'Group ID' }),
    (0, swagger_1.ApiOperation)({ summary: 'Add an expense to a group' }),
    (0, swagger_1.ApiResponse)({ status: 201, type: expense_response_dto_1.ExpenseDto }),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, create_expense_dto_1.CreateExpenseDto]),
    __metadata("design:returntype", Promise)
], ExpensesController.prototype, "createExpense", null);
__decorate([
    (0, common_1.Get)('groups/:id/expenses'),
    (0, common_1.UseGuards)(group_member_guard_1.GroupMemberGuard),
    (0, swagger_1.ApiParam)({ name: 'id', description: 'Group ID' }),
    (0, swagger_1.ApiOperation)({ summary: 'List expenses in a group (paginated)' }),
    (0, swagger_1.ApiResponse)({ status: 200, type: expense_response_dto_1.PaginatedExpensesDto }),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Query)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, expense_query_dto_1.ExpenseQueryDto]),
    __metadata("design:returntype", Promise)
], ExpensesController.prototype, "listGroupExpenses", null);
__decorate([
    (0, common_1.Get)('expenses'),
    (0, swagger_1.ApiOperation)({ summary: 'List my expenses across all groups' }),
    (0, swagger_1.ApiResponse)({ status: 200, type: expense_response_dto_1.PaginatedExpensesDto }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Query)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, expense_query_dto_1.ExpenseQueryDto]),
    __metadata("design:returntype", Promise)
], ExpensesController.prototype, "listMyExpenses", null);
__decorate([
    (0, common_1.Get)('expenses/:id'),
    (0, swagger_1.ApiParam)({ name: 'id', description: 'Expense ID' }),
    (0, swagger_1.ApiOperation)({ summary: 'Get expense detail' }),
    (0, swagger_1.ApiResponse)({ status: 200, type: expense_response_dto_1.ExpenseDto }),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object]),
    __metadata("design:returntype", Promise)
], ExpensesController.prototype, "getExpense", null);
__decorate([
    (0, common_1.Patch)('expenses/:id'),
    (0, swagger_1.ApiParam)({ name: 'id', description: 'Expense ID' }),
    (0, swagger_1.ApiOperation)({ summary: 'Update expense (creator or group admin)' }),
    (0, swagger_1.ApiResponse)({ status: 200, type: expense_response_dto_1.ExpenseDto }),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, update_expense_dto_1.UpdateExpenseDto]),
    __metadata("design:returntype", Promise)
], ExpensesController.prototype, "updateExpense", null);
__decorate([
    (0, common_1.Delete)('expenses/:id'),
    (0, common_1.HttpCode)(common_1.HttpStatus.OK),
    (0, swagger_1.ApiParam)({ name: 'id', description: 'Expense ID' }),
    (0, swagger_1.ApiOperation)({ summary: 'Soft delete expense (creator or group admin)' }),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object]),
    __metadata("design:returntype", Promise)
], ExpensesController.prototype, "deleteExpense", null);
exports.ExpensesController = ExpensesController = __decorate([
    (0, swagger_1.ApiTags)('Expenses'),
    (0, swagger_1.ApiBearerAuth)(),
    (0, common_1.Controller)({ version: '1' }),
    __metadata("design:paramtypes", [expenses_service_1.ExpensesService])
], ExpensesController);
//# sourceMappingURL=expenses.controller.js.map