bug fix access control

This commit is contained in:
Hesabix 2025-10-01 15:51:33 +03:30
parent 61ff2d4ca7
commit fb037a8299
3 changed files with 22 additions and 9 deletions

View file

@ -59,8 +59,8 @@ class BankController extends AbstractController
->getQuery() ->getQuery()
->getResult(); ->getResult();
foreach ($items as $item) { foreach ($items as $item) {
$bs += $item->getBs(); $bs += (float) $item->getBs();
$bd += $item->getBd(); $bd += (float) $item->getBd();
} }
$data->setBalance($bd - $bs); $data->setBalance($bd - $bs);
} }

View file

@ -61,8 +61,8 @@ class CashdeskController extends AbstractController
->getQuery() ->getQuery()
->getResult(); ->getResult();
foreach ($items as $item) { foreach ($items as $item) {
$bs += $item->getBs(); $bs += (float) $item->getBs();
$bd += $item->getBd(); $bd += (float) $item->getBd();
} }
$data->setBalance($bd - $bs); $data->setBalance($bd - $bs);
$resp[] = Explore::ExploreCashdesk($data); $resp[] = Explore::ExploreCashdesk($data);
@ -206,8 +206,8 @@ class CashdeskController extends AbstractController
->getQuery() ->getQuery()
->getResult(); ->getResult();
foreach ($items as $item) { foreach ($items as $item) {
$bs += $item->getBs(); $bs += (float) $item->getBs();
$bd += $item->getBd(); $bd += (float) $item->getBd();
} }
$data->setBalance($bd - $bs); $data->setBalance($bd - $bs);
} }
@ -255,8 +255,8 @@ class CashdeskController extends AbstractController
->getResult(); ->getResult();
foreach ($items as $item) { foreach ($items as $item) {
$bs += $item->getBs(); $bs += (float) $item->getBs();
$bd += $item->getBd(); $bd += (float) $item->getBd();
} }
return $this->json([ return $this->json([

View file

@ -144,13 +144,26 @@ class Access
} }
} }
// normalize incoming role names to match Permission getters
$normalizeMap = [
'bank' => 'banks',
'transfer' => 'bankTransfer',
'person_receive' => 'person',
'person_send' => 'person',
'sell_receive' => 'sell',
'buy_send' => 'buy',
'all' => 'accounting',
];
if (isset($normalizeMap[$roll])) {
$roll = $normalizeMap[$roll];
}
$methodName = 'is' . ucfirst($roll); $methodName = 'is' . ucfirst($roll);
$permission = $this->em->getRepository(Permission::class)->findOneBy([ $permission = $this->em->getRepository(Permission::class)->findOneBy([
'bid'=>$bid, 'bid'=>$bid,
'user'=>$this->user 'user'=>$this->user
]); ]);
if($permission){ if($permission){
if($permission->{$methodName}()) if(method_exists($permission, $methodName) && $permission->{$methodName}())
return $accessArray; return $accessArray;
} }
return false; return false;