"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Expense = void 0;
const typeorm_1 = require("typeorm");
const enums_1 = require("../../common/enums");
const base_entity_1 = require("./base.entity");
const group_entity_1 = require("./group.entity");
const user_entity_1 = require("./user.entity");
const expense_split_entity_1 = require("./expense-split.entity");
let Expense = class Expense extends base_entity_1.BaseEntity {
};
exports.Expense = Expense;
__decorate([
    (0, typeorm_1.Column)({ name: 'group_id', type: 'varchar', length: 36, nullable: true }),
    __metadata("design:type", Object)
], Expense.prototype, "groupId", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'varchar', length: 255 }),
    __metadata("design:type", String)
], Expense.prototype, "description", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'decimal', precision: 12, scale: 2 }),
    __metadata("design:type", String)
], Expense.prototype, "amount", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'char', length: 3, default: 'USD' }),
    __metadata("design:type", String)
], Expense.prototype, "currency", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'enum', enum: enums_1.ExpenseCategory, default: enums_1.ExpenseCategory.Other }),
    __metadata("design:type", String)
], Expense.prototype, "category", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'paid_by', type: 'varchar', length: 36 }),
    __metadata("design:type", String)
], Expense.prototype, "paidById", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'split_type', type: 'enum', enum: enums_1.SplitType }),
    __metadata("design:type", String)
], Expense.prototype, "splitType", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'date' }),
    __metadata("design:type", Date)
], Expense.prototype, "date", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", Object)
], Expense.prototype, "notes", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'receipt_url', type: 'varchar', length: 500, nullable: true }),
    __metadata("design:type", Object)
], Expense.prototype, "receiptUrl", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'is_deleted', type: 'boolean', default: false }),
    __metadata("design:type", Boolean)
], Expense.prototype, "isDeleted", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'created_by', type: 'varchar', length: 36 }),
    __metadata("design:type", String)
], Expense.prototype, "createdById", void 0);
__decorate([
    (0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'datetime', precision: 3 }),
    __metadata("design:type", Date)
], Expense.prototype, "createdAt", void 0);
__decorate([
    (0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'datetime', precision: 3 }),
    __metadata("design:type", Date)
], Expense.prototype, "updatedAt", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => group_entity_1.Group, (g) => g.expenses, { onDelete: 'SET NULL' }),
    (0, typeorm_1.JoinColumn)({ name: 'group_id' }),
    __metadata("design:type", Object)
], Expense.prototype, "group", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => user_entity_1.User, (u) => u.paidExpenses),
    (0, typeorm_1.JoinColumn)({ name: 'paid_by' }),
    __metadata("design:type", user_entity_1.User)
], Expense.prototype, "paidBy", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => user_entity_1.User, (u) => u.createdExpenses),
    (0, typeorm_1.JoinColumn)({ name: 'created_by' }),
    __metadata("design:type", user_entity_1.User)
], Expense.prototype, "createdBy", void 0);
__decorate([
    (0, typeorm_1.OneToMany)(() => expense_split_entity_1.ExpenseSplit, (s) => s.expense),
    __metadata("design:type", Array)
], Expense.prototype, "splits", void 0);
exports.Expense = Expense = __decorate([
    (0, typeorm_1.Entity)('expenses')
], Expense);
//# sourceMappingURL=expense.entity.js.map