"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.Settlement = 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");
let Settlement = class Settlement extends base_entity_1.BaseEntity {
};
exports.Settlement = Settlement;
__decorate([
    (0, typeorm_1.Column)({ name: 'group_id', type: 'varchar', length: 36, nullable: true }),
    __metadata("design:type", Object)
], Settlement.prototype, "groupId", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'payer_id', type: 'varchar', length: 36 }),
    __metadata("design:type", String)
], Settlement.prototype, "payerId", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'payee_id', type: 'varchar', length: 36 }),
    __metadata("design:type", String)
], Settlement.prototype, "payeeId", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'decimal', precision: 12, scale: 2 }),
    __metadata("design:type", String)
], Settlement.prototype, "amount", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'char', length: 3, default: 'USD' }),
    __metadata("design:type", String)
], Settlement.prototype, "currency", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'enum', enum: enums_1.SettlementMethod, default: enums_1.SettlementMethod.Cash }),
    __metadata("design:type", String)
], Settlement.prototype, "method", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", Object)
], Settlement.prototype, "notes", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'is_confirmed', type: 'boolean', default: false }),
    __metadata("design:type", Boolean)
], Settlement.prototype, "isConfirmed", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'settled_at', type: 'datetime', precision: 3, nullable: true }),
    __metadata("design:type", Object)
], Settlement.prototype, "settledAt", void 0);
__decorate([
    (0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'datetime', precision: 3 }),
    __metadata("design:type", Date)
], Settlement.prototype, "createdAt", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => group_entity_1.Group, (g) => g.settlements, { onDelete: 'SET NULL' }),
    (0, typeorm_1.JoinColumn)({ name: 'group_id' }),
    __metadata("design:type", Object)
], Settlement.prototype, "group", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => user_entity_1.User, (u) => u.sentSettlements),
    (0, typeorm_1.JoinColumn)({ name: 'payer_id' }),
    __metadata("design:type", user_entity_1.User)
], Settlement.prototype, "payer", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => user_entity_1.User, (u) => u.receivedSettlements),
    (0, typeorm_1.JoinColumn)({ name: 'payee_id' }),
    __metadata("design:type", user_entity_1.User)
], Settlement.prototype, "payee", void 0);
exports.Settlement = Settlement = __decorate([
    (0, typeorm_1.Entity)('settlements')
], Settlement);
//# sourceMappingURL=settlement.entity.js.map