Merge pull request #1550 from gradido/adminarea-creation-transactionlist-show

Adminarea creation transactionlist show
This commit is contained in:
Alexander Friedland 2022-03-07 16:36:48 +01:00 committed by GitHub
commit ef3a0ea9be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 64 deletions

View File

@ -9,41 +9,25 @@ const apolloQueryMock = jest.fn().mockResolvedValue({
transactionList: { transactionList: {
transactions: [ transactions: [
{ {
type: 'creation', id: 1,
balance: 100, amount: 100,
decayStart: 0, balanceDate: 0,
decayEnd: 0, creationDate: new Date(),
decayDuration: 0,
memo: 'Testing', memo: 'Testing',
transactionId: 1, linkedUser: {
name: 'Gradido Akademie', firstName: 'Gradido',
email: 'bibi@bloxberg.de', lastName: 'Akademie',
date: new Date(),
decay: {
balance: 0.01,
decayStart: 0,
decayEnd: 0,
decayDuration: 0,
decayStartBlock: 0,
}, },
}, },
{ {
type: 'creation', id: 2,
balance: 200, amount: 200,
decayStart: 0, balanceDate: 0,
decayEnd: 0, creationDate: new Date(),
decayDuration: 0,
memo: 'Testing 2', memo: 'Testing 2',
transactionId: 2, linkedUser: {
name: 'Gradido Akademie', firstName: 'Gradido',
email: 'bibi@bloxberg.de', lastName: 'Akademie',
date: new Date(),
decay: {
balance: 0.01,
decayStart: 0,
decayEnd: 0,
decayDuration: 0,
decayStartBlock: 0,
}, },
}, },
], ],

View File

@ -15,30 +15,32 @@ export default {
return { return {
fields: [ fields: [
{ {
key: 'date', key: 'creationDate',
label: this.$t('transactionlist.date'), label: this.$t('transactionlist.date'),
formatter: (value, key, item) => { formatter: (value, key, item) => {
return this.$d(new Date(value)) return this.$d(new Date(value))
}, },
}, },
{ {
key: 'balance', key: 'amount',
label: this.$t('transactionlist.amount'), label: this.$t('transactionlist.amount'),
formatter: (value, key, item) => { formatter: (value, key, item) => {
return `${value} GDD` return `${value} GDD`
}, },
}, },
{ key: 'name', label: this.$t('transactionlist.community') }, {
key: 'linkedUser',
label: this.$t('transactionlist.community'),
formatter: (value, key, item) => {
return `${value.firstName} ${value.lastName}`
},
},
{ key: 'memo', label: this.$t('transactionlist.memo') }, { key: 'memo', label: this.$t('transactionlist.memo') },
{ {
key: 'decay', key: 'balanceDate',
label: this.$t('transactionlist.decay'), label: this.$t('transactionlist.balanceDate'),
formatter: (value, key, item) => { formatter: (value, key, item) => {
if (value && value.balance >= 0) { return this.$d(new Date(value))
return value.balance
} else {
return '0'
}
}, },
}, },
], ],
@ -59,7 +61,7 @@ export default {
}, },
}) })
.then((result) => { .then((result) => {
this.items = result.data.transactionList.transactions.filter((t) => t.type === 'creation') this.items = result.data.transactionList.transactions
}) })
.catch((error) => { .catch((error) => {
this.toastError(error.message) this.toastError(error.message)

View File

@ -15,28 +15,15 @@ export const transactionList = gql`
onlyCreations: $onlyCreations onlyCreations: $onlyCreations
userId: $userId userId: $userId
) { ) {
gdtSum
count
balance
decay
decayDate
transactions { transactions {
type id
balance amount
decayStart balanceDate
decayEnd creationDate
decayDuration
memo memo
transactionId linkedUser {
name firstName
email lastName
date
decay {
balance
decayStart
decayEnd
decayDuration
decayStartBlock
} }
} }
} }

View File

@ -75,6 +75,7 @@
"transaction": "Transaktion", "transaction": "Transaktion",
"transactionlist": { "transactionlist": {
"amount": "Betrag", "amount": "Betrag",
"balanceDate": "Schöpfungsdatum",
"community": "Gemeinschaft", "community": "Gemeinschaft",
"date": "Datum", "date": "Datum",
"decay": "Vergänglichkeit", "decay": "Vergänglichkeit",

View File

@ -75,6 +75,7 @@
"transaction": "Transaction", "transaction": "Transaction",
"transactionlist": { "transactionlist": {
"amount": "Amount", "amount": "Amount",
"balanceDate": "Creation date",
"community": "Community", "community": "Community",
"date": "Date", "date": "Date",
"decay": "Decay", "decay": "Decay",

View File

@ -112,7 +112,7 @@ export class TransactionResolver {
const transactions: Transaction[] = [] const transactions: Transaction[] = []
// decay transaction // decay transaction
if (currentPage === 1 && order === Order.DESC) { if (!onlyCreations && currentPage === 1 && order === Order.DESC) {
transactions.push( transactions.push(
virtualDecayTransaction(lastTransaction.balance, lastTransaction.balanceDate, now, self), virtualDecayTransaction(lastTransaction.balance, lastTransaction.balanceDate, now, self),
) )

View File

@ -15,8 +15,8 @@ export class TransactionRepository extends Repository<Transaction> {
if (onlyCreation) { if (onlyCreation) {
return this.createQueryBuilder('userTransaction') return this.createQueryBuilder('userTransaction')
.where('userTransaction.userId = :userId', { userId }) .where('userTransaction.userId = :userId', { userId })
.andWhere('userTransaction.transactionTypeId = :transactionTypeId', { .andWhere('userTransaction.typeId = :typeId', {
transactionTypeId: TransactionTypeId.CREATION, typeId: TransactionTypeId.CREATION,
}) })
.orderBy('userTransaction.balanceDate', order) .orderBy('userTransaction.balanceDate', order)
.limit(limit) .limit(limit)