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