mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into 1165-refactor-admin-interface
This commit is contained in:
commit
fedd1d626d
@ -212,95 +212,80 @@ export class AdminResolver {
|
||||
|
||||
async function getUserCreations(id: number): Promise<number[]> {
|
||||
const dateNextMonth = moment().add(1, 'month').format('YYYY-MM') + '-01'
|
||||
const dateMonth = moment().format('YYYY-MM') + '-01'
|
||||
const dateLastMonth = moment().subtract(1, 'month').format('YYYY-MM') + '-01'
|
||||
const dateBeforeLastMonth = moment().subtract(2, 'month').format('YYYY-MM') + '-01'
|
||||
const beforeLastMonthNumber = moment().subtract(2, 'month').format('M')
|
||||
const lastMonthNumber = moment().subtract(1, 'month').format('M')
|
||||
const currentMonthNumber = moment().format('M')
|
||||
|
||||
const transactionCreationRepository = getCustomRepository(TransactionCreationRepository)
|
||||
const createdAmountBeforeLastMonth = await transactionCreationRepository
|
||||
const createdAmountsQuery = await transactionCreationRepository
|
||||
.createQueryBuilder('transaction_creations')
|
||||
.select('SUM(transaction_creations.amount)', 'sum')
|
||||
.select('MONTH(transaction_creations.target_date)', 'target_month')
|
||||
.addSelect('SUM(transaction_creations.amount)', 'sum')
|
||||
.where('transaction_creations.state_user_id = :id', { id })
|
||||
.andWhere({
|
||||
targetDate: Raw((alias) => `${alias} >= :date and ${alias} < :enddate`, {
|
||||
targetDate: Raw((alias) => `${alias} >= :date and ${alias} < :endDate`, {
|
||||
date: dateBeforeLastMonth,
|
||||
enddate: dateLastMonth,
|
||||
endDate: dateNextMonth,
|
||||
}),
|
||||
})
|
||||
.getRawOne()
|
||||
|
||||
const createdAmountLastMonth = await transactionCreationRepository
|
||||
.createQueryBuilder('transaction_creations')
|
||||
.select('SUM(transaction_creations.amount)', 'sum')
|
||||
.where('transaction_creations.state_user_id = :id', { id })
|
||||
.andWhere({
|
||||
targetDate: Raw((alias) => `${alias} >= :date and ${alias} < :enddate`, {
|
||||
date: dateLastMonth,
|
||||
enddate: dateMonth,
|
||||
}),
|
||||
})
|
||||
.getRawOne()
|
||||
|
||||
const createdAmountMonth = await transactionCreationRepository
|
||||
.createQueryBuilder('transaction_creations')
|
||||
.select('SUM(transaction_creations.amount)', 'sum')
|
||||
.where('transaction_creations.state_user_id = :id', { id })
|
||||
.andWhere({
|
||||
targetDate: Raw((alias) => `${alias} >= :date and ${alias} < :enddate`, {
|
||||
date: dateMonth,
|
||||
enddate: dateNextMonth,
|
||||
}),
|
||||
})
|
||||
.getRawOne()
|
||||
.groupBy('target_month')
|
||||
.orderBy('target_month', 'ASC')
|
||||
.getRawMany()
|
||||
|
||||
const loginPendingTasksAdminRepository = getCustomRepository(LoginPendingTasksAdminRepository)
|
||||
const pendingAmountMounth = await loginPendingTasksAdminRepository
|
||||
const pendingAmountsQuery = await loginPendingTasksAdminRepository
|
||||
.createQueryBuilder('login_pending_tasks_admin')
|
||||
.select('SUM(login_pending_tasks_admin.amount)', 'sum')
|
||||
.select('MONTH(login_pending_tasks_admin.date)', 'target_month')
|
||||
.addSelect('SUM(login_pending_tasks_admin.amount)', 'sum')
|
||||
.where('login_pending_tasks_admin.userId = :id', { id })
|
||||
.andWhere({
|
||||
date: Raw((alias) => `${alias} >= :date and ${alias} < :enddate`, {
|
||||
date: dateMonth,
|
||||
enddate: dateNextMonth,
|
||||
}),
|
||||
})
|
||||
.getRawOne()
|
||||
|
||||
const pendingAmountLastMounth = await loginPendingTasksAdminRepository
|
||||
.createQueryBuilder('login_pending_tasks_admin')
|
||||
.select('SUM(login_pending_tasks_admin.amount)', 'sum')
|
||||
.where('login_pending_tasks_admin.userId = :id', { id })
|
||||
.andWhere({
|
||||
date: Raw((alias) => `${alias} >= :date and ${alias} < :enddate`, {
|
||||
date: dateLastMonth,
|
||||
enddate: dateMonth,
|
||||
}),
|
||||
})
|
||||
.getRawOne()
|
||||
|
||||
const pendingAmountBeforeLastMounth = await loginPendingTasksAdminRepository
|
||||
.createQueryBuilder('login_pending_tasks_admin')
|
||||
.select('SUM(login_pending_tasks_admin.amount)', 'sum')
|
||||
.where('login_pending_tasks_admin.userId = :id', { id })
|
||||
.andWhere({
|
||||
date: Raw((alias) => `${alias} >= :date and ${alias} < :enddate`, {
|
||||
date: Raw((alias) => `${alias} >= :date and ${alias} < :endDate`, {
|
||||
date: dateBeforeLastMonth,
|
||||
enddate: dateLastMonth,
|
||||
endDate: dateNextMonth,
|
||||
}),
|
||||
})
|
||||
.getRawOne()
|
||||
.groupBy('target_month')
|
||||
.orderBy('target_month', 'ASC')
|
||||
.getRawMany()
|
||||
|
||||
const map = new Map()
|
||||
if (Array.isArray(createdAmountsQuery) && createdAmountsQuery.length > 0) {
|
||||
createdAmountsQuery.forEach((createdAmount) => {
|
||||
if (!map.has(createdAmount.target_month)) {
|
||||
map.set(createdAmount.target_month, createdAmount.sum)
|
||||
} else {
|
||||
const store = map.get(createdAmount.target_month)
|
||||
map.set(createdAmount.target_month, Number(store) + Number(createdAmount.sum))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (Array.isArray(pendingAmountsQuery) && pendingAmountsQuery.length > 0) {
|
||||
pendingAmountsQuery.forEach((pendingAmount) => {
|
||||
if (!map.has(pendingAmount.target_month)) {
|
||||
map.set(pendingAmount.target_month, pendingAmount.sum)
|
||||
} else {
|
||||
const store = map.get(pendingAmount.target_month)
|
||||
map.set(pendingAmount.target_month, Number(store) + Number(pendingAmount.sum))
|
||||
}
|
||||
})
|
||||
}
|
||||
const usedCreationBeforeLastMonth = map.get(Number(beforeLastMonthNumber))
|
||||
? Number(map.get(Number(beforeLastMonthNumber))) / 10000
|
||||
: 0
|
||||
const usedCreationLastMonth = map.get(Number(lastMonthNumber))
|
||||
? Number(map.get(Number(lastMonthNumber))) / 10000
|
||||
: 0
|
||||
|
||||
const usedCreationCurrentMonth = map.get(Number(currentMonthNumber))
|
||||
? Number(map.get(Number(currentMonthNumber))) / 10000
|
||||
: 0
|
||||
|
||||
// COUNT amount from 2 tables
|
||||
const usedCreationBeforeLastMonth =
|
||||
(Number(createdAmountBeforeLastMonth.sum) + Number(pendingAmountBeforeLastMounth.sum)) / 10000
|
||||
const usedCreationLastMonth =
|
||||
(Number(createdAmountLastMonth.sum) + Number(pendingAmountLastMounth.sum)) / 10000
|
||||
const usedCreationMonth =
|
||||
(Number(createdAmountMonth.sum) + Number(pendingAmountMounth.sum)) / 10000
|
||||
return [
|
||||
1000 - usedCreationBeforeLastMonth,
|
||||
1000 - usedCreationLastMonth,
|
||||
1000 - usedCreationMonth,
|
||||
1000 - usedCreationCurrentMonth,
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@ -45,9 +45,11 @@
|
||||
},
|
||||
"error": {
|
||||
"change-password": "Fehler beim Ändern des Passworts",
|
||||
"empty-transactionlist": "Es gab einen Fehler mit der Übermittlung der Anzahl deiner Transaktionen.",
|
||||
"error": "Fehler",
|
||||
"no-account": "Leider konnten wir keinen Account finden mit diesen Daten!",
|
||||
"no-email-verify": "Die Email wurde noch nicht bestätigt, bitte überprüfe deine Emails und klicke auf den Aktivierungslink!",
|
||||
"no-transactionlist": "Es gab leider einen Fehler. Es wurden keine Transaktionen vom Server übermittelt",
|
||||
"session-expired": "Die Sitzung wurde aus Sicherheitsgründen beendet."
|
||||
},
|
||||
"form": {
|
||||
|
||||
@ -45,9 +45,11 @@
|
||||
},
|
||||
"error": {
|
||||
"change-password": "Error while changing password",
|
||||
"empty-transactionlist": "There was an error with the transmission of the number of your transactions.",
|
||||
"error": "Error",
|
||||
"no-account": "Unfortunately we could not find an account to the given data!",
|
||||
"no-email-verify": "Your email is not activated yet, please check your emails and click the activation link!",
|
||||
"no-transactionlist": "Unfortunately, there was an error. No transactions have been sent from the server.",
|
||||
"session-expired": "The session was closed for security reasons."
|
||||
},
|
||||
"form": {
|
||||
|
||||
@ -36,9 +36,42 @@ describe('GddTransactionList', () => {
|
||||
expect(wrapper.find('div.gdd-transaction-list').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
describe('no transactions from server', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.setProps({
|
||||
transactions: false,
|
||||
})
|
||||
})
|
||||
it('shows error no transaction list', () => {
|
||||
expect(wrapper.find('div.test-no-transactionlist').text()).toContain(
|
||||
'error.no-transactionlist',
|
||||
)
|
||||
})
|
||||
})
|
||||
describe('0 transactions from server', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.setProps({
|
||||
transactions: [],
|
||||
transactionCount: 0,
|
||||
})
|
||||
})
|
||||
it('Transactions Array is empty, 0 transactions', () => {
|
||||
expect(wrapper.find('div.test-empty-transactionlist').text()).toContain(
|
||||
'error.empty-transactionlist',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('without any properties', () => {
|
||||
it('renders text saying that there are no transactions', () => {
|
||||
expect(wrapper.find('div.gdd-transaction-list').text()).toBe('transaction.nullTransactions')
|
||||
it('renders text saying that there are error.empty-transactionlist ', () => {
|
||||
expect(wrapper.find('div.gdd-transaction-list').text()).toContain(
|
||||
'error.empty-transactionlist',
|
||||
)
|
||||
})
|
||||
it('renders text saying that there are no transaction.nullTransactions', () => {
|
||||
expect(wrapper.find('div.gdd-transaction-list').text()).toContain(
|
||||
'transaction.nullTransactions',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@ -1,6 +1,16 @@
|
||||
<template>
|
||||
<div class="gdd-transaction-list">
|
||||
<div class="list-group">
|
||||
<div v-if="!transactions" class="test-no-transactionlist text-right">
|
||||
<b-icon icon="exclamation-triangle" class="mr-2" style="color: red"></b-icon>
|
||||
<small>
|
||||
{{ $t('error.no-transactionlist') }}
|
||||
</small>
|
||||
</div>
|
||||
<div v-if="!transactionCount" class="test-empty-transactionlist text-right">
|
||||
<b-icon icon="exclamation-triangle" class="mr-2" style="color: red"></b-icon>
|
||||
<small>{{ $t('error.empty-transactionlist') }}</small>
|
||||
</div>
|
||||
<div
|
||||
v-for="{ decay, transactionId, type, date, balance, name, memo } in transactions"
|
||||
:key="transactionId"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user