Files
dsc-api/src/modules/wallets/entities/transaction.entity.ts
T
2025-02-26 20:15:16 +03:30

27 lines
972 B
TypeScript
Executable File

// eslint-disable-next-line import/no-named-as-default
import Decimal from "decimal.js";
import { Column, Entity, ManyToOne } from "typeorm";
import { Wallet } from "./wallet.entity";
import { BaseEntity } from "../../../common/entities/base.entity";
import { DecimalTransformer } from "../../../common/transformers/decimal.transformer";
import { TransactionType } from "../enums/transaction-type.enum";
@Entity()
export class WalletTransaction extends BaseEntity {
@Column({ type: "int", generated: "identity", insert: false })
numericId: number;
@ManyToOne(() => Wallet, (wallet) => wallet.transactions, { onDelete: "CASCADE", nullable: false })
wallet: Wallet;
@Column({ type: "decimal", precision: 16, scale: 2, nullable: false, transformer: new DecimalTransformer() })
amount: Decimal;
@Column({ type: "enum", enum: TransactionType, nullable: false })
type: TransactionType;
@Column({ type: "text", nullable: false })
description: string;
}