import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, } from "typeorm"; import { Product } from "./Product"; import { TypeMeasureIngredient } from "./TypeMeasureIngredient"; @Entity("product_ingredient", { comment: "Ingredientes que tendrá un producto específico. Esto se hace para guardar la información del inventario que se tiene y el que se gasta diario, esto genera un reporte donde el cliente puede ver qué cosas fueron usadas.", }) export class ProductIngredient { @PrimaryGeneratedColumn({ type: "int", comment: "Número de identificación (ID) único de cada registro.", }) id: number; @ManyToOne(() => Product, (product) => product.product_ingredients, { onDelete: "CASCADE", onUpdate: "NO ACTION", }) @JoinColumn({ name: "product" }) product: Product; @Column({ length: 30, type: "varchar", comment: "Nombre del ingrediente." }) name: string; @ManyToOne( () => TypeMeasureIngredient, (typeMeasureIngredient) => typeMeasureIngredient.type_measure_ingredients, { onDelete: "CASCADE", onUpdate: "NO ACTION", } ) @JoinColumn({ name: "type_measure_ingredient" }) type_measure_ingredient: TypeMeasureIngredient; @Column({ type: "int", comment: "Cantidad del ingrediente." }) quantity: number; @Column({ type: "datetime", comment: "Fecha de creación del registro." }) created: Date; @Column({ default: 1, type: "int", width: 1, comment: "Estado del registro, es decir:\r\n1. Activo: Es visible en los reportes de inventario.\r\n0. Inactivo: No será visible en los reportes de inventario.", }) status: number; }