mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into fix_send_more_then_half_via_link
This commit is contained in:
commit
cbd7cc6ab9
@ -4,4 +4,6 @@ export interface CreationInterface {
|
||||
memo: string
|
||||
creationDate: string
|
||||
confirmed?: boolean
|
||||
// number of months to move the confirmed creation to the past
|
||||
moveCreationDate?: number
|
||||
}
|
||||
|
||||
@ -1,29 +1,28 @@
|
||||
import { CreationInterface } from './CreationInterface'
|
||||
|
||||
const lastMonth = (date: Date): string => {
|
||||
return new Date(date.getFullYear(), date.getMonth() - 1, 1).toISOString()
|
||||
}
|
||||
import { nMonthsBefore } from '../factory/creation'
|
||||
|
||||
export const creations: CreationInterface[] = [
|
||||
{
|
||||
email: 'bibi@bloxberg.de',
|
||||
amount: 1000,
|
||||
memo: 'Herzlich Willkommen bei Gradido!',
|
||||
creationDate: lastMonth(new Date()),
|
||||
creationDate: nMonthsBefore(new Date()),
|
||||
confirmed: true,
|
||||
moveCreationDate: 12,
|
||||
},
|
||||
{
|
||||
email: 'bob@baumeister.de',
|
||||
amount: 1000,
|
||||
memo: 'Herzlich Willkommen bei Gradido!',
|
||||
creationDate: lastMonth(new Date()),
|
||||
creationDate: nMonthsBefore(new Date()),
|
||||
confirmed: true,
|
||||
moveCreationDate: 8,
|
||||
},
|
||||
{
|
||||
email: 'raeuber@hotzenplotz.de',
|
||||
amount: 1000,
|
||||
memo: 'Herzlich Willkommen bei Gradido!',
|
||||
creationDate: lastMonth(new Date()),
|
||||
creationDate: nMonthsBefore(new Date()),
|
||||
confirmed: true,
|
||||
},
|
||||
]
|
||||
|
||||
@ -6,9 +6,14 @@ import { login } from '@/seeds/graphql/queries'
|
||||
import { CreationInterface } from '@/seeds/creation/CreationInterface'
|
||||
import { ApolloServerTestClient } from 'apollo-server-testing'
|
||||
import { User } from '@entity/User'
|
||||
import { Transaction } from '@entity/Transaction'
|
||||
import { AdminPendingCreation } from '@entity/AdminPendingCreation'
|
||||
// import CONFIG from '@/config/index'
|
||||
|
||||
export const nMonthsBefore = (date: Date, months = 1): string => {
|
||||
return new Date(date.getFullYear(), date.getMonth() - months, 1).toISOString()
|
||||
}
|
||||
|
||||
export const creationFactory = async (
|
||||
client: ApolloServerTestClient,
|
||||
creation: CreationInterface,
|
||||
@ -34,5 +39,21 @@ export const creationFactory = async (
|
||||
})
|
||||
|
||||
await mutate({ mutation: confirmPendingCreation, variables: { id: pendingCreation.id } })
|
||||
|
||||
if (creation.moveCreationDate) {
|
||||
const transaction = await Transaction.findOneOrFail({
|
||||
where: { userId: user.id, creationDate: new Date(creation.creationDate) },
|
||||
order: { balanceDate: 'DESC' },
|
||||
})
|
||||
if (transaction.decay.equals(0) && transaction.creationDate) {
|
||||
transaction.creationDate = new Date(
|
||||
nMonthsBefore(transaction.creationDate, creation.moveCreationDate),
|
||||
)
|
||||
transaction.balanceDate = new Date(
|
||||
nMonthsBefore(transaction.balanceDate, creation.moveCreationDate),
|
||||
)
|
||||
await transaction.save()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,8 +155,6 @@ describe('Send', () => {
|
||||
})
|
||||
})
|
||||
|
||||
/* LINK */
|
||||
|
||||
describe('transaction form link', () => {
|
||||
beforeEach(async () => {
|
||||
apolloMutationMock.mockResolvedValue({
|
||||
@ -261,7 +259,7 @@ describe('Send', () => {
|
||||
})
|
||||
|
||||
it('toasts an error message', () => {
|
||||
expect(toastErrorSpy).toBeCalledWith({ message: 'OUCH!' })
|
||||
expect(toastErrorSpy).toBeCalledWith('OUCH!')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -133,8 +133,8 @@ export default {
|
||||
this.transactionData = { ...EMPTY_TRANSACTION_DATA }
|
||||
this.currentTransactionStep = TRANSACTION_STEPS.transactionResultSendSuccess
|
||||
})
|
||||
.catch((err) => {
|
||||
this.errorResult = err.message
|
||||
.catch((error) => {
|
||||
this.errorResult = error.message
|
||||
this.error = true
|
||||
this.currentTransactionStep = TRANSACTION_STEPS.transactionResultSendError
|
||||
})
|
||||
@ -153,7 +153,7 @@ export default {
|
||||
this.updateTransactions({})
|
||||
})
|
||||
.catch((error) => {
|
||||
this.toastError(error)
|
||||
this.toastError(error.message)
|
||||
})
|
||||
break
|
||||
default:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user