import { Entity, Enum, Index, ManyToOne, Property, Unique } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { Restaurant } from 'src/modules/restaurants/entities/restaurant.entity';
import { PaymentGatewayEnum, PaymentMethodEnum } from '../interface/payment';

@Entity({ tableName: 'payment_methods' })
@Unique({ properties: ['restaurant', 'method'] })
@Index({ properties: ['restaurant', 'enabled'] })
@Index({ properties: ['restaurant'] })
export class PaymentMethod extends BaseEntity {
  @ManyToOne(() => Restaurant)
  restaurant!: Restaurant;

  @Enum(() => PaymentMethodEnum)
  method!: PaymentMethodEnum;

  @Enum(() => PaymentGatewayEnum)
  gateway: PaymentGatewayEnum | null = null;

  @Property({ nullable: true })
  description?: string;

  @Property({ default: true })
  enabled: boolean = true;

  @Property({ type: 'integer', default: 0 })
  order: number = 0;

  @Property({ nullable: true })
  merchantId?: string;
}
