import { PcdBaseEntity } from "src/framework/custom/pcd-entity.custom";
import { ImportantDoc } from "src/tables/imp-doc/imp-doc.entity";
import { paymentInstrument } from "src/tables/payment-instrument/payment-ins.entity";
import { EmdFeeType } from "src/tables/emd-fee-type/emd-fee-type.entity";
import { FormOfContract } from "src/tables/form-of-contract/form-of-contract.entity";
import { PaymentMode } from "src/tables/payment-mode/payment-mode.entity";
import { ProductCategory } from "src/tables/product-category/product-category.entity";
import { TenderCategory } from "src/tables/tender-category/tender-category.entity";
import { TenderType } from "src/tables/tender-type/tender-type.entity";
import { TenderDoc } from "src/tables/tender-documents/tender-doc.entity";
import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm";

@Entity('tender_master')
export class TenderMaster extends PcdBaseEntity{

    @PrimaryGeneratedColumn({
        name:'id'
    })
        id:number
    @Column({
        name:'org_chain',
        type:'varchar',
        length:500,
        nullable:true
    })
    orgChain:string
    @Column({
        name:'tender_ref_no',
        type:"varchar",
        length:500,
        nullable:true
    })
    tenderRefNo:string
    @Column({
        name:"tender_id",
        type:'varchar',
        length:510,
        nullable:true
    })
    tenderId:string
    @Column({
        name:"allow_tech_eval",
        type:"char",
        length:1,
        nullable:true
    })
    allowTechEval:string

    @Column({
        name:"payment_mode",
        type:'numeric',
        nullable:true
    })
    paymentMode:number
    @Column({
        name:'allow_withdraw',
        type :'char',
        length:1,
        nullable:true
    })
    allowWithdraw:string
    @Column({
        name:'no_of_covers',
        type:'int',
        nullable:true,
        default: () => "(0)"
    })
    noOfCovers:string
    @Column({
        name:'itemwise_tech_eval',
        type:'char',
        length:1,
        nullable:true
    })
    itemwiseTechEval:string
    @Column({
        name:'allow_two_stage',
        type:'char',
        length:1,
        nullable:true
    })
    allowTwoStageBid:string

