"use strict";
/**
 * EstimacionWorkflow Entity
 * Historial de workflow de estimaciones
 *
 * @module Estimates
 * @table estimates.estimacion_workflow
 * @ddl schemas/04-estimates-schema-ddl.sql
 */
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.EstimacionWorkflow = void 0;
const typeorm_1 = require("typeorm");
const tenant_entity_1 = require("../../core/entities/tenant.entity");
const user_entity_1 = require("../../core/entities/user.entity");
const estimacion_entity_1 = require("./estimacion.entity");
let EstimacionWorkflow = class EstimacionWorkflow {
    id;
    tenantId;
    estimacionId;
    fromStatus;
    toStatus;
    action;
    comments;
    performedById;
    performedAt;
    createdAt;
    createdById;
    // Relations
    tenant;
    estimacion;
    performedBy;
    createdBy;
};
exports.EstimacionWorkflow = EstimacionWorkflow;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
    __metadata("design:type", String)
], EstimacionWorkflow.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid' }),
    __metadata("design:type", String)
], EstimacionWorkflow.prototype, "tenantId", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'estimacion_id', type: 'uuid' }),
    __metadata("design:type", String)
], EstimacionWorkflow.prototype, "estimacionId", void 0);
__decorate([
    (0, typeorm_1.Column)({
        name: 'from_status',
        type: 'enum',
        enum: ['draft', 'submitted', 'reviewed', 'approved', 'invoiced', 'paid', 'rejected', 'cancelled'],
        enumName: 'estimates.estimate_status',
        nullable: true,
    }),
    __metadata("design:type", Object)
], EstimacionWorkflow.prototype, "fromStatus", void 0);
__decorate([
    (0, typeorm_1.Column)({
        name: 'to_status',
        type: 'enum',
        enum: ['draft', 'submitted', 'reviewed', 'approved', 'invoiced', 'paid', 'rejected', 'cancelled'],
        enumName: 'estimates.estimate_status',
    }),
    __metadata("design:type", String)
], EstimacionWorkflow.prototype, "toStatus", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'varchar', length: 50 }),
    __metadata("design:type", String)
], EstimacionWorkflow.prototype, "action", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", Object)
], EstimacionWorkflow.prototype, "comments", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'performed_by', type: 'uuid' }),
    __metadata("design:type", String)
], EstimacionWorkflow.prototype, "performedById", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'performed_at', type: 'timestamptz', default: () => 'NOW()' }),
    __metadata("design:type", Date)
], EstimacionWorkflow.prototype, "performedAt", void 0);
__decorate([
    (0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
    __metadata("design:type", Date)
], EstimacionWorkflow.prototype, "createdAt", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'created_by', type: 'uuid', nullable: true }),
    __metadata("design:type", Object)
], EstimacionWorkflow.prototype, "createdById", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => tenant_entity_1.Tenant),
    (0, typeorm_1.JoinColumn)({ name: 'tenant_id' }),
    __metadata("design:type", tenant_entity_1.Tenant)
], EstimacionWorkflow.prototype, "tenant", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => estimacion_entity_1.Estimacion, (e) => e.workflow),
    (0, typeorm_1.JoinColumn)({ name: 'estimacion_id' }),
    __metadata("design:type", estimacion_entity_1.Estimacion)
], EstimacionWorkflow.prototype, "estimacion", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => user_entity_1.User),
    (0, typeorm_1.JoinColumn)({ name: 'performed_by' }),
    __metadata("design:type", user_entity_1.User)
], EstimacionWorkflow.prototype, "performedBy", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => user_entity_1.User),
    (0, typeorm_1.JoinColumn)({ name: 'created_by' }),
    __metadata("design:type", Object)
], EstimacionWorkflow.prototype, "createdBy", void 0);
exports.EstimacionWorkflow = EstimacionWorkflow = __decorate([
    (0, typeorm_1.Entity)({ schema: 'estimates', name: 'estimacion_workflow' }),
    (0, typeorm_1.Index)(['tenantId']),
    (0, typeorm_1.Index)(['estimacionId'])
], EstimacionWorkflow);
//# sourceMappingURL=estimacion-workflow.entity.js.map