From eb9dcf07cfa239052c9950db22ee49005ea1c25b Mon Sep 17 00:00:00 2001 From: babak alizadeh Date: Thu, 25 Jul 2024 13:16:46 +0330 Subject: [PATCH] bug fix in repservice plugin --- .../Plugins/PlugRepserviceController.php | 8 ++++ .../src/Controller/StoreroomController.php | 43 ++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/hesabixCore/src/Controller/Plugins/PlugRepserviceController.php b/hesabixCore/src/Controller/Plugins/PlugRepserviceController.php index ec14f2f..76c1722 100644 --- a/hesabixCore/src/Controller/Plugins/PlugRepserviceController.php +++ b/hesabixCore/src/Controller/Plugins/PlugRepserviceController.php @@ -8,6 +8,7 @@ use App\Service\SMS; use App\Entity\Person; use App\Service\Access; use App\Entity\Commodity; +use App\Entity\Log as EntityLog; use App\Service\Provider; use App\Service\Extractor; use App\Service\registryMGR; @@ -272,6 +273,13 @@ class PlugRepserviceController extends AbstractController if (!$item) throw $this->createNotFoundException(); $code = $item->getCode(); + // remove logs + $logs = $entityManager->getRepository(EntityLog::class)->findBy(['repserviceOrder' => $item]); + foreach($logs as $lg){ + $lg->setRepserviceOrder(null); + $entityManager->persist($lg); + } + $entityManager->flush(); $entityManager->remove($item); $log->insert('افزونه تعمیرکاران', 'درخواست با شماره قبض' . $code . 'حذف شد.', $this->getUser(), $acc['bid']->getId()); return $this->json(['result' => 1]); diff --git a/hesabixCore/src/Controller/StoreroomController.php b/hesabixCore/src/Controller/StoreroomController.php index 9540f20..990e496 100644 --- a/hesabixCore/src/Controller/StoreroomController.php +++ b/hesabixCore/src/Controller/StoreroomController.php @@ -153,9 +153,50 @@ class StoreroomController extends AbstractController } } + $rfsells = $entityManager->getRepository(HesabdariDoc::class)->findBy([ + 'bid' => $acc['bid'], + 'type' => 'rfsell' + ]); + $rfsellsForExport = []; + foreach ($rfsells as $sell) { + $temp = $provider->Entity2Array($sell, 0); + $person = $this->getPerson($sell); + $temp['person'] = $provider->Entity2ArrayJustIncludes($person, ['getCode', 'getNikename', 'getDes']); + $temp['person']['des'] = ' # ' . $person->getCode() . ' ' . $person->getNikename(); + $temp['commodities'] = $this->getCommodities($sell, $provider); + //check storeroom exist + $this->calcStoreRemaining($temp, $sell, $entityManager); + $temp['des'] = 'فاکتور برگشت از فروش شماره # ' . $sell->getCode(); + if (array_key_exists('storeroomComplete', $temp)) + if (!$temp['storeroomComplete']) { + $rfsellsForExport[] = $temp; + } + } + + $rfbuys = $entityManager->getRepository(HesabdariDoc::class)->findBy([ + 'bid' => $acc['bid'], + 'type' => 'rfbuy' + ]); + $rfbuysForExport = []; + foreach ($rfbuys as $buy) { + $temp = $provider->Entity2Array($buy, 0); + $person = $this->getPerson($buy); + $temp['person'] = $provider->Entity2ArrayJustIncludes($person, ['getCode', 'getNikename', 'getDes']); + $temp['person']['des'] = ' # ' . $person->getCode() . ' ' . $person->getNikename(); + $temp['commodities'] = $this->getCommodities($buy, $provider); + //check storeroom exist + $this->calcStoreRemaining($temp, $buy, $entityManager); + $temp['des'] = 'فاکتور برگشت از خرید شماره # ' . $buy->getCode(); + if (array_key_exists('storeroomComplete', $temp)) + if (!$temp['storeroomComplete']) { + $rfbuysForExport[] = $temp; + } + } return $this->json([ 'buys' => $buysForExport, - 'sells' => $sellsForExport + 'sells' => $sellsForExport, + 'rfsells' => $rfsellsForExport, + 'rfbuys' => $rfbuysForExport ]); }