Skip to content

Commit 38a24e1

Browse files
authored
Přenos vstupenky - opravy (#1425)
* select padding * paid_canceled state * do not edit paid applications * padding * confirm improved * cs fix, update * html in confirm --------- Co-authored-by: Jan Staněk <[email protected]>
1 parent b6279a6 commit 38a24e1

File tree

9 files changed

+102
-100
lines changed

9 files changed

+102
-100
lines changed

app/AdminModule/Forms/EditUserTransferFormFactory.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public function create(int $id): Form
5151
->setDisabled(! $this->user->isRegistered() || ! $this->user->hasPaidAnyApplication())
5252
->setHtmlAttribute('class', 'btn btn-danger')
5353
->setHtmlAttribute('data-toggle', 'confirmation')
54-
->setHtmlAttribute('data-content', $this->translator->translate('admin.users.users_transfer_confirm'));
54+
->setHtmlAttribute('data-content', $this->translator->translate('admin.users.users_transfer_confirm'))
55+
->setHtmlAttribute('data-html', 'true');
5556

5657
$form->onSuccess[] = [$this, 'processForm'];
5758

app/Model/Enums/PaymentState.php

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ class PaymentState
1616
*/
1717
public const PAIRED_MANUAL = 'paired_manual';
1818

19+
/**
20+
* Spárovaná přihláška byla zrušena.
21+
*/
22+
public const PAIRED_CANCELED = 'paired_canceled';
23+
1924
/**
2025
* Nespárováno - nesouhlasí poplatek.
2126
*/
@@ -45,6 +50,7 @@ class PaymentState
4550
public static array $states = [
4651
self::PAIRED_AUTO,
4752
self::PAIRED_MANUAL,
53+
self::PAIRED_CANCELED,
4854
self::NOT_PAIRED_FEE,
4955
self::NOT_PAIRED_VS,
5056
self::NOT_PAIRED_CANCELED,

app/Model/Structure/Subevent.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,10 @@ public function countUsers(): int
429429
//
430430
// return $this->applications->matching($criteria)->count();
431431

432-
return $this->applications->filter(static fn (Application $application) => $application->getValidTo() === null && (
433-
$application->getState() === ApplicationState::WAITING_FOR_PAYMENT ||
434-
$application->getState() === ApplicationState::PAID_FREE ||
435-
$application->getState() === ApplicationState::PAID ||
436-
$application->getState() === ApplicationState::PAID_TRANSFERED))->count();
432+
return $this->applications->filter(
433+
static fn (Application $application) => $application->getValidTo() === null && (
434+
$application->getState() === ApplicationState::WAITING_FOR_PAYMENT || $application->isPaid()),
435+
)->count();
437436
}
438437

439438
public function countUnoccupied(): int|null

app/Model/User/User.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -811,11 +811,9 @@ public function getPaidApplications(): Collection
811811
*/
812812
public function getPaidAndTransferedAndFreeApplications(): Collection
813813
{
814-
return $this->applications->filter(static fn (Application $application) => $application->getValidTo() === null && (
815-
$application->getState() === ApplicationState::PAID ||
816-
$application->getState() === ApplicationState::PAID_FREE ||
817-
$application->getState() === ApplicationState::PAID_TRANSFERED
818-
));
814+
return $this->applications->filter(
815+
static fn (Application $application) => $application->getValidTo() === null && $application->isPaid(),
816+
);
819817
}
820818

821819
/**

app/Services/ApplicationService.php

+26-30
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,8 @@ public function cancelRegistration(User $user, string $state, User|null $created
282282

283283
if ($newApplication->getPayment() !== null) {
284284
if ($newApplication->getPayment()->getPairedValidApplications()->count() === 1) {
285-
$newApplication->getPayment()->setState(PaymentState::NOT_PAIRED_CANCELED);
285+
$newApplication->getPayment()->setState(PaymentState::PAIRED_CANCELED);
286286
}
287-
288-
$newApplication->setPayment(null);
289287
}
290288

291289
$this->applicationRepository->save($newApplication);
@@ -448,10 +446,8 @@ public function cancelSubeventsApplication(SubeventsApplication $application, st
448446

449447
if ($newApplication->getPayment() !== null) {
450448
if ($newApplication->getPayment()->getPairedValidApplications()->count() === 1) {
451-
$newApplication->getPayment()->setState(PaymentState::NOT_PAIRED_CANCELED);
449+
$newApplication->getPayment()->setState(PaymentState::PAIRED_CANCELED);
452450
}
453-
454-
$newApplication->setPayment(null);
455451
}
456452

457453
$this->applicationRepository->save($newApplication);
@@ -568,17 +564,9 @@ public function createPayment(
568564
$pairedApplication = $this->applicationRepository->findValidByVariableSymbol($variableSymbol);
569565

570566
if ($pairedApplication) {
571-
if (
572-
$pairedApplication->getState() === ApplicationState::PAID ||
573-
$pairedApplication->getState() === ApplicationState::PAID_FREE ||
574-
$pairedApplication->getState() === ApplicationState::PAID_TRANSFERED
575-
) {
567+
if ($pairedApplication->isPaid()) {
576568
$payment->setState(PaymentState::NOT_PAIRED_PAID);
577-
} elseif (
578-
$pairedApplication->getState() === ApplicationState::CANCELED ||
579-
$pairedApplication->getState() === ApplicationState::CANCELED_NOT_PAID ||
580-
$pairedApplication->getState() === ApplicationState::CANCELED_TRANSFERED
581-
) {
569+
} elseif ($pairedApplication->isCanceled()) {
582570
$payment->setState(PaymentState::NOT_PAIRED_CANCELED);
583571
} elseif (abs($pairedApplication->getFee() - $amount) >= 0.01) {
584572
$payment->setState(PaymentState::NOT_PAIRED_FEE);
@@ -812,39 +800,47 @@ public function transferRegistration(User $sourceUser, User $targetUser, User $c
812800
$targetUserPaidSubevents = $targetUser->getPaidSubevents();
813801

814802
// přidání zaplacených podakcí od zdrojového uživatele (kromě podakcí nekompatibilních s jeho stávajícími)
815-
/** @var ArrayCollection<int, Subevent> $targetSubevents */
816-
$targetSubevents = new ArrayCollection();
803+
/** @var ArrayCollection<int, Subevent> $addSubevents */
804+
$addSubevents = new ArrayCollection();
817805
foreach ($sourceUserPaidSubevents as $subevent) {
818-
if (! $targetSubevents->contains($subevent)) {
806+
if (! $addSubevents->contains($subevent)) {
819807
foreach ($subevent->getIncompatibleSubevents() as $incompatibleSubevent) {
820808
if ($targetUserPaidSubevents->contains($incompatibleSubevent)) {
821809
continue 2;
822810
}
823811
}
824812

825-
$targetSubevents->add($subevent);
813+
$addSubevents->add($subevent);
826814
}
827815
}
828816

817+
$addSubeventsFiltered = clone$addSubevents;
818+
829819
// odebrání podakcí, které už cílový uživatel má, ale budou mu přidány převodem
830820
foreach ($targetUser->getNotCanceledSubeventsApplications() as $application) {
831-
$remainingSubevents = new ArrayCollection();
821+
if ($application->isPaid()) {
822+
foreach ($application->getSubevents() as $subevent) {
823+
$addSubeventsFiltered->removeElement($subevent);
824+
}
825+
} else {
826+
$remainingApplicationSubevents = new ArrayCollection();
832827

833-
foreach ($application->getSubevents() as $subevent) {
834-
if (! $targetSubevents->contains($subevent)) {
835-
$remainingSubevents->add($subevent);
828+
foreach ($application->getSubevents() as $subevent) {
829+
if (! $addSubevents->contains($subevent)) {
830+
$remainingApplicationSubevents->add($subevent);
831+
}
836832
}
837-
}
838833

839-
if ($remainingSubevents->isEmpty()) {
840-
$this->cancelSubeventsApplication($application, ApplicationState::CANCELED, $createdBy);
841-
} else {
842-
$this->updateSubeventsApplication($application, $remainingSubevents, $createdBy);
834+
if ($remainingApplicationSubevents->isEmpty()) {
835+
$this->cancelSubeventsApplication($application, ApplicationState::CANCELED, $createdBy);
836+
} else {
837+
$this->updateSubeventsApplication($application, $remainingApplicationSubevents, $createdBy);
838+
}
843839
}
844840
}
845841

846842
$this->updateRoles($targetUser, $targetRoles, $createdBy, false, true);
847-
$this->addSubeventsApplication($targetUser, $targetSubevents, $createdBy, true);
843+
$this->addSubeventsApplication($targetUser, $addSubeventsFiltered, $createdBy, true);
848844

849845
$this->cancelRegistration($sourceUser, ApplicationState::CANCELED_TRANSFERED, $createdBy);
850846
});

app/assets/common/main.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ function initSelects() {
115115
actionsBox: true,
116116
iconBase: 'fa',
117117
tickIcon: 'fa-check',
118-
style: 'btn-light'
118+
style: 'btn-light',
119+
windowPadding: [50, 0, 0, 0]
119120
});
120121
}
121122

app/lang/admin.cs_CZ.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ users:
479479
users_edit_roles_occupied: "Všechna místa v některé roli jsou obsazena."
480480
users_edit_roles_nonregistered: "Roli \"Nepřihlášený\" není možné nastavit, použijte odhlášení ze semináře."
481481
users_transfer: "Převést registraci"
482-
users_transfer_confirm: "Opravdu chcete registraci převést na nového uživatele?"
482+
users_transfer_confirm: "Opravdu chcete registraci převést na nového uživatele?<br>Pokud cílový uživatel už má zaplacené některé z převáděných podakcí nebo nekompatibilní podakce, budou mu přidány jen ostatní a tyto budou uvolněny."
483483

484484
users_applications_application_date: "Čas přihlášení"
485485
users_applications_roles: "Role"

app/lang/common.cs_CZ.neon

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ payment:
8484
payment_state:
8585
paired_auto: "Spárována (automaticky)"
8686
paired_manual: "Spárována (ručně)"
87+
paired_canceled: "Spárována (přihláška zrušena)"
8788
not_paired_fee: "Nespárována (nesouhlasí částka)"
8889
not_paired_vs: "Nespárována (neexistuje variabilní symbol)"
8990
not_paired_canceled: "Nespárována (přihláška zrušena)"

0 commit comments

Comments
 (0)