init
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { Column, CreateDateColumn, Entity, OneToMany, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { ColumnBigIntTransformer } from '../../../utils/ColumnBigIntTransformer';
|
||||
import { ColumnNumericTransformer } from '../../../utils/ColumnNumericTransformer';
|
||||
import { PaymentMethod } from '../types/PaymentMethod';
|
||||
import { InvoiceReason } from '../types/InvoiceReason';
|
||||
import { InvoiceMoneroDetails } from './InvoiceMoneroDetails';
|
||||
import { InvoicePayment } from './InvoicePayment';
|
||||
|
||||
@Entity('invoices')
|
||||
export class Invoice {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({ type: 'enum', enum: InvoiceReason })
|
||||
reason: InvoiceReason;
|
||||
|
||||
@Column({ type: 'enum', enum: PaymentMethod })
|
||||
paymentMethod: PaymentMethod;
|
||||
|
||||
@Column({
|
||||
type: 'numeric',
|
||||
precision: 12,
|
||||
scale: 2,
|
||||
transformer: new ColumnNumericTransformer()
|
||||
})
|
||||
amountFiat: number;
|
||||
|
||||
@Column({ length: 3 })
|
||||
fiatCurrency: string;
|
||||
|
||||
@Column({ type: 'timestamptz' })
|
||||
expiresAt: Date;
|
||||
|
||||
@Column({ type: 'varchar', length: 255, unique: true })
|
||||
paymentAddress: string;
|
||||
|
||||
@Column({ type: 'bigint', transformer: new ColumnBigIntTransformer() })
|
||||
expectedTotalAtomic: string;
|
||||
|
||||
@OneToMany(() => InvoicePayment, payment => payment.invoice, { cascade: true })
|
||||
payments: InvoicePayment[];
|
||||
|
||||
@OneToOne(() => InvoiceMoneroDetails, moneroDetails => moneroDetails.invoice, { cascade: true })
|
||||
moneroDetails: InvoiceMoneroDetails | null;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
}
|
||||
Reference in New Issue
Block a user