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

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

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

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

  @ManyToOne(() => Assign, (assign) => assign.posMasterAssigns)
  @JoinColumn({ name: "assignId" })
  assign: Assign;
}

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

export class PosMasterAssignDTO {
  id: string;
  posMasterId: string;
  assignId: string;
}

export type UpdatePosMaster = Partial<PosMaster>;
