fixy
This commit is contained in:
@@ -192,17 +192,26 @@ public class EventService {
|
||||
entity = userAccountRepository.save(entity);
|
||||
accountsByAccountName.put(Account.Skarbiec.name(), entity);
|
||||
}
|
||||
List<UserAccount> accountsToCharge = new ArrayList<>();
|
||||
event
|
||||
List<TransactionItem> itemsToCharge = new ArrayList<>();
|
||||
List<Registration> registrationsToCharge = event
|
||||
.getRegistrations()
|
||||
.forEach(registration -> {
|
||||
.stream()
|
||||
.filter(registration -> !Boolean.FALSE.equals(registration.getActive()))
|
||||
.sorted(Comparator.comparing(Registration::getDateTime))
|
||||
.limit(event.getPlayersLimit() == null ? 10000 : event.getPlayersLimit()) // Ograniczamy do pierwszych n elementów
|
||||
.toList();
|
||||
|
||||
registrationsToCharge.forEach(registration -> {
|
||||
String login = registration.getUser().getLogin();
|
||||
UserAccount userAccount = accountsByLogin.get(login);
|
||||
if (userAccount == null) {
|
||||
userAccount = createNewAccountForLogin(login);
|
||||
accountsByLogin.put(login, userAccount);
|
||||
}
|
||||
accountsToCharge.add(userAccount);
|
||||
TransactionItem transactionForPlayer = new TransactionItem();
|
||||
transactionForPlayer.setRegistration(registration);
|
||||
transactionForPlayer.setUserAccount(userAccount);
|
||||
itemsToCharge.add(transactionForPlayer);
|
||||
});
|
||||
TransactionItem fieldServiceItem = new TransactionItem();
|
||||
fieldServiceItem.setEvent(event);
|
||||
@@ -210,13 +219,11 @@ public class EventService {
|
||||
fieldServiceItem.setUserAccount(accountsByAccountName.get(Account.Boisko.name()));
|
||||
fieldServiceItem.setTransaction(transaction);
|
||||
transaction.getTransactionItems().add(fieldServiceItem);
|
||||
accountsToCharge.forEach(userAccount -> {
|
||||
TransactionItem playerCharge = new TransactionItem();
|
||||
playerCharge.setEvent(event);
|
||||
playerCharge.setAmount(event.getCost().divide(BigDecimal.valueOf(-accountsToCharge.size()), 2, RoundingMode.HALF_UP));
|
||||
playerCharge.setUserAccount(userAccount);
|
||||
playerCharge.setTransaction(transaction);
|
||||
transaction.getTransactionItems().add(playerCharge);
|
||||
itemsToCharge.forEach(transactionForPlayer -> {
|
||||
transactionForPlayer.setEvent(event);
|
||||
transactionForPlayer.setAmount(event.getCost().divide(BigDecimal.valueOf(-itemsToCharge.size()), 2, RoundingMode.HALF_UP));
|
||||
transactionForPlayer.setTransaction(transaction);
|
||||
transaction.getTransactionItems().add(transactionForPlayer);
|
||||
});
|
||||
BigDecimal vaultValue = transaction
|
||||
.getTransactionItems()
|
||||
|
||||
@@ -237,7 +237,8 @@ public class RegistrationResource {
|
||||
throw new AccessDeniedException("Registration is closed for this event");
|
||||
}
|
||||
LOG.debug("REST request to delete Registration : {}", id);
|
||||
registrationRepository.deleteById(id);
|
||||
registration.setActive(Boolean.FALSE);
|
||||
registrationRepository.save(registration);
|
||||
return ResponseEntity.noContent()
|
||||
.headers(HeaderUtil.createEntityDeletionAlert(applicationName, false, ENTITY_NAME, id.toString()))
|
||||
.build();
|
||||
|
||||
@@ -66,15 +66,20 @@
|
||||
<!-- Display row number or empty if not active -->
|
||||
{{ getRegistrationIndex(index) }}
|
||||
</td>
|
||||
<td>{{ formatDateShort(registration.dateTime) || '' }}</td>
|
||||
<td>
|
||||
{{ registration.playerName }}
|
||||
<span :class="{ strikethrough: registration.active === false }">{{ registration.dateTime }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span :class="{ strikethrough: registration.active === false }">{{ registration.playerName }}</span>
|
||||
<b-button
|
||||
@click="prepareRemove(registration)"
|
||||
variant="danger"
|
||||
class="btn btn-sm"
|
||||
data-cy="entityDeleteButton"
|
||||
v-if="(registration.id && registration.user?.id == currentUserId && isCurrentEvent) || hasAnyAuthority('ROLE_ADMIN')"
|
||||
v-if="
|
||||
((registration.id && registration.user?.id == currentUserId && isCurrentEvent) || hasAnyAuthority('ROLE_ADMIN')) &&
|
||||
registration.active !== false
|
||||
"
|
||||
v-b-modal.removeEntity
|
||||
>
|
||||
<font-awesome-icon icon="times"></font-awesome-icon>
|
||||
|
||||
@@ -108,6 +108,7 @@ export default defineComponent({
|
||||
registration.value = res;
|
||||
// Assuming you can retrieve event details here
|
||||
eventName.value = '' + registration.value.event?.name; // Set this from the event details
|
||||
currentUserFullName.value = '' + registration.value.user?.firstName + ' ' + registration.value.user?.lastName;
|
||||
} catch (error) {
|
||||
alertService.showHttpError(error.response);
|
||||
}
|
||||
|
||||
@@ -168,3 +168,8 @@ th.rotate > div {
|
||||
top: 126px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.strikethrough {
|
||||
text-decoration: line-through;
|
||||
color: lightgray;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user