"use strict"; /** * Inspection Entity * Inspecciones de calidad realizadas * * @module Quality * @table quality.inspections */ 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.Inspection = 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 checklist_entity_1 = require("./checklist.entity"); const inspection_result_entity_1 = require("./inspection-result.entity"); const non_conformity_entity_1 = require("./non-conformity.entity"); let Inspection = class Inspection { id; tenantId; checklistId; loteId; inspectionNumber; inspectionDate; inspectorId; status; totalItems; passedItems; failedItems; passRate; completedAt; approvedById; approvedAt; notes; rejectionReason; createdAt; createdById; updatedAt; updatedById; // Relations tenant; checklist; inspector; createdBy; approvedBy; results; nonConformities; }; exports.Inspection = Inspection; __decorate([ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'), __metadata("design:type", String) ], Inspection.prototype, "id", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid' }), __metadata("design:type", String) ], Inspection.prototype, "tenantId", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'checklist_id', type: 'uuid' }), __metadata("design:type", String) ], Inspection.prototype, "checklistId", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'lote_id', type: 'uuid' }), __metadata("design:type", String) ], Inspection.prototype, "loteId", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'inspection_number', type: 'varchar', length: 50 }), __metadata("design:type", String) ], Inspection.prototype, "inspectionNumber", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'inspection_date', type: 'date' }), __metadata("design:type", Date) ], Inspection.prototype, "inspectionDate", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'inspector_id', type: 'uuid' }), __metadata("design:type", String) ], Inspection.prototype, "inspectorId", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'varchar', length: 20, default: 'pending' }), __metadata("design:type", String) ], Inspection.prototype, "status", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'total_items', type: 'integer', default: 0 }), __metadata("design:type", Number) ], Inspection.prototype, "totalItems", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'passed_items', type: 'integer', default: 0 }), __metadata("design:type", Number) ], Inspection.prototype, "passedItems", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'failed_items', type: 'integer', default: 0 }), __metadata("design:type", Number) ], Inspection.prototype, "failedItems", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'pass_rate', type: 'decimal', precision: 5, scale: 2, nullable: true }), __metadata("design:type", Number) ], Inspection.prototype, "passRate", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'completed_at', type: 'timestamptz', nullable: true }), __metadata("design:type", Date) ], Inspection.prototype, "completedAt", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'approved_by', type: 'uuid', nullable: true }), __metadata("design:type", String) ], Inspection.prototype, "approvedById", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'approved_at', type: 'timestamptz', nullable: true }), __metadata("design:type", Date) ], Inspection.prototype, "approvedAt", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'text', nullable: true }), __metadata("design:type", String) ], Inspection.prototype, "notes", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'rejection_reason', type: 'text', nullable: true }), __metadata("design:type", String) ], Inspection.prototype, "rejectionReason", void 0); __decorate([ (0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }), __metadata("design:type", Date) ], Inspection.prototype, "createdAt", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'created_by', type: 'uuid', nullable: true }), __metadata("design:type", String) ], Inspection.prototype, "createdById", void 0); __decorate([ (0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'timestamptz' }), __metadata("design:type", Date) ], Inspection.prototype, "updatedAt", void 0); __decorate([ (0, typeorm_1.Column)({ name: 'updated_by', type: 'uuid', nullable: true }), __metadata("design:type", String) ], Inspection.prototype, "updatedById", 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) ], Inspection.prototype, "tenant", void 0); __decorate([ (0, typeorm_1.ManyToOne)(() => checklist_entity_1.Checklist, (c) => c.inspections), (0, typeorm_1.JoinColumn)({ name: 'checklist_id' }), __metadata("design:type", checklist_entity_1.Checklist) ], Inspection.prototype, "checklist", void 0); __decorate([ (0, typeorm_1.ManyToOne)(() => user_entity_1.User), (0, typeorm_1.JoinColumn)({ name: 'inspector_id' }), __metadata("design:type", user_entity_1.User) ], Inspection.prototype, "inspector", 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) ], Inspection.prototype, "createdBy", 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) ], Inspection.prototype, "approvedBy", void 0); __decorate([ (0, typeorm_1.OneToMany)(() => inspection_result_entity_1.InspectionResult, (r) => r.inspection), __metadata("design:type", Array) ], Inspection.prototype, "results", void 0); __decorate([ (0, typeorm_1.OneToMany)(() => non_conformity_entity_1.NonConformity, (nc) => nc.inspection), __metadata("design:type", Array) ], Inspection.prototype, "nonConformities", void 0); exports.Inspection = Inspection = __decorate([ (0, typeorm_1.Entity)({ schema: 'quality', name: 'inspections' }), (0, typeorm_1.Index)(['tenantId', 'inspectionNumber'], { unique: true }) ], Inspection); //# sourceMappingURL=inspection.entity.js.map