    @Column({
        name:'tender_fee',
        type:'int',
        nullable:true
        
    })
    tenderFee:string
    @Column({
        name:'fee_pay_to',
        type:"varchar",
        length:100,
        default:()=>"'Nil'"
    })
    feePayableTo:string
    @Column({
        name:'fee_pay_at',
        type:"varchar",
        length:100,
        default:()=>"'Nil'"
    })
    feePayableAt:string
    @Column({
        name:"t_fee_Exemption",
        type:"char",
        length:1,
        nullable:true
    })
    tenderFeeExemption:string
    @Column({
        name:'emd_amt',
        type:'int',
        nullable:true
    })
    emdAmt:string
    @Column({
        name:"emd_payable_to",
        type:"varchar",
        length:100,
        default :() =>"'Nil'"
    })
    emdPayableTo:string
    @Column({
        name:"allow_emd_bg_st",
        type:"char",
        length:1,
        nullable:true
    })
    allowEmdBgOrSt:string
    @Column({
        name:"emd_percentage",
        type:"int",
        nullable:true
    })
    emdPercentage:string
    @Column({
        name:"emd_payable_at",
        type:"varchar",
        length:100,
        default:() =>"'Nil'"
    })
    emdPayableAt:string
    @Column({
        name:"title",
        type:'varchar',
        length:500,
        nullable:true
      })
      title:string
    @Column({
        name:"work_desc",
        type:'varchar',
        length:500,
        nullable:true
    })
    workDesc:string
    @Column({
        name:"nda_pre_quali",
        type:"varchar",
        length:500,
        nullable:true
    })
    ndaPreQualification:string
    @Column({
        name:"remarks",
        type:"varchar",
        length:500,
        default:()=>"'NA'"
    })
    remarks:string
    @Column({
        name:"tender_value",
        type:"int",
        nullable:true
    })
    tenderValue:string
    @Column({
        name:"contract_type",
        type:"varchar",
        length:200,
        nullable:true
    })
    contractType:string
    @Column({
        name:"location",
        type :"varchar",
        length:200,
        nullable:true
    })
    location:string
    @Column({
        name:"pre_bid_meet_add",
        type:"varchar",
        length:500,
        nullable:true
    })
    preBidMeetAdd:string
    @Column({
        name:"allow_nda_tender",
        type:"char",
        length:1,
        nullable:true
    })
    allowNdaTender:string
    @Column({
        name:"product_cat",
        type:"varchar",
        nullable:true
    })
    productCategory:string
    @Column({
        name:"bid_validity",
        type:'int',
        nullable:true
    })
    bidValidity:string
    @Column({
        name:"pincode",
        type:"int",
        nullable:true
    })
    pincode:string
    @Column({
        name:"pre_bid_date",
        type:"date",
        nullable:true
    })
    preBidDate:Date
    @Column({
        name:"allow_prefer_bidder",
        type:"char",
        length:1,
        nullable:true
    })
    allowPreferencialBidder:string
    @Column({
        name:"sub_category",
        type:"varchar",
        length:500,
        nullable:true
    })
    subCategory:string
    @Column({
        name:"period_of_work",
        type:"int",
        nullable:true
    })
    periodOfWork:string
    @Column({
        name:"pre_meet_place",
        type:"varchar",
        length:500,
        nullable:true
    })
    preBidMeetPlace:string
    @Column({
        name:"bid_open_place",
        type:"varchar",
        length:500,
        nullable:true
    })
    bidOpeningPlace:string
    @Column({
        name:"publish_date",
        type:"date",
        nullable:true
    })
    publishDate:Date
    @Column({
        name:"sale_start_date",
        type:"date",
        nullable:true
    })
    saleStartDate:Date
    @Column({
        name:"clarification_start_d",
        type:"date",
        nullable:true
    })
    clarificationStartDate:Date
    @Column({
        name:"bid_sub_start_date",
        type:"date",
        nullable:true
    })
    bidSubStartDate:Date
    @Column({
        name:"bid_open_date",
        type:"date",
        nullable:true
    })
    bidOpenDate:Date
    @Column({
        name:"sale_end_date",
        type:"date",
        nullable:true
    })
    saleEndDate:Date
    @Column({
        name:"clarification_end_d",
        type:"date",
        nullable:true
    })
    clarificationEndDate:Date
    @Column({
        name:"bid_sub_end_date",
        type:"date",
        nullable:true
    })
    bidSubEndDate:Date
    @Column({
        name:"tender_inv_name",
        type:"varchar",
        length:100,
        nullable:true
    })
    tenderInvName:string
    @Column({
        name:"tender_inv_address",
        type:"varchar",
        length:500,
        nullable:true
    })
    tenderInvAddess:string
    @Column({
        name:"tender_type",
        type:"numeric",
        nullable:true
    })
    tenderType:number
    @Column({
        name:"tender_category",
        type:"numeric",
        nullable:true
    })
    tenderCategory:number
    @Column({
        name:"form_of_contract",
        type:"numeric",
        nullable:true
    })
    formOfContract:number
    @Column({
        name:"emd_fee_type",
        type:"varchar",
        nullable:true
    })
    emd_fee_type:string

    @Column({ 
        name:"activeyn",
        type:"varchar",
        length:1,
        nullable:true
    })
    activeYn:string


    @OneToMany(() => ImportantDoc, (importantDoc) => importantDoc.tenderIdD )
    importantDoc:ImportantDoc[]

    @OneToMany(() => paymentInstrument, (paymentInstrument) => paymentInstrument.tenderIdD )
    paymentInstrument:paymentInstrument[]

    @OneToMany(() => TenderDoc, (TenderDoc) => TenderDoc.tenderIdD )
    TenderDoc:TenderDoc[]

    @ManyToOne(() => TenderType,(tenderType)=> tenderType.tenderMaster,{eager:true})
    @JoinColumn([{ name: "tender_type", referencedColumnName: "id" }])
    tenderTypeD:TenderType

    @ManyToOne(() => TenderCategory,(tenderCategory)=> tenderCategory.tenderMaster,{eager:true})
    @JoinColumn([{ name: "tender_category", referencedColumnName: "id" }])
    tenderCategoryD:TenderCategory


    @ManyToOne(() => PaymentMode,(paymentMode)=> paymentMode.tenderMaster,{eager:true})
    @JoinColumn([{ name: "payment_mode", referencedColumnName: "id" }])
    paymentModeD:PaymentMode

    @ManyToOne(() => FormOfContract,(formOfContract)=> formOfContract.tenderMaster,{eager:true})
    @JoinColumn([{ name: "form_of_contract", referencedColumnName: "id" }])
    formOfContractD:FormOfContract

    @ManyToOne(() => ProductCategory,(productCategory)=> productCategory.tenderMaster,{eager:true})
    @JoinColumn([{ name: "product_cat", referencedColumnName: "id" }])
    productCategoryD:ProductCategory

    @ManyToOne(() => EmdFeeType,(EmdFeeType)=> EmdFeeType.tenderMaster,{eager:true})
    @JoinColumn([{ name: "emd_fee_type", referencedColumnName: "id" }])
    emdFeeTypeD:ProductCategory
   
}

