4
4
5
5
namespace App \AdminModule \PaymentsModule \Components ;
6
6
7
+ use App \AdminModule \Presenters \AdminBasePresenter ;
7
8
use App \Model \Enums \PaymentState ;
8
9
use App \Model \Payment \Payment ;
9
10
use App \Model \Payment \Repositories \PaymentRepository ;
10
11
use App \Model \Settings \Exceptions \SettingsItemNotFoundException ;
11
12
use App \Model \Settings \Queries \SettingDateValueQuery ;
12
13
use App \Model \Settings \Queries \SettingStringValueQuery ;
13
14
use App \Model \Settings \Settings ;
14
- use App \Model \User \Repositories \UserRepository ;
15
15
use App \Services \ApplicationService ;
16
16
use App \Services \BankService ;
17
17
use App \Services \QueryBus ;
29
29
use Ublaboo \DataGrid \DataGrid ;
30
30
use Ublaboo \DataGrid \Exception \DataGridException ;
31
31
32
+ use function assert ;
33
+
32
34
/**
33
35
* Komponenta pro správu plateb.
34
36
*/
@@ -38,7 +40,6 @@ public function __construct(
38
40
private readonly QueryBus $ queryBus ,
39
41
private readonly Translator $ translator ,
40
42
private readonly PaymentRepository $ paymentRepository ,
41
- private readonly UserRepository $ userRepository ,
42
43
private readonly ApplicationService $ applicationService ,
43
44
private readonly BankService $ bankService ,
44
45
private readonly Session $ session ,
@@ -140,12 +141,13 @@ public function createComponentPaymentsGrid(string $name): void
140
141
*/
141
142
public function add (stdClass $ values ): void
142
143
{
143
- $ loggedUser = $ this ->userRepository ->findById ($ this ->getPresenter ()->user ->id );
144
+ $ p = $ this ->getPresenter ();
145
+ assert ($ p instanceof AdminBasePresenter);
144
146
145
- $ this ->applicationService ->createPaymentManual ($ values ->date , $ values ->amount , $ values ->variableSymbol , $ loggedUser );
147
+ $ this ->applicationService ->createPaymentManual ($ values ->date , $ values ->amount , $ values ->variableSymbol , $ p -> getDbUser () );
146
148
147
- $ this -> getPresenter () ->flashMessage ('admin.payments.payments.saved ' , 'success ' );
148
- $ this -> getPresenter () ->redrawControl ('flashes ' );
149
+ $ p ->flashMessage ('admin.payments.payments.saved ' , 'success ' );
150
+ $ p ->redrawControl ('flashes ' );
149
151
}
150
152
151
153
/**
@@ -157,11 +159,11 @@ public function handleDelete(int $id): void
157
159
{
158
160
$ payment = $ this ->paymentRepository ->findById ($ id );
159
161
160
- $ loggedUser = $ this ->userRepository ->findById ($ this ->getPresenter ()->user ->id );
162
+ $ p = $ this ->getPresenter ();
163
+ assert ($ p instanceof AdminBasePresenter);
161
164
162
- $ this ->applicationService ->removePayment ($ payment , $ loggedUser );
165
+ $ this ->applicationService ->removePayment ($ payment , $ p -> getDbUser () );
163
166
164
- $ p = $ this ->getPresenter ();
165
167
$ p ->flashMessage ('admin.payments.payments.deleted ' , 'success ' );
166
168
$ p ->redirect ('this ' );
167
169
}
0 commit comments