mirror of
https://github.com/IT4Change/gradido.git
synced 2026-01-15 17:34:31 +00:00
25 lines
913 B
TypeScript
25 lines
913 B
TypeScript
import Faker from 'faker'
|
|
import { define } from 'typeorm-seeding'
|
|
import { Transaction } from '../../entity/Transaction'
|
|
import { TransactionContext } from '../interface/TransactionContext'
|
|
import Decimal from 'decimal.js-light'
|
|
|
|
define(Transaction, (faker: typeof Faker, context?: TransactionContext) => {
|
|
if (!context) {
|
|
throw new Error('TransactionContext not well defined.')
|
|
}
|
|
|
|
const transaction = new Transaction()
|
|
transaction.typeId = context.typeId // || 2
|
|
transaction.userId = context.userId
|
|
transaction.amount = context.amount
|
|
transaction.balance = context.balance
|
|
transaction.decay = new Decimal(0) // context.decay
|
|
transaction.memo = context.memo
|
|
transaction.creationDate = context.creationDate || new Date()
|
|
// transaction.sendReceiverPublicKey = context.sendReceiverPublicKey || null
|
|
transaction.linkedUserId = context.sendReceiverUserId || null
|
|
|
|
return transaction
|
|
})
|