erp-construccion-backend/dist/modules/estimates/entities/anticipo.entity.js

193 lines
7.5 KiB
JavaScript

"use strict";
/**
* Anticipo Entity
* Anticipos otorgados a subcontratistas
*
* @module Estimates
* @table estimates.anticipos
* @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.Anticipo = 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 amortizacion_entity_1 = require("./amortizacion.entity");
let Anticipo = class Anticipo {
id;
tenantId;
contratoId;
advanceType;
advanceNumber;
advanceDate;
grossAmount;
taxAmount;
netAmount;
amortizationPercentage;
amortizedAmount;
// Columna calculada (GENERATED ALWAYS AS) - solo lectura
pendingAmount;
isFullyAmortized;
approvedAt;
approvedById;
paidAt;
paymentReference;
notes;
createdAt;
createdById;
updatedAt;
updatedById;
deletedAt;
deletedById;
// Relations
tenant;
approvedBy;
createdBy;
amortizaciones;
};
exports.Anticipo = Anticipo;
__decorate([
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
__metadata("design:type", String)
], Anticipo.prototype, "id", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid' }),
__metadata("design:type", String)
], Anticipo.prototype, "tenantId", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'contrato_id', type: 'uuid' }),
__metadata("design:type", String)
], Anticipo.prototype, "contratoId", void 0);
__decorate([
(0, typeorm_1.Column)({
name: 'advance_type',
type: 'enum',
enum: ['initial', 'progress', 'materials'],
enumName: 'estimates.advance_type',
default: 'initial',
}),
__metadata("design:type", String)
], Anticipo.prototype, "advanceType", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'advance_number', type: 'varchar', length: 30 }),
__metadata("design:type", String)
], Anticipo.prototype, "advanceNumber", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'advance_date', type: 'date' }),
__metadata("design:type", Date)
], Anticipo.prototype, "advanceDate", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'gross_amount', type: 'decimal', precision: 16, scale: 2 }),
__metadata("design:type", Number)
], Anticipo.prototype, "grossAmount", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'tax_amount', type: 'decimal', precision: 16, scale: 2, default: 0 }),
__metadata("design:type", Number)
], Anticipo.prototype, "taxAmount", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'net_amount', type: 'decimal', precision: 16, scale: 2 }),
__metadata("design:type", Number)
], Anticipo.prototype, "netAmount", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'amortization_percentage', type: 'decimal', precision: 5, scale: 2, default: 0 }),
__metadata("design:type", Number)
], Anticipo.prototype, "amortizationPercentage", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'amortized_amount', type: 'decimal', precision: 16, scale: 2, default: 0 }),
__metadata("design:type", Number)
], Anticipo.prototype, "amortizedAmount", void 0);
__decorate([
(0, typeorm_1.Column)({
name: 'pending_amount',
type: 'decimal',
precision: 16,
scale: 2,
insert: false,
update: false,
}),
__metadata("design:type", Number)
], Anticipo.prototype, "pendingAmount", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'is_fully_amortized', type: 'boolean', default: false }),
__metadata("design:type", Boolean)
], Anticipo.prototype, "isFullyAmortized", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'approved_at', type: 'timestamptz', nullable: true }),
__metadata("design:type", Object)
], Anticipo.prototype, "approvedAt", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'approved_by', type: 'uuid', nullable: true }),
__metadata("design:type", Object)
], Anticipo.prototype, "approvedById", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'paid_at', type: 'timestamptz', nullable: true }),
__metadata("design:type", Object)
], Anticipo.prototype, "paidAt", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'payment_reference', type: 'varchar', length: 100, nullable: true }),
__metadata("design:type", Object)
], Anticipo.prototype, "paymentReference", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
__metadata("design:type", Object)
], Anticipo.prototype, "notes", void 0);
__decorate([
(0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
__metadata("design:type", Date)
], Anticipo.prototype, "createdAt", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'created_by', type: 'uuid', nullable: true }),
__metadata("design:type", Object)
], Anticipo.prototype, "createdById", void 0);
__decorate([
(0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'timestamptz', nullable: true }),
__metadata("design:type", Object)
], Anticipo.prototype, "updatedAt", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'updated_by', type: 'uuid', nullable: true }),
__metadata("design:type", Object)
], Anticipo.prototype, "updatedById", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'deleted_at', type: 'timestamptz', nullable: true }),
__metadata("design:type", Object)
], Anticipo.prototype, "deletedAt", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'deleted_by', type: 'uuid', nullable: true }),
__metadata("design:type", Object)
], Anticipo.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)
], Anticipo.prototype, "tenant", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => user_entity_1.User),
(0, typeorm_1.JoinColumn)({ name: 'approved_by' }),
__metadata("design:type", Object)
], Anticipo.prototype, "approvedBy", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => user_entity_1.User),
(0, typeorm_1.JoinColumn)({ name: 'created_by' }),
__metadata("design:type", Object)
], Anticipo.prototype, "createdBy", void 0);
__decorate([
(0, typeorm_1.OneToMany)(() => amortizacion_entity_1.Amortizacion, (a) => a.anticipo),
__metadata("design:type", Array)
], Anticipo.prototype, "amortizaciones", void 0);
exports.Anticipo = Anticipo = __decorate([
(0, typeorm_1.Entity)({ schema: 'estimates', name: 'anticipos' }),
(0, typeorm_1.Index)(['tenantId', 'advanceNumber'], { unique: true }),
(0, typeorm_1.Index)(['tenantId']),
(0, typeorm_1.Index)(['contratoId']),
(0, typeorm_1.Index)(['advanceType'])
], Anticipo);
//# sourceMappingURL=anticipo.entity.js.map