"use strict";
/**
 * ComparativoProducto Entity
 * Productos cotizados por proveedor en comparativo
 *
 * @module Purchase
 * @table purchase.comparativo_productos
 * @ddl schemas/07-purchase-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.ComparativoProducto = 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 comparativo_proveedor_entity_1 = require("./comparativo-proveedor.entity");
let ComparativoProducto = class ComparativoProducto {
    id;
    tenantId;
    comparativoProveedorId;
    productId;
    quantity;
    unitPrice;
    notes;
    createdAt;
    createdById;
    updatedAt;
    updatedById;
    // Computed property (in DB is GENERATED ALWAYS AS)
    get totalPrice() {
        return this.quantity * this.unitPrice;
    }
    // Relations
    tenant;
    comparativoProveedor;
    createdBy;
};
exports.ComparativoProducto = ComparativoProducto;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
    __metadata("design:type", String)
], ComparativoProducto.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'tenant_id', type: 'uuid' }),
    __metadata("design:type", String)
], ComparativoProducto.prototype, "tenantId", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'comparativo_proveedor_id', type: 'uuid' }),
    __metadata("design:type", String)
], ComparativoProducto.prototype, "comparativoProveedorId", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'product_id', type: 'uuid' }),
    __metadata("design:type", String)
], ComparativoProducto.prototype, "productId", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'decimal', precision: 12, scale: 4 }),
    __metadata("design:type", Number)
], ComparativoProducto.prototype, "quantity", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'unit_price', type: 'decimal', precision: 12, scale: 4 }),
    __metadata("design:type", Number)
], ComparativoProducto.prototype, "unitPrice", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], ComparativoProducto.prototype, "notes", void 0);
__decorate([
    (0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
    __metadata("design:type", Date)
], ComparativoProducto.prototype, "createdAt", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'created_by', type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], ComparativoProducto.prototype, "createdById", void 0);
__decorate([
    (0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'timestamptz' }),
    __metadata("design:type", Date)
], ComparativoProducto.prototype, "updatedAt", void 0);
__decorate([
    (0, typeorm_1.Column)({ name: 'updated_by', type: 'uuid', nullable: true }),
    __metadata("design:type", String)
], ComparativoProducto.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)
], ComparativoProducto.prototype, "tenant", void 0);
__decorate([
    (0, typeorm_1.ManyToOne)(() => comparativo_proveedor_entity_1.ComparativoProveedor, (cp) => cp.productos, { onDelete: 'CASCADE' }),
    (0, typeorm_1.JoinColumn)({ name: 'comparativo_proveedor_id' }),
    __metadata("design:type", comparativo_proveedor_entity_1.ComparativoProveedor)
], ComparativoProducto.prototype, "comparativoProveedor", 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)
], ComparativoProducto.prototype, "createdBy", void 0);
exports.ComparativoProducto = ComparativoProducto = __decorate([
    (0, typeorm_1.Entity)({ schema: 'purchase', name: 'comparativo_productos' })
], ComparativoProducto);
//# sourceMappingURL=comparativo-producto.entity.js.map