import { Plan } from "src/modules/plans/entities/plan.entity"
import { ServicePricing } from "src/modules/service-pricing/entities/service-pricing.entity"
import { TripServicePricing } from "src/modules/trips/entities/trip-service-pricing.entity"
import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  DeleteDateColumn,
  OneToMany,
} from "typeorm"

@Entity("charge_types")
export class ChargeType {
  @PrimaryGeneratedColumn()
  id: number

  @Column({ type: "varchar", nullable: false })
  name: string

  @Column({ type: "varchar", nullable: true })
  unit_of_measure: string

  @Column({ type: "varchar", nullable: true })
  description: string

  @CreateDateColumn({
    type: "timestamp",
    nullable: true,
    default: () => "NOW()",
  })
  created_at: Date

  @UpdateDateColumn({
    type: "timestamp",
    nullable: true,
    default: () => "NOW()",
  })
  updated_at: Date

  @DeleteDateColumn({ type: "timestamp", nullable: true })
  deleted_at: Date

  @OneToMany(
    () => ServicePricing,
    (service_pricing) => service_pricing.charge_type,
  )
  service_pricing: ServicePricing[]

  @OneToMany(
    () => TripServicePricing,
    (trip_service_pricing) => trip_service_pricing.charge_type,
  )
  trip_service_pricing: TripServicePricing[]

  @OneToMany(() => Plan, (plan) => plan.charge_type)
  plan: Plan
}
