erp-construccion-backend/dist/modules/hr/entities/employee.entity.js

195 lines
7.4 KiB
JavaScript

"use strict";
/**
* Employee Entity
* Empleados de la empresa
*
* @module HR
* @table hr.employees
* @ddl schemas/02-hr-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.Employee = 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 puesto_entity_1 = require("./puesto.entity");
const employee_fraccionamiento_entity_1 = require("./employee-fraccionamiento.entity");
let Employee = class Employee {
id;
tenantId;
codigo;
nombre;
apellidoPaterno;
apellidoMaterno;
curp;
rfc;
nss;
fechaNacimiento;
genero;
email;
telefono;
direccion;
fechaIngreso;
fechaBaja;
puestoId;
departamento;
tipoContrato;
salarioDiario;
estado;
fotoUrl;
createdAt;
updatedAt;
createdById;
// Relations
tenant;
puesto;
createdBy;
asignaciones;
// Computed property
get nombreCompleto() {
return [this.nombre, this.apellidoPaterno, this.apellidoMaterno]
.filter(Boolean)
.join(' ');
}
};
exports.Employee = Employee;
__decorate([
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
__metadata("design:type", String)
], Employee.prototype, "id", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid' }),
__metadata("design:type", String)
], Employee.prototype, "tenantId", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'varchar', length: 20 }),
__metadata("design:type", String)
], Employee.prototype, "codigo", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'varchar', length: 100 }),
__metadata("design:type", String)
], Employee.prototype, "nombre", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'apellido_paterno', type: 'varchar', length: 100 }),
__metadata("design:type", String)
], Employee.prototype, "apellidoPaterno", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'apellido_materno', type: 'varchar', length: 100, nullable: true }),
__metadata("design:type", String)
], Employee.prototype, "apellidoMaterno", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'varchar', length: 18, nullable: true }),
__metadata("design:type", String)
], Employee.prototype, "curp", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'varchar', length: 13, nullable: true }),
__metadata("design:type", String)
], Employee.prototype, "rfc", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'varchar', length: 11, nullable: true }),
__metadata("design:type", String)
], Employee.prototype, "nss", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'fecha_nacimiento', type: 'date', nullable: true }),
__metadata("design:type", Date)
], Employee.prototype, "fechaNacimiento", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'varchar', length: 1, nullable: true }),
__metadata("design:type", String)
], Employee.prototype, "genero", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: true }),
__metadata("design:type", String)
], Employee.prototype, "email", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'varchar', length: 20, nullable: true }),
__metadata("design:type", String)
], Employee.prototype, "telefono", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
__metadata("design:type", String)
], Employee.prototype, "direccion", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'fecha_ingreso', type: 'date' }),
__metadata("design:type", Date)
], Employee.prototype, "fechaIngreso", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'fecha_baja', type: 'date', nullable: true }),
__metadata("design:type", Date)
], Employee.prototype, "fechaBaja", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'puesto_id', type: 'uuid', nullable: true }),
__metadata("design:type", String)
], Employee.prototype, "puestoId", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'varchar', length: 100, nullable: true }),
__metadata("design:type", String)
], Employee.prototype, "departamento", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'tipo_contrato', type: 'varchar', length: 50, nullable: true }),
__metadata("design:type", String)
], Employee.prototype, "tipoContrato", void 0);
__decorate([
(0, typeorm_1.Column)({
name: 'salario_diario',
type: 'decimal',
precision: 10,
scale: 2,
nullable: true
}),
__metadata("design:type", Number)
], Employee.prototype, "salarioDiario", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'varchar', length: 20, default: 'activo' }),
__metadata("design:type", String)
], Employee.prototype, "estado", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'foto_url', type: 'varchar', length: 500, nullable: true }),
__metadata("design:type", String)
], Employee.prototype, "fotoUrl", void 0);
__decorate([
(0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
__metadata("design:type", Date)
], Employee.prototype, "createdAt", void 0);
__decorate([
(0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'timestamptz' }),
__metadata("design:type", Date)
], Employee.prototype, "updatedAt", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'created_by', type: 'uuid', nullable: true }),
__metadata("design:type", String)
], Employee.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)
], Employee.prototype, "tenant", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => puesto_entity_1.Puesto, (p) => p.empleados),
(0, typeorm_1.JoinColumn)({ name: 'puesto_id' }),
__metadata("design:type", puesto_entity_1.Puesto)
], Employee.prototype, "puesto", 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)
], Employee.prototype, "createdBy", void 0);
__decorate([
(0, typeorm_1.OneToMany)(() => employee_fraccionamiento_entity_1.EmployeeFraccionamiento, (ef) => ef.employee),
__metadata("design:type", Array)
], Employee.prototype, "asignaciones", void 0);
exports.Employee = Employee = __decorate([
(0, typeorm_1.Entity)({ schema: 'hr', name: 'employees' }),
(0, typeorm_1.Index)(['tenantId', 'codigo'], { unique: true }),
(0, typeorm_1.Index)(['tenantId', 'curp'], { unique: true })
], Employee);
//# sourceMappingURL=employee.entity.js.map