// Espejo INSERTABLE de maeplu — usado UNICAMENTE por MaepluMirrorService
// para dar de alta productos "de una sola vez" (prefijo TLLP-) que el
// taller crea localmente y que necesitan existir en el ERP para poder
// facturarse en POSTouch (Facturacion.php valida el PLU contra maeplu).
//
// A diferencia de Producto (producto.entity.ts), esta entidad NO tiene
// insert:false/update:false: es la unica excepcion deliberada a la regla
// "maeplu es de solo lectura", y solo permite INSERT (nunca UPDATE/DELETE
// — ver maeplu-mirror.guard.spec.ts, que falla si MaepluMirrorService
// llama algo distinto de .insert() sobre este repositorio).
import { Column, Entity, PrimaryColumn } from "typeorm";
import { charBooleanTransformer } from "../../common/transformers/char-boolean.transformer";

@Entity("maeplu")
export class MaepluMirror {
  @PrimaryColumn({ length: 24 })
  plu: string;

  @Column({ length: 255, nullable: true })
  desclarga: string;

  @Column({ type: "decimal", precision: 12, scale: 2, default: 0 })
  precio: number;

  @Column({ type: "decimal", precision: 12, scale: 2, default: 0 })
  costo: number;

  @Column({ type: "decimal", precision: 5, scale: 2, default: 0 })
  iva: number;

  @Column({
    type: "char",
    length: 1,
    nullable: true,
    transformer: charBooleanTransformer,
  })
  pagaiva: boolean;

  @Column({
    name: "es_servicio",
    type: "char",
    length: 1,
    nullable: true,
    transformer: charBooleanTransformer,
  })
  es_servicio: boolean;

  @Column({
    name: "usainventario",
    type: "char",
    length: 1,
    nullable: true,
    transformer: charBooleanTransformer,
  })
  usainventario: boolean;

  @Column({
    name: "es_taller",
    type: "char",
    length: 1,
    nullable: true,
    transformer: charBooleanTransformer,
  })
  es_taller: boolean;

  @Column({
    name: "es_producto",
    type: "char",
    length: 1,
    nullable: true,
    transformer: charBooleanTransformer,
  })
  es_producto: boolean;
}
