bug fix in storeroom controller for remove tickets
This commit is contained in:
parent
2276754e39
commit
bae07712e9
|
@ -66,8 +66,7 @@ class StoreroomController extends AbstractController
|
||||||
return $this->json(['result' => 2]);
|
return $this->json(['result' => 2]);
|
||||||
$data = new Storeroom();
|
$data = new Storeroom();
|
||||||
$data->setBid($acc['bid']);
|
$data->setBid($acc['bid']);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$data = $entityManager->getRepository(Storeroom::class)->findOneBy([
|
$data = $entityManager->getRepository(Storeroom::class)->findOneBy([
|
||||||
'bid' => $acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
'id' => $code
|
'id' => $code
|
||||||
|
@ -160,7 +159,8 @@ class StoreroomController extends AbstractController
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPerson(HesabdariDoc $doc): Person | bool{
|
private function getPerson(HesabdariDoc $doc): Person | bool
|
||||||
|
{
|
||||||
foreach ($doc->getHesabdariRows() as $row) {
|
foreach ($doc->getHesabdariRows() as $row) {
|
||||||
if ($row->getPerson())
|
if ($row->getPerson())
|
||||||
return $row->getPerson();
|
return $row->getPerson();
|
||||||
|
@ -168,7 +168,8 @@ class StoreroomController extends AbstractController
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getCommodities(HesabdariDoc $doc,Provider $provider): array{
|
private function getCommodities(HesabdariDoc $doc, Provider $provider): array
|
||||||
|
{
|
||||||
$res = [];
|
$res = [];
|
||||||
foreach ($doc->getHesabdariRows() as $row) {
|
foreach ($doc->getHesabdariRows() as $row) {
|
||||||
if ($row->getCommodity()) {
|
if ($row->getCommodity()) {
|
||||||
|
@ -176,7 +177,6 @@ class StoreroomController extends AbstractController
|
||||||
$arrayRow['commdityCount'] = $row->getCommdityCount();
|
$arrayRow['commdityCount'] = $row->getCommdityCount();
|
||||||
$res[] = $arrayRow;
|
$res[] = $arrayRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
@ -210,15 +210,18 @@ class StoreroomController extends AbstractController
|
||||||
if ($row->getPerson()) {
|
if ($row->getPerson()) {
|
||||||
$person = $row->getPerson();
|
$person = $row->getPerson();
|
||||||
break;
|
break;
|
||||||
}
|
} elseif ($row->getCommodity()) {
|
||||||
elseif ($row->getCommodity()){
|
|
||||||
if (!$row->getCommodity()->isKhadamat())
|
if (!$row->getCommodity()->isKhadamat())
|
||||||
$commodities[] = $row;
|
$commodities[] = $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($commodities as $commodity) {
|
foreach ($commodities as $commodity) {
|
||||||
|
if (is_string($commodity->getCommodity()->getUnit())) {
|
||||||
|
$commodity->getCommodity()->setUnit($commodity->getCommodity()->getUnit());
|
||||||
|
} else {
|
||||||
$commodity->getCommodity()->setUnit($commodity->getCommodity()->getUnit()->getName());
|
$commodity->getCommodity()->setUnit($commodity->getCommodity()->getUnit()->getName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$res = $provider->Entity2Array($doc, 0);
|
$res = $provider->Entity2Array($doc, 0);
|
||||||
$res['person'] = $provider->Entity2Array($person, 0);
|
$res['person'] = $provider->Entity2Array($person, 0);
|
||||||
$res['person']['des'] = ' # ' . $person->getCode() . ' ' . $person->getNikename();
|
$res['person']['des'] = ' # ' . $person->getCode() . ' ' . $person->getNikename();
|
||||||
|
@ -228,7 +231,8 @@ class StoreroomController extends AbstractController
|
||||||
return $this->json($res);
|
return $this->json($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calcStoreRemaining(array &$ref,HesabdariDoc $doc,EntityManagerInterface $entityManager){
|
private function calcStoreRemaining(array &$ref, HesabdariDoc $doc, EntityManagerInterface $entityManager)
|
||||||
|
{
|
||||||
$tickets = $entityManager->getRepository(StoreroomTicket::class)->findBy(['doc' => $doc]);
|
$tickets = $entityManager->getRepository(StoreroomTicket::class)->findBy(['doc' => $doc]);
|
||||||
|
|
||||||
if (count($tickets) == 0) {
|
if (count($tickets) == 0) {
|
||||||
|
@ -238,8 +242,7 @@ class StoreroomController extends AbstractController
|
||||||
$ref['commodities'][$key]['hesabdariCount'] = $commodity['commdityCount'];
|
$ref['commodities'][$key]['hesabdariCount'] = $commodity['commdityCount'];
|
||||||
$ref['commodities'][$key]['remain'] = $ref['commodities'][$key]['hesabdariCount'];
|
$ref['commodities'][$key]['remain'] = $ref['commodities'][$key]['hesabdariCount'];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$ref['storeroomComplete'] = true;
|
$ref['storeroomComplete'] = true;
|
||||||
foreach ($tickets as $ticket) {
|
foreach ($tickets as $ticket) {
|
||||||
$rows = $entityManager->getRepository(StoreroomItem::class)->findBy(['ticket' => $ticket]);
|
$rows = $entityManager->getRepository(StoreroomItem::class)->findBy(['ticket' => $ticket]);
|
||||||
|
@ -251,12 +254,10 @@ class StoreroomController extends AbstractController
|
||||||
if (array_key_exists('countBefore', $ref['commodities'][$key])) {
|
if (array_key_exists('countBefore', $ref['commodities'][$key])) {
|
||||||
$ref['commodities'][$key]['countBefore'] += $row->getCount();
|
$ref['commodities'][$key]['countBefore'] += $row->getCount();
|
||||||
$ref['commodities'][$key]['hesabdariCount'] = $comRow->getCommdityCount();
|
$ref['commodities'][$key]['hesabdariCount'] = $comRow->getCommdityCount();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$ref['commodities'][$key]['countBefore'] = $row->getCount();
|
$ref['commodities'][$key]['countBefore'] = $row->getCount();
|
||||||
$ref['commodities'][$key]['hesabdariCount'] = $comRow->getCommdityCount();
|
$ref['commodities'][$key]['hesabdariCount'] = $comRow->getCommdityCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,7 +278,6 @@ class StoreroomController extends AbstractController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#[Route('/api/storeroom/transfertype/list', name: 'app_storeroom_get_transfertype_list')]
|
#[Route('/api/storeroom/transfertype/list', name: 'app_storeroom_get_transfertype_list')]
|
||||||
public function app_storeroom_get_transfertype_list(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
public function app_storeroom_get_transfertype_list(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||||
|
@ -474,16 +474,39 @@ class StoreroomController extends AbstractController
|
||||||
$temp['existCount'] = $temp['input'] - $temp['output'];
|
$temp['existCount'] = $temp['input'] - $temp['output'];
|
||||||
$items[] = $temp;
|
$items[] = $temp;
|
||||||
}
|
}
|
||||||
return $this->json($items);
|
return $this->json($this->getCommodityCountExistInStoreroom($commodities, $rows, $provider));
|
||||||
|
}
|
||||||
|
public function getCommodityCountExistInStoreroom(array $commodities, array $rows, Provider $provider)
|
||||||
|
{
|
||||||
|
$items = [];
|
||||||
|
foreach ($commodities as $commodity) {
|
||||||
|
$temp = [];
|
||||||
|
$temp['commodity'] = $provider->Entity2ArrayJustIncludes($commodity, ['getUnit', 'getCode', 'getName', 'getCat', 'getOrderPoint']);
|
||||||
|
$temp['input'] = 0;
|
||||||
|
$temp['output'] = 0;
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
if ($row->getCommodity()->getId() == $commodity->getId()) {
|
||||||
|
if ($row->getType() == 'output')
|
||||||
|
$temp['output'] += $row->getCount();
|
||||||
|
elseif ($row->getType() == 'input')
|
||||||
|
$temp['input'] += $row->getCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$temp['existCount'] = $temp['input'] - $temp['output'];
|
||||||
|
$items[] = $temp;
|
||||||
|
}
|
||||||
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/storeroom/ticket/remove/{id}', name: 'app_storeroom_ticket_remove')]
|
#[Route('/api/storeroom/ticket/remove/{id}', name: 'app_storeroom_ticket_remove')]
|
||||||
public function app_storeroom_ticket_remove(String $id, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
public function app_storeroom_ticket_remove(String $id, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||||
{
|
{
|
||||||
$acc = $access->hasRole('store');
|
$acc = $access->hasRole('store');
|
||||||
if (!$acc)
|
if (!$acc)
|
||||||
throw $this->createAccessDeniedException();
|
throw $this->createAccessDeniedException();
|
||||||
$ticket = $entityManager->getRepository(StoreroomTicket::class)->findOneBy(['code'=>$id]);
|
$ticket = $entityManager->getRepository(StoreroomTicket::class)->findOneBy([
|
||||||
|
'code' => $id,
|
||||||
|
'bid' => $acc['bid']
|
||||||
|
]);
|
||||||
if (!$ticket)
|
if (!$ticket)
|
||||||
throw $this->createNotFoundException('حواله یافت نشد');
|
throw $this->createNotFoundException('حواله یافت نشد');
|
||||||
$items = $entityManager->getRepository(StoreroomItem::class)->findBy(['ticket' => $ticket]);
|
$items = $entityManager->getRepository(StoreroomItem::class)->findBy(['ticket' => $ticket]);
|
||||||
|
|
Loading…
Reference in a new issue