diff --git a/hesabixCore/src/Controller/CommodityController.php b/hesabixCore/src/Controller/CommodityController.php index 89af0e5..f3cebdb 100644 --- a/hesabixCore/src/Controller/CommodityController.php +++ b/hesabixCore/src/Controller/CommodityController.php @@ -62,7 +62,9 @@ class CommodityController extends AbstractController $temp['khadamat'] = false; if ($item->isKhadamat()) $temp['khadamat'] = true; - + $temp['withoutTax'] = false; + if ($item->isWithoutTax()) + $temp['withoutTax'] = true; $temp['commodityCountCheck'] = $item->isCommodityCountCheck(); $temp['minOrderCount'] = $item->getMinOrderCount(); $temp['dayLoading'] = $item->getDayLoading(); @@ -232,7 +234,7 @@ class CommodityController extends AbstractController 'code' => $code ]); $data->setUnit($data->getUnit()->getName()); - $res = $provider->Entity2ArrayJustIncludes($data, ['isSpeedAccess', 'isCommodityCountCheck', 'getName', 'getUnit', 'getPriceBuy', 'getPriceSell', 'getCat', 'getOrderPoint', 'getdes', 'getId', 'getDayLoading', 'isKhadamat', 'getCode', 'getMinOrderCount', 'getLabel'], 1); + $res = $provider->Entity2ArrayJustIncludes($data, ['isSpeedAccess', 'isCommodityCountCheck', 'getName', 'getUnit', 'getPriceBuy', 'getPriceSell', 'getCat', 'getOrderPoint', 'getdes', 'getId', 'getDayLoading', 'isKhadamat', 'getCode', 'getMinOrderCount', 'getLabel', 'isWithoutTax'], 1); $res['cat'] = ''; if ($data->getCat()) $res['cat'] = $data->getCat()->getId(); @@ -297,6 +299,8 @@ class CommodityController extends AbstractController $data->setname($params['name']); if ($params['khadamat'] == 'true') $data->setKhadamat(true); else $data->setKhadamat(false); + if ($params['withoutTax'] == 'true') $data->setWithoutTax(true); + else $data->setWithoutTax(false); $data->setDes($params['des']); $data->setPriceSell($params['priceSell']); $data->setPriceBuy($params['priceBuy']); diff --git a/hesabixCore/src/Controller/SellController.php b/hesabixCore/src/Controller/SellController.php index 7bb42f1..87b37fc 100644 --- a/hesabixCore/src/Controller/SellController.php +++ b/hesabixCore/src/Controller/SellController.php @@ -11,6 +11,7 @@ use App\Service\Extractor; use App\Entity\HesabdariDoc; use App\Entity\HesabdariRow; use App\Entity\HesabdariTable; +use App\Entity\InvoiceType; use App\Entity\Person; use App\Entity\StoreroomTicket; use Doctrine\ORM\EntityManagerInterface; @@ -84,7 +85,7 @@ class SellController extends AbstractController 'year' => $acc['year'], 'code' => $params['update'] ]); - if (!$doc) $this->json($extractor->notFound()); + if (!$doc) return $this->json($extractor->notFound()); $rows = $entityManager->getRepository(HesabdariRow::class)->findBy([ 'doc' => $doc @@ -156,7 +157,7 @@ class SellController extends AbstractController $entityManager->persist($hesabdariRow); //set tax info - + $entityManager->persist($doc); $entityManager->flush(); $log->insert( @@ -168,4 +169,110 @@ class SellController extends AbstractController ); return $this->json($extractor->operationSuccess()); } + + #[Route('/api/sell/label/change', name: 'app_sell_label_change')] + public function app_sell_label_change(Request $request, Access $access, Extractor $extractor, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + $acc = $access->hasRole('sell'); + if (!$acc) + throw $this->createAccessDeniedException(); + if ($params['label'] != 'clear') { + $label = $entityManager->getRepository(InvoiceType::class)->findOneBy([ + 'code' => $params['label']['code'], + 'type' => 'sell' + ]); + if (!$label) return $this->json($extractor->notFound()); + } + foreach ($params['items'] as $item) { + $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ + 'bid' => $acc['bid'], + 'year' => $acc['year'], + 'code' => $item['code'] + ]); + if (!$doc) return $this->json($extractor->notFound()); + if ($params['label'] != 'clear') { + $doc->setInvoiceLabel($label); + $entityManager->persist($doc); + $log->insert( + 'حسابداری', + ' تغییر برچسب فاکتور‌ شماره ' . $doc->getCode() . ' به ' . $label->getLabel(), + $this->getUser(), + $acc['bid']->getId(), + $doc + ); + } else { + $doc->setInvoiceLabel(null); + $entityManager->persist($doc); + $log->insert( + 'حسابداری', + ' حذف برچسب فاکتور‌ شماره ' . $doc->getCode(), + $this->getUser(), + $acc['bid']->getId(), + $doc + ); + } + } + $entityManager->flush(); + return $this->json($extractor->operationSuccess()); + } + + #[Route('/api/sell/docs/search', name: 'app_sell_docs_search')] + public function app_sell_docs_search(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('sell'); + if (!$acc) + throw $this->createAccessDeniedException(); + + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + $data = $entityManager->getRepository(HesabdariDoc::class)->findBy([ + 'bid' => $acc['bid'], + 'year' => $acc['year'], + 'type' => 'sell' + ], [ + 'id' => 'DESC' + ]); + $dataTemp = []; + foreach ($data as $item) { + $temp = [ + 'id' => $item->getId(), + 'dateSubmit' => $item->getDateSubmit(), + 'date' => $item->getDate(), + 'type' => $item->getType(), + 'code' => $item->getCode(), + 'des' => $item->getDes(), + 'amount' => $item->getAmount(), + 'submitter' => $item->getSubmitter()->getFullName(), + ]; + $mainRow = $entityManager->getRepository(HesabdariRow::class)->getNotEqual($item, 'person'); + $temp['person'] = ''; + if ($mainRow) + $temp['person'] = Explore::ExplorePerson($mainRow->getPerson()); + + $temp['label'] = null; + if ($item->getInvoiceLabel()) { + $temp['label'] = [ + 'code' => $item->getInvoiceLabel()->getCode(), + 'label' => $item->getInvoiceLabel()->getLabel() + ]; + } + + $temp['relatedDocsCount'] = count($item->getRelatedDocs()); + $pays = 0; + foreach ($item->getRelatedDocs() as $relatedDoc) { + $pays += $relatedDoc->getAmount(); + } + $temp['relatedDocsPays'] = $pays; + $dataTemp[] = $temp; + } + return $this->json($dataTemp); + } } diff --git a/hesabixCore/src/Entity/Commodity.php b/hesabixCore/src/Entity/Commodity.php index 2b03189..24ae201 100644 --- a/hesabixCore/src/Entity/Commodity.php +++ b/hesabixCore/src/Entity/Commodity.php @@ -76,6 +76,9 @@ class Commodity #[ORM\OneToMany(mappedBy: 'commodity', targetEntity: PlugRepserviceOrder::class, orphanRemoval: true)] private Collection $plugRepserviceOrders; + #[ORM\Column(nullable: true)] + private ?bool $withoutTax = null; + public function __construct() { $this->setPriceBuy(0); @@ -378,4 +381,16 @@ class Commodity return $this; } + + public function isWithoutTax(): ?bool + { + return $this->withoutTax; + } + + public function setWithoutTax(?bool $withoutTax): static + { + $this->withoutTax = $withoutTax; + + return $this; + } } diff --git a/hesabixCore/src/Service/Explore.php b/hesabixCore/src/Service/Explore.php index 8682efe..061cdd1 100644 --- a/hesabixCore/src/Service/Explore.php +++ b/hesabixCore/src/Service/Explore.php @@ -164,7 +164,8 @@ class Explore //most be completed 'count' => $count, 'unit' => $item->getUnit()->getName(), - 'des' => $des + 'des' => $des, + 'withoutTax' => $item->isWithoutTax() ]; return null; }