255 lines
10 KiB
JavaScript
255 lines
10 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Estimacion Entity
|
|
* Estimaciones de obra periodicas para subcontratistas
|
|
*
|
|
* @module Estimates
|
|
* @table estimates.estimaciones
|
|
* @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.Estimacion = 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 estimacion_concepto_entity_1 = require("./estimacion-concepto.entity");
|
|
const amortizacion_entity_1 = require("./amortizacion.entity");
|
|
const retencion_entity_1 = require("./retencion.entity");
|
|
const estimacion_workflow_entity_1 = require("./estimacion-workflow.entity");
|
|
let Estimacion = class Estimacion {
|
|
id;
|
|
tenantId;
|
|
contratoId;
|
|
fraccionamientoId;
|
|
estimateNumber;
|
|
periodStart;
|
|
periodEnd;
|
|
sequenceNumber;
|
|
status;
|
|
subtotal;
|
|
advanceAmount;
|
|
retentionAmount;
|
|
taxAmount;
|
|
totalAmount;
|
|
submittedAt;
|
|
submittedById;
|
|
reviewedAt;
|
|
reviewedById;
|
|
approvedAt;
|
|
approvedById;
|
|
invoiceId;
|
|
invoicedAt;
|
|
paidAt;
|
|
notes;
|
|
createdAt;
|
|
createdById;
|
|
updatedAt;
|
|
updatedById;
|
|
deletedAt;
|
|
deletedById;
|
|
// Relations
|
|
tenant;
|
|
fraccionamiento;
|
|
submittedBy;
|
|
reviewedBy;
|
|
approvedBy;
|
|
createdBy;
|
|
conceptos;
|
|
amortizaciones;
|
|
retenciones;
|
|
workflow;
|
|
};
|
|
exports.Estimacion = Estimacion;
|
|
__decorate([
|
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
__metadata("design:type", String)
|
|
], Estimacion.prototype, "id", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid' }),
|
|
__metadata("design:type", String)
|
|
], Estimacion.prototype, "tenantId", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'contrato_id', type: 'uuid' }),
|
|
__metadata("design:type", String)
|
|
], Estimacion.prototype, "contratoId", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'fraccionamiento_id', type: 'uuid' }),
|
|
__metadata("design:type", String)
|
|
], Estimacion.prototype, "fraccionamientoId", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'estimate_number', type: 'varchar', length: 30 }),
|
|
__metadata("design:type", String)
|
|
], Estimacion.prototype, "estimateNumber", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'period_start', type: 'date' }),
|
|
__metadata("design:type", Date)
|
|
], Estimacion.prototype, "periodStart", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'period_end', type: 'date' }),
|
|
__metadata("design:type", Date)
|
|
], Estimacion.prototype, "periodEnd", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'sequence_number', type: 'integer' }),
|
|
__metadata("design:type", Number)
|
|
], Estimacion.prototype, "sequenceNumber", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({
|
|
type: 'enum',
|
|
enum: ['draft', 'submitted', 'reviewed', 'approved', 'invoiced', 'paid', 'rejected', 'cancelled'],
|
|
enumName: 'estimates.estimate_status',
|
|
default: 'draft',
|
|
}),
|
|
__metadata("design:type", String)
|
|
], Estimacion.prototype, "status", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ type: 'decimal', precision: 16, scale: 2, default: 0 }),
|
|
__metadata("design:type", Number)
|
|
], Estimacion.prototype, "subtotal", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'advance_amount', type: 'decimal', precision: 16, scale: 2, default: 0 }),
|
|
__metadata("design:type", Number)
|
|
], Estimacion.prototype, "advanceAmount", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'retention_amount', type: 'decimal', precision: 16, scale: 2, default: 0 }),
|
|
__metadata("design:type", Number)
|
|
], Estimacion.prototype, "retentionAmount", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'tax_amount', type: 'decimal', precision: 16, scale: 2, default: 0 }),
|
|
__metadata("design:type", Number)
|
|
], Estimacion.prototype, "taxAmount", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'total_amount', type: 'decimal', precision: 16, scale: 2, default: 0 }),
|
|
__metadata("design:type", Number)
|
|
], Estimacion.prototype, "totalAmount", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'submitted_at', type: 'timestamptz', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "submittedAt", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'submitted_by', type: 'uuid', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "submittedById", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'reviewed_at', type: 'timestamptz', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "reviewedAt", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'reviewed_by', type: 'uuid', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "reviewedById", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'approved_at', type: 'timestamptz', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "approvedAt", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'approved_by', type: 'uuid', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "approvedById", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'invoice_id', type: 'uuid', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "invoiceId", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'invoiced_at', type: 'timestamptz', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "invoicedAt", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'paid_at', type: 'timestamptz', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "paidAt", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "notes", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
|
|
__metadata("design:type", Date)
|
|
], Estimacion.prototype, "createdAt", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'created_by', type: 'uuid', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "createdById", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'timestamptz', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "updatedAt", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'updated_by', type: 'uuid', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "updatedById", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'deleted_at', type: 'timestamptz', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "deletedAt", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.Column)({ name: 'deleted_by', type: 'uuid', nullable: true }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.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)
|
|
], Estimacion.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)
|
|
], Estimacion.prototype, "fraccionamiento", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.ManyToOne)(() => user_entity_1.User),
|
|
(0, typeorm_1.JoinColumn)({ name: 'submitted_by' }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "submittedBy", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.ManyToOne)(() => user_entity_1.User),
|
|
(0, typeorm_1.JoinColumn)({ name: 'reviewed_by' }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "reviewedBy", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.ManyToOne)(() => user_entity_1.User),
|
|
(0, typeorm_1.JoinColumn)({ name: 'approved_by' }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "approvedBy", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.ManyToOne)(() => user_entity_1.User),
|
|
(0, typeorm_1.JoinColumn)({ name: 'created_by' }),
|
|
__metadata("design:type", Object)
|
|
], Estimacion.prototype, "createdBy", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.OneToMany)(() => estimacion_concepto_entity_1.EstimacionConcepto, (c) => c.estimacion),
|
|
__metadata("design:type", Array)
|
|
], Estimacion.prototype, "conceptos", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.OneToMany)(() => amortizacion_entity_1.Amortizacion, (a) => a.estimacion),
|
|
__metadata("design:type", Array)
|
|
], Estimacion.prototype, "amortizaciones", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.OneToMany)(() => retencion_entity_1.Retencion, (r) => r.estimacion),
|
|
__metadata("design:type", Array)
|
|
], Estimacion.prototype, "retenciones", void 0);
|
|
__decorate([
|
|
(0, typeorm_1.OneToMany)(() => estimacion_workflow_entity_1.EstimacionWorkflow, (w) => w.estimacion),
|
|
__metadata("design:type", Array)
|
|
], Estimacion.prototype, "workflow", void 0);
|
|
exports.Estimacion = Estimacion = __decorate([
|
|
(0, typeorm_1.Entity)({ schema: 'estimates', name: 'estimaciones' }),
|
|
(0, typeorm_1.Index)(['tenantId', 'estimateNumber'], { unique: true }),
|
|
(0, typeorm_1.Index)(['contratoId', 'sequenceNumber'], { unique: true }),
|
|
(0, typeorm_1.Index)(['tenantId']),
|
|
(0, typeorm_1.Index)(['contratoId']),
|
|
(0, typeorm_1.Index)(['fraccionamientoId']),
|
|
(0, typeorm_1.Index)(['status']),
|
|
(0, typeorm_1.Index)(['periodStart', 'periodEnd']),
|
|
(0, typeorm_1.Check)(`"period_end" >= "period_start"`)
|
|
], Estimacion);
|
|
//# sourceMappingURL=estimacion.entity.js.map
|