"use strict";
/**
 * Generador Entity
 * Numeros generadores (soporte de cantidades para estimaciones)
 *
 * @module Estimates
 * @table estimates.generadores
 * @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.Generador = 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_concepto_entity_1 = require("./estimacion-concepto.entity");
let Generador = class Generador {
    id;
    tenantId;
    estimacionConceptoId;
    generatorNumber;
    description;
    status;
    loteId;
    departamentoId;
    locationDescription;
    quantity;
    formula;
    photoUrl;
    sketchUrl;
    capturedById;
    capturedAt;
    approvedById;
    approvedAt;
    createdAt;
    createdById;
    updatedAt;
    updatedById;
    deletedAt;
    deletedById;
    // Relations
    tenant;
    estimacionConcepto;
    capturedBy;
    approvedBy;
    createdBy;
};
exports.Generador = Generador;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
    __metadata("design:type", String)
], Generador.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid' }),
    __metadata("design:type", String)
], Generador.prototype, "tenantId", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'estimacion_concepto_id', type: 'uuid' }),
    __metadata("design:type", String)
], Generador.prototype, "estimacionConceptoId", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'generator_number', type: 'varchar', length: 30 }),
    __metadata("design:type", String)
], Generador.prototype, "generatorNumber", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", Object)
], Generador.prototype, "description", void 0);
__decorate([
    (0, typeorm_1.Column)({
        type: 'enum',
        enum: ['draft', 'in_progress', 'completed', 'approved'],
        enumName: 'estimates.generator_status',
        default: 'draft',
    }),
    __metadata("design:type", String)
], Generador.prototype, "status", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'lote_id', type: 'uuid', nullable: true }),
    __metadata("design:type", Object)
], Generador.prototype, "loteId", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'departamento_id', type: 'uuid', nullable: true }),
    __metadata("design:type", Object)
], Generador.prototype, "departamentoId", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'location_description', type: 'varchar', length: 255, nullable: true }),
    __metadata("design:type", Object)
], Generador.prototype, "locationDescription", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'decimal', precision: 12, scale: 4, default: 0 }),
    __metadata("design:type", Number)
], Generador.prototype, "quantity", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", Object)
], Generador.prototype, "formula", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'photo_url', type: 'varchar', length: 500, nullable: true }),
    __metadata("design:type", Object)
], Generador.prototype, "photoUrl", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'sketch_url', type: 'varchar', length: 500, nullable: true }),
    __metadata("design:type", Object)
], Generador.prototype, "sketchUrl", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'captured_by', type: 'uuid' }),
    __metadata("design:type", String)
], Generador.prototype, "capturedById", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'captured_at', type: 'timestamptz', default: () => 'NOW()' }),
    __metadata("design:type", Date)
], Generador.prototype, "capturedAt", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'approved_by', type: 'uuid', nullable: true }),
    __metadata("design:type", Object)
], Generador.prototype, "approvedById", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'approved_at', type: 'timestamptz', nullable: true }),
    __metadata("design:type", Object)
], Generador.prototype, "approvedAt", void 0);
__decorate([
    (0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
    __metadata("design:type", Date)
], Generador.prototype, "createdAt", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'created_by', type: 'uuid', nullable: true }),
    __metadata("design:type", Object)
], Generador.prototype, "createdById", void 0);
__decorate([
    (0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'timestamptz', nullable: true }),
    __metadata("design:type", Object)
], Generador.prototype, "updatedAt", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'updated_by', type: 'uuid', nullable: true }),
    __metadata("design:type", Object)
], Generador.prototype, "updatedById", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'deleted_at', type: 'timestamptz', nullable: true }),
    __metadata("design:type", Object)
], Generador.prototype, "deletedAt", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'deleted_by', type: 'uuid', nullable: true }),
    __metadata("design:type", Object)
], Generador.prototype, "deletedById", 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)
], Generador.prototype, "tenant", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => estimacion_concepto_entity_1.EstimacionConcepto, (ec) => ec.generadores),
    (0, typeorm_1.JoinColumn)({ name: 'estimacion_concepto_id' }),
    __metadata("design:type", estimacion_concepto_entity_1.EstimacionConcepto)
], Generador.prototype, "estimacionConcepto", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => user_entity_1.User),
    (0, typeorm_1.JoinColumn)({ name: 'captured_by' }),
    __metadata("design:type", user_entity_1.User)
], Generador.prototype, "capturedBy", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => user_entity_1.User),
    (0, typeorm_1.JoinColumn)({ name: 'approved_by' }),
    __metadata("design:type", Object)
], Generador.prototype, "approvedBy", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => user_entity_1.User),
    (0, typeorm_1.JoinColumn)({ name: 'created_by' }),
    __metadata("design:type", Object)
], Generador.prototype, "createdBy", void 0);
exports.Generador = Generador = __decorate([
    (0, typeorm_1.Entity)({ schema: 'estimates', name: 'generadores' }),
    (0, typeorm_1.Index)(['tenantId']),
    (0, typeorm_1.Index)(['estimacionConceptoId']),
    (0, typeorm_1.Index)(['status'])
], Generador);
//# sourceMappingURL=generador.entity.js.map