"use strict";
/**
 * RequisicionObra Entity
 * Requisiciones de material desde obra
 *
 * @module Inventory
 * @table inventory.requisiciones_obra
 * @ddl schemas/06-inventory-ext-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.RequisicionObra = 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 fraccionamiento_entity_1 = require("../../construction/entities/fraccionamiento.entity");
const requisicion_linea_entity_1 = require("./requisicion-linea.entity");
let RequisicionObra = class RequisicionObra {
    id;
    tenantId;
    fraccionamientoId;
    requisitionNumber;
    requisitionDate;
    requiredDate;
    status;
    priority;
    requestedById;
    destinationWarehouseId;
    approvedById;
    approvedAt;
    rejectionReason;
    purchaseOrderId;
    notes;
    createdAt;
    createdById;
    updatedAt;
    updatedById;
    deletedAt;
    deletedById;
    // Relations
    tenant;
    fraccionamiento;
    requestedBy;
    approvedBy;
    createdBy;
    lineas;
};
exports.RequisicionObra = RequisicionObra;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
    __metadata("design:type", String)
], RequisicionObra.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid' }),
    __metadata("design:type", String)
], RequisicionObra.prototype, "tenantId", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'fraccionamiento_id', type: 'uuid' }),
    __metadata("design:type", String)
], RequisicionObra.prototype, "fraccionamientoId", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'requisition_number', type: 'varchar', length: 30 }),
    __metadata("design:type", String)
], RequisicionObra.prototype, "requisitionNumber", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'requisition_date', type: 'date' }),
    __metadata("design:type", Date)
], RequisicionObra.prototype, "requisitionDate", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'required_date', type: 'date' }),
    __metadata("design:type", Date)
], RequisicionObra.prototype, "requiredDate", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'varchar', length: 20, default: 'draft' }),
    __metadata("design:type", String)
], RequisicionObra.prototype, "status", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'varchar', length: 20, default: 'medium' }),
    __metadata("design:type", String)
], RequisicionObra.prototype, "priority", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'requested_by', type: 'uuid' }),
    __metadata("design:type", String)
], RequisicionObra.prototype, "requestedById", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'destination_warehouse_id', type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], RequisicionObra.prototype, "destinationWarehouseId", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'approved_by', type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], RequisicionObra.prototype, "approvedById", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'approved_at', type: 'timestamptz', nullable: true }),
    __metadata("design:type", Date)
], RequisicionObra.prototype, "approvedAt", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'rejection_reason', type: 'text', nullable: true }),
    __metadata("design:type", String)
], RequisicionObra.prototype, "rejectionReason", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'purchase_order_id', type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], RequisicionObra.prototype, "purchaseOrderId", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], RequisicionObra.prototype, "notes", void 0);
__decorate([
    (0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
    __metadata("design:type", Date)
], RequisicionObra.prototype, "createdAt", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'created_by', type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], RequisicionObra.prototype, "createdById", void 0);
__decorate([
    (0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'timestamptz' }),
    __metadata("design:type", Date)
], RequisicionObra.prototype, "updatedAt", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'updated_by', type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], RequisicionObra.prototype, "updatedById", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'deleted_at', type: 'timestamptz', nullable: true }),
    __metadata("design:type", Date)
], RequisicionObra.prototype, "deletedAt", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'deleted_by', type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], RequisicionObra.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)
], RequisicionObra.prototype, "tenant", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => fraccionamiento_entity_1.Fraccionamiento),
    (0, typeorm_1.JoinColumn)({ name: 'fraccionamiento_id' }),
    __metadata("design:type", fraccionamiento_entity_1.Fraccionamiento)
], RequisicionObra.prototype, "fraccionamiento", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => user_entity_1.User),
    (0, typeorm_1.JoinColumn)({ name: 'requested_by' }),
    __metadata("design:type", user_entity_1.User)
], RequisicionObra.prototype, "requestedBy", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => user_entity_1.User),
    (0, typeorm_1.JoinColumn)({ name: 'approved_by' }),
    __metadata("design:type", user_entity_1.User)
], RequisicionObra.prototype, "approvedBy", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => user_entity_1.User),
    (0, typeorm_1.JoinColumn)({ name: 'created_by' }),
    __metadata("design:type", user_entity_1.User)
], RequisicionObra.prototype, "createdBy", void 0);
__decorate([
    (0, typeorm_1.OneToMany)(() => requisicion_linea_entity_1.RequisicionLinea, (linea) => linea.requisicion),
    __metadata("design:type", Array)
], RequisicionObra.prototype, "lineas", void 0);
exports.RequisicionObra = RequisicionObra = __decorate([
    (0, typeorm_1.Entity)({ schema: 'inventory', name: 'requisiciones_obra' }),
    (0, typeorm_1.Index)(['tenantId', 'requisitionNumber'], { unique: true })
], RequisicionObra);
//# sourceMappingURL=requisicion-obra.entity.js.map