import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosMaster } from "./PosMaster";

@Entity("posMasterAct")
export class PosMasterAct extends EntityBase {
  @Column({
    nullable: true,
    comment: "ลำดับที่แสดงผล",
    default: null,
  })
  posMasterOrder: number;

  @Column({
    nullable: true,
    default: null,
    length: 40,
    comment: "คีย์นอก(FK)ของตาราง posMaster",
  })
  posMasterId: string;

  @ManyToOne(() => PosMaster, (posMaster) => posMaster.posMasterActs)
  @JoinColumn({ name: "posMasterId" })
  posMaster: PosMaster;

  @Column({
    nullable: true,
    default: null,
    length: 40,
    comment: "คีย์นอก(FK)ของตาราง posMasterChild",
  })
  posMasterChildId: string;

  @ManyToOne(() => PosMaster, (posMaster) => posMaster.posMasterActChilds)
  @JoinColumn({ name: "posMasterChildId" })
  posMasterChild: PosMaster;

  @Column({
    comment: "สถานะออกคำสั่ง",
    default: "PENDING",
    length: 20,
  })
  statusReport: string;
}

export class CreatePosMaster {
  @Column()
  posMasterNoPrefix: string;
}

export type UpdatePosMaster = Partial<PosMaster>;
