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