mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into consistent-user-contacts-table
This commit is contained in:
commit
c8fa84ac11
@ -42,7 +42,9 @@ export class Transaction {
|
||||
this.creationDate = transaction.creationDate
|
||||
this.linkedUser = linkedUser
|
||||
this.linkedTransactionId = transaction.linkedTransactionId
|
||||
this.transactionLinkId = transaction.transactionLinkId
|
||||
this.linkId = transaction.contribution
|
||||
? transaction.contribution.contributionLinkId
|
||||
: transaction.transactionLinkId
|
||||
}
|
||||
|
||||
@Field(() => Number)
|
||||
@ -81,7 +83,7 @@ export class Transaction {
|
||||
@Field(() => Number, { nullable: true })
|
||||
linkedTransactionId?: number | null
|
||||
|
||||
// Links to the TransactionLink when transaction was created by a link
|
||||
// Links to the TransactionLink/ContributionLink when transaction was created by a link
|
||||
@Field(() => Number, { nullable: true })
|
||||
transactionLinkId?: number | null
|
||||
linkId?: number | null
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ export class TransactionResolver {
|
||||
// find current balance
|
||||
const lastTransaction = await dbTransaction.findOne(
|
||||
{ userId: user.id },
|
||||
{ order: { balanceDate: 'DESC' } },
|
||||
{ order: { balanceDate: 'DESC' }, relations: ['contribution'] },
|
||||
)
|
||||
logger.debug(`lastTransaction=${lastTransaction}`)
|
||||
|
||||
@ -328,7 +328,6 @@ export class TransactionResolver {
|
||||
|
||||
// validate recipient user
|
||||
const recipientUser = await findUserByEmail(email)
|
||||
|
||||
if (recipientUser.deletedAt) {
|
||||
logger.error(`The recipient account was deleted: recipientUser=${recipientUser}`)
|
||||
throw new Error('The recipient account was deleted')
|
||||
|
||||
@ -12,29 +12,24 @@ export class TransactionRepository extends Repository<Transaction> {
|
||||
order: Order,
|
||||
onlyCreation?: boolean,
|
||||
): Promise<[Transaction[], number]> {
|
||||
if (onlyCreation) {
|
||||
return this.createQueryBuilder('userTransaction')
|
||||
const query = this.createQueryBuilder('userTransaction')
|
||||
.leftJoinAndSelect(
|
||||
'userTransaction.contribution',
|
||||
'contribution',
|
||||
'userTransaction.id = contribution.transactionId',
|
||||
)
|
||||
.where('userTransaction.userId = :userId', { userId })
|
||||
.andWhere('userTransaction.typeId = :typeId', {
|
||||
|
||||
if (onlyCreation) {
|
||||
query.andWhere('userTransaction.typeId = :typeId', {
|
||||
typeId: TransactionTypeId.CREATION,
|
||||
})
|
||||
.orderBy('userTransaction.balanceDate', order)
|
||||
.limit(limit)
|
||||
.offset(offset)
|
||||
.getManyAndCount()
|
||||
}
|
||||
return this.createQueryBuilder('userTransaction')
|
||||
.where('userTransaction.userId = :userId', { userId })
|
||||
.orderBy('userTransaction.balanceDate', order)
|
||||
.limit(limit)
|
||||
.offset(offset)
|
||||
.getManyAndCount()
|
||||
}
|
||||
|
||||
findLastForUser(userId: number): Promise<Transaction | undefined> {
|
||||
return this.createQueryBuilder('userTransaction')
|
||||
.where('userTransaction.userId = :userId', { userId })
|
||||
.orderBy('userTransaction.balanceDate', 'DESC')
|
||||
.getOne()
|
||||
return query
|
||||
.orderBy('userTransaction.balanceDate', order)
|
||||
.limit(limit)
|
||||
.offset(offset)
|
||||
.getManyAndCount()
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,6 +49,7 @@ const virtualLinkTransaction = (
|
||||
decay: decay.toDecimalPlaces(2, Decimal.ROUND_FLOOR),
|
||||
memo: '',
|
||||
creationDate: null,
|
||||
contribution: null,
|
||||
...defaultModelFunctions,
|
||||
}
|
||||
return new Transaction(linkDbTransaction, user)
|
||||
@ -78,6 +79,7 @@ const virtualDecayTransaction = (
|
||||
decayStart: decay.start,
|
||||
memo: '',
|
||||
creationDate: null,
|
||||
contribution: null,
|
||||
...defaultModelFunctions,
|
||||
}
|
||||
return new Transaction(decayDbTransaction, user)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import Decimal from 'decimal.js-light'
|
||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm'
|
||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToOne, JoinColumn } from 'typeorm'
|
||||
import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer'
|
||||
import { Contribution } from '../Contribution'
|
||||
|
||||
@Entity('transactions')
|
||||
export class Transaction extends BaseEntity {
|
||||
@ -91,4 +92,8 @@ export class Transaction extends BaseEntity {
|
||||
default: null,
|
||||
})
|
||||
transactionLinkId?: number | null
|
||||
|
||||
@OneToOne(() => Contribution, (contribution) => contribution.transaction)
|
||||
@JoinColumn({ name: 'id', referencedColumnName: 'transactionId' })
|
||||
contribution?: Contribution | null
|
||||
}
|
||||
|
||||
@ -8,10 +8,12 @@ import {
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
OneToOne,
|
||||
} from 'typeorm'
|
||||
import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer'
|
||||
import { User } from '../User'
|
||||
import { ContributionMessage } from '../ContributionMessage'
|
||||
import { Transaction } from '../Transaction'
|
||||
|
||||
@Entity('contributions')
|
||||
export class Contribution extends BaseEntity {
|
||||
@ -92,4 +94,8 @@ export class Contribution extends BaseEntity {
|
||||
@OneToMany(() => ContributionMessage, (message) => message.contribution)
|
||||
@JoinColumn({ name: 'contribution_id' })
|
||||
messages?: ContributionMessage[]
|
||||
|
||||
@OneToOne(() => Transaction, (transaction) => transaction.contribution)
|
||||
@JoinColumn({ name: 'transaction_id' })
|
||||
transaction?: Transaction | null
|
||||
}
|
||||
|
||||
@ -10,11 +10,13 @@
|
||||
</b-col>
|
||||
<b-col cols="7">
|
||||
<div class="gdd-transaction-list-item-name">
|
||||
<div v-if="linkedUser && linkedUser.email">
|
||||
<span v-if="linkedUser && linkedUser.email">
|
||||
<b-link @click.stop="tunnelEmail">
|
||||
{{ itemText }}
|
||||
</b-link>
|
||||
<span v-if="transactionLinkId">
|
||||
</span>
|
||||
<span v-else>{{ itemText }}</span>
|
||||
<span v-if="linkId">
|
||||
{{ $t('via_link') }}
|
||||
<b-icon
|
||||
icon="link45deg"
|
||||
@ -24,8 +26,6 @@
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
<span v-else>{{ itemText }}</span>
|
||||
</div>
|
||||
</b-col>
|
||||
</b-row>
|
||||
</div>
|
||||
@ -46,7 +46,7 @@ export default {
|
||||
type: String,
|
||||
required: false,
|
||||
},
|
||||
transactionLinkId: {
|
||||
linkId: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: null,
|
||||
|
||||
@ -12,7 +12,12 @@
|
||||
|
||||
<b-col cols="11">
|
||||
<!-- Amount / Name || Text -->
|
||||
<amount-and-name-row :amount="amount" :linkedUser="linkedUser" v-on="$listeners" />
|
||||
<amount-and-name-row
|
||||
:amount="amount"
|
||||
:linkedUser="linkedUser"
|
||||
v-on="$listeners"
|
||||
:linkId="linkId"
|
||||
/>
|
||||
|
||||
<!-- Nachricht Memo -->
|
||||
<memo-row :memo="memo" />
|
||||
@ -77,6 +82,10 @@ export default {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
linkId: {
|
||||
type: Number,
|
||||
required: false,
|
||||
},
|
||||
previousBookedBalance: {
|
||||
type: String,
|
||||
required: true,
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
v-on="$listeners"
|
||||
:amount="amount"
|
||||
:linkedUser="linkedUser"
|
||||
:transactionLinkId="transactionLinkId"
|
||||
:linkId="linkId"
|
||||
/>
|
||||
|
||||
<!-- Nachricht Memo -->
|
||||
@ -82,7 +82,7 @@ export default {
|
||||
typeId: {
|
||||
type: String,
|
||||
},
|
||||
transactionLinkId: {
|
||||
linkId: {
|
||||
type: Number,
|
||||
required: false,
|
||||
},
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
v-on="$listeners"
|
||||
:amount="amount"
|
||||
:linkedUser="linkedUser"
|
||||
:transactionLinkId="transactionLinkId"
|
||||
:linkId="linkId"
|
||||
/>
|
||||
|
||||
<!-- Memo -->
|
||||
@ -83,7 +83,7 @@ export default {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
transactionLinkId: {
|
||||
linkId: {
|
||||
type: Number,
|
||||
required: false,
|
||||
},
|
||||
|
||||
@ -45,7 +45,7 @@ export const transactionsQuery = gql`
|
||||
end
|
||||
duration
|
||||
}
|
||||
transactionLinkId
|
||||
linkId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user