mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Update creations of a user only if the old pending creation has the same month as the updated month. Throw exception before end of file.
This commit is contained in:
parent
e4900e03a5
commit
6c81673a4b
@ -122,28 +122,27 @@ export class AdminResolver {
|
||||
|
||||
const creationDateObj = new Date(creationDate)
|
||||
let creations = await getUserCreations(user.id)
|
||||
creations = updateCreations(creations, pendingCreationToUpdate)
|
||||
if (pendingCreationToUpdate.date.getMonth() === creationDateObj.getMonth()) {
|
||||
creations = updateCreations(creations, pendingCreationToUpdate)
|
||||
}
|
||||
|
||||
if (isCreationValid(creations, amount, creationDateObj)) {
|
||||
// TODO Check if open creation (of creationDate) + amount * 10000 <= 1000
|
||||
|
||||
pendingCreationToUpdate.amount = BigInt(amount * 10000)
|
||||
pendingCreationToUpdate.memo = memo
|
||||
pendingCreationToUpdate.date = new Date(creationDate)
|
||||
pendingCreationToUpdate.moderator = moderator
|
||||
|
||||
await loginPendingTasksAdminRepository.save(pendingCreationToUpdate)
|
||||
const result = new UpdatePendingCreation()
|
||||
result.amount = parseInt(amount.toString())
|
||||
result.memo = pendingCreationToUpdate.memo
|
||||
result.date = pendingCreationToUpdate.date
|
||||
result.moderator = pendingCreationToUpdate.moderator
|
||||
result.creation = await getUserCreations(user.id)
|
||||
|
||||
return result
|
||||
} else {
|
||||
if (!isCreationValid(creations, amount, creationDateObj)) {
|
||||
throw new Error('Creation is not valid')
|
||||
}
|
||||
pendingCreationToUpdate.amount = BigInt(amount * 10000)
|
||||
pendingCreationToUpdate.memo = memo
|
||||
pendingCreationToUpdate.date = new Date(creationDate)
|
||||
pendingCreationToUpdate.moderator = moderator
|
||||
|
||||
await loginPendingTasksAdminRepository.save(pendingCreationToUpdate)
|
||||
const result = new UpdatePendingCreation()
|
||||
result.amount = parseInt(amount.toString())
|
||||
result.memo = pendingCreationToUpdate.memo
|
||||
result.date = pendingCreationToUpdate.date
|
||||
result.moderator = pendingCreationToUpdate.moderator
|
||||
result.creation = await getUserCreations(user.id)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@Authorized([RIGHTS.SEARCH_PENDING_CREATION])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user