erp-construccion-backend/dist/modules/inventory/entities/consumo-obra.entity.js

169 lines
6.9 KiB
JavaScript

"use strict";
/**
* ConsumoObra Entity
* Consumos de materiales por obra/lote
*
* @module Inventory
* @table inventory.consumos_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.ConsumoObra = 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 lote_entity_1 = require("../../construction/entities/lote.entity");
const concepto_entity_1 = require("../../budgets/entities/concepto.entity");
let ConsumoObra = class ConsumoObra {
id;
tenantId;
stockMoveId;
fraccionamientoId;
loteId;
departamentoId;
conceptoId;
productId;
quantity;
unitCost;
consumptionDate;
registeredById;
notes;
createdAt;
createdById;
updatedAt;
updatedById;
deletedAt;
deletedById;
// Computed property (in DB is GENERATED ALWAYS AS)
get totalCost() {
return this.quantity * (this.unitCost || 0);
}
// Relations
tenant;
fraccionamiento;
lote;
concepto;
registeredBy;
createdBy;
};
exports.ConsumoObra = ConsumoObra;
__decorate([
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
__metadata("design:type", String)
], ConsumoObra.prototype, "id", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid' }),
__metadata("design:type", String)
], ConsumoObra.prototype, "tenantId", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'stock_move_id', type: 'uuid', nullable: true }),
__metadata("design:type", String)
], ConsumoObra.prototype, "stockMoveId", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'fraccionamiento_id', type: 'uuid' }),
__metadata("design:type", String)
], ConsumoObra.prototype, "fraccionamientoId", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'lote_id', type: 'uuid', nullable: true }),
__metadata("design:type", String)
], ConsumoObra.prototype, "loteId", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'departamento_id', type: 'uuid', nullable: true }),
__metadata("design:type", String)
], ConsumoObra.prototype, "departamentoId", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'concepto_id', type: 'uuid', nullable: true }),
__metadata("design:type", String)
], ConsumoObra.prototype, "conceptoId", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'product_id', type: 'uuid' }),
__metadata("design:type", String)
], ConsumoObra.prototype, "productId", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'decimal', precision: 12, scale: 4 }),
__metadata("design:type", Number)
], ConsumoObra.prototype, "quantity", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'unit_cost', type: 'decimal', precision: 12, scale: 4, nullable: true }),
__metadata("design:type", Number)
], ConsumoObra.prototype, "unitCost", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'consumption_date', type: 'date' }),
__metadata("design:type", Date)
], ConsumoObra.prototype, "consumptionDate", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'registered_by', type: 'uuid' }),
__metadata("design:type", String)
], ConsumoObra.prototype, "registeredById", void 0);
__decorate([
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
__metadata("design:type", String)
], ConsumoObra.prototype, "notes", void 0);
__decorate([
(0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
__metadata("design:type", Date)
], ConsumoObra.prototype, "createdAt", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'created_by', type: 'uuid', nullable: true }),
__metadata("design:type", String)
], ConsumoObra.prototype, "createdById", void 0);
__decorate([
(0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'timestamptz' }),
__metadata("design:type", Date)
], ConsumoObra.prototype, "updatedAt", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'updated_by', type: 'uuid', nullable: true }),
__metadata("design:type", String)
], ConsumoObra.prototype, "updatedById", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'deleted_at', type: 'timestamptz', nullable: true }),
__metadata("design:type", Date)
], ConsumoObra.prototype, "deletedAt", void 0);
__decorate([
(0, typeorm_1.Column)({ name: 'deleted_by', type: 'uuid', nullable: true }),
__metadata("design:type", String)
], ConsumoObra.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)
], ConsumoObra.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)
], ConsumoObra.prototype, "fraccionamiento", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => lote_entity_1.Lote),
(0, typeorm_1.JoinColumn)({ name: 'lote_id' }),
__metadata("design:type", lote_entity_1.Lote)
], ConsumoObra.prototype, "lote", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => concepto_entity_1.Concepto),
(0, typeorm_1.JoinColumn)({ name: 'concepto_id' }),
__metadata("design:type", concepto_entity_1.Concepto)
], ConsumoObra.prototype, "concepto", void 0);
__decorate([
(0, typeorm_1.ManyToOne)(() => user_entity_1.User),
(0, typeorm_1.JoinColumn)({ name: 'registered_by' }),
__metadata("design:type", user_entity_1.User)
], ConsumoObra.prototype, "registeredBy", 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)
], ConsumoObra.prototype, "createdBy", void 0);
exports.ConsumoObra = ConsumoObra = __decorate([
(0, typeorm_1.Entity)({ schema: 'inventory', name: 'consumos_obra' })
], ConsumoObra);
//# sourceMappingURL=consumo-obra.entity.js.map