import { Entity, Index, Property, ManyToOne, Enum } from '@mikro-orm/core'; import { BaseEntity } from '../../../../common/entities/base.entity'; import { User } from './user.entity'; import { WalletTransactionReason, WalletTransactionType } from '../interface/wallet'; import { Shop } from ../../../shops/entities/shop.entity'; @Entity({ tableName: 'wallet_transactions' }) @Index({ properties: ['user', 'shop'] }) @Index({ properties: ['user'] }) @Index({ properties: ['shop'] }) export class WalletTransaction extends BaseEntity { @ManyToOne(() => User) user!: User; @ManyToOne(() => Shop) shop!: Shop; @Property({ type: 'decimal', precision: 10, scale: 0 }) amount!: number; @Property({ type: 'decimal', precision: 10, scale: 0 }) balance!: number; @Enum(() => WalletTransactionType) type!: WalletTransactionType; @Enum(() => WalletTransactionReason) reason!: WalletTransactionReason; }