From dc066b0f5f0a97a9b52a9536486c4e0aa8ca5803 Mon Sep 17 00:00:00 2001 From: babak alizadeh Date: Mon, 29 Jul 2024 20:16:40 +0330 Subject: [PATCH] some progress in accpro --- hesabixCore/src/Controller/BuyController.php | 109 ++++- .../src/Controller/PrintersController.php | 46 ++ .../src/Controller/RfbuyController.php | 442 +++++++++++++++++- .../src/Controller/RfsellController.php | 430 ++++++++++++++++- hesabixCore/src/Entity/PrintOptions.php | 270 +++++++++++ .../templates/pdf/printers/buy.html.twig | 217 +++++---- .../templates/pdf/printers/rfbuy.html.twig | 311 ++++++++++++ .../templates/pdf/printers/rfsell.html.twig | 311 ++++++++++++ 8 files changed, 2016 insertions(+), 120 deletions(-) create mode 100644 hesabixCore/templates/pdf/printers/rfbuy.html.twig create mode 100644 hesabixCore/templates/pdf/printers/rfsell.html.twig diff --git a/hesabixCore/src/Controller/BuyController.php b/hesabixCore/src/Controller/BuyController.php index 382fa09..a089ac8 100644 --- a/hesabixCore/src/Controller/BuyController.php +++ b/hesabixCore/src/Controller/BuyController.php @@ -13,6 +13,7 @@ use App\Entity\HesabdariRow; use App\Entity\HesabdariTable; use App\Entity\InvoiceType; use App\Entity\Person; +use App\Entity\PrintOptions; use App\Entity\StoreroomTicket; use App\Service\Printers; use Doctrine\ORM\EntityManagerInterface; @@ -179,7 +180,7 @@ class BuyController extends AbstractController } //set amount of document $doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']); - //set person seller + //set person buyer $hesabdariRow = new HesabdariRow(); $hesabdariRow->setDes('فاکتور خرید'); $hesabdariRow->setBid($acc['bid']); @@ -193,7 +194,7 @@ class BuyController extends AbstractController $hesabdariRow->setRef($ref); $person = $entityManager->getRepository(Person::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $params['seller']['code'] + 'code' => $params['buyer']['code'] ]); if (!$person) return $this->json($extractor->paramsNotSend()); @@ -330,6 +331,69 @@ class BuyController extends AbstractController return $this->json($dataTemp); } + #[Route('/api/buy/posprinter/invoice', name: 'app_buy_posprinter_invoice')] + public function app_buy_posprinter_invoice(Printers $printers, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + $acc = $access->hasRole('buy'); + if (!$acc) throw $this->createAccessDeniedException(); + + $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ + 'bid' => $acc['bid'], + 'code' => $params['code'] + ]); + if (!$doc) throw $this->createNotFoundException(); + $pdfPid = 0; + if ($params['pdf']) { + $pdfPid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/posPrinters/buy.html.twig', [ + 'bid' => $acc['bid'], + 'doc'=>$doc, + 'rows'=>$doc->getHesabdariRows(), + 'printInvoice'=>$params['posPrint'], + 'printcashdeskRecp'=>$params['posPrintRecp'], + ]), + true + ); + } + + + if ($params['posPrint'] == true) { + $pid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/posPrinters/justSell.html.twig', [ + 'bid' => $acc['bid'], + 'doc' => $doc, + 'rows' => $doc->getHesabdariRows(), + ]), + true + ); + $printers->addFile($pid, $acc, "fastSellInvoice"); + } + if ($params['posPrintRecp'] == true) { + $pid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/posPrinters/cashdesk.html.twig', [ + 'bid' => $acc['bid'], + 'doc' => $doc, + 'rows' => $doc->getHesabdariRows(), + ]), + true + ); + $printers->addFile($pid, $acc, "fastSellCashdesk"); + } + + return $this->json(['id' => $pdfPid]); + } + #[Route('/api/buy/print/invoice', name: 'app_buy_print_invoice')] public function app_buy_print_invoice(Printers $printers, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse { @@ -353,13 +417,40 @@ class BuyController extends AbstractController if ($item->getPerson()) { $person = $item->getPerson(); } elseif ($item->getRef()->getCode() == 104) { - $discount = $item->getBs(); - } elseif ($item->getRef()->getCode() == 90) { - $transfer = $item->getBd(); + $discount = $item->getBd(); + } elseif ($item->getRef()->getCode() == 61) { + $transfer = $item->getBs(); } } $pdfPid = 0; if ($params['pdf']) { + $printOptions = [ + 'bidInfo' => true, + 'pays' =>true, + 'taxInfo' =>true, + 'discountInfo' =>true, + 'note' =>true + ]; + if(array_key_exists('printOptions',$params)){ + if(array_key_exists('bidInfo',$params['printOptions'])){ + $printOptions['bidInfo'] = $params['printOptions']['bidInfo']; + } + if(array_key_exists('pays',$params['printOptions'])){ + $printOptions['pays'] = $params['printOptions']['pays']; + } + if(array_key_exists('taxInfo',$params['printOptions'])){ + $printOptions['taxInfo'] = $params['printOptions']['taxInfo']; + } + if(array_key_exists('discountInfo',$params['printOptions'])){ + $printOptions['discountInfo'] = $params['printOptions']['discountInfo']; + } + if(array_key_exists('note',$params['printOptions'])){ + $printOptions['note'] = $params['printOptions']['note']; + } + } + $note = ''; + $printSettings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid'=>$acc['bid']]); + if($printSettings){$note = $printSettings->getSellNoteString();} $pdfPid = $provider->createPrint( $acc['bid'], $this->getUser(), @@ -370,7 +461,9 @@ class BuyController extends AbstractController 'person' => $person, 'printInvoice' => $params['printers'], 'discount' => $discount, - 'transfer' => $transfer + 'transfer' => $transfer, + 'printOptions'=> $printOptions, + 'note'=> $note ]), false ); @@ -379,14 +472,14 @@ class BuyController extends AbstractController $pid = $provider->createPrint( $acc['bid'], $this->getUser(), - $this->renderView('pdf/posPrinters/justBuy.html.twig', [ + $this->renderView('pdf/posPrinters/justSell.html.twig', [ 'bid' => $acc['bid'], 'doc' => $doc, 'rows' => $doc->getHesabdariRows(), ]), false ); - $printers->addFile($pid, $acc, "fastBuyInvoice"); + $printers->addFile($pid, $acc, "fastSellInvoice"); } return $this->json(['id' => $pdfPid]); } diff --git a/hesabixCore/src/Controller/PrintersController.php b/hesabixCore/src/Controller/PrintersController.php index 6741f2d..0ca5c63 100644 --- a/hesabixCore/src/Controller/PrintersController.php +++ b/hesabixCore/src/Controller/PrintersController.php @@ -52,6 +52,30 @@ class PrintersController extends AbstractController $temp['sell']['note'] = $settings->isSellNote(); $temp['sell']['noteString'] = $settings->getSellNoteString(); $temp['sell']['pays'] = $settings->isSellPays(); + + $temp['buy']['id'] = $settings->getId(); + $temp['buy']['bidInfo'] = $settings->isBuyBidInfo(); + $temp['buy']['taxInfo'] = $settings->isBuyTaxInfo(); + $temp['buy']['discountInfo'] = $settings->isBuyDiscountInfo(); + $temp['buy']['note'] = $settings->isBuyNote(); + $temp['buy']['noteString'] = $settings->getBuyNoteString(); + $temp['buy']['pays'] = $settings->isBuyPays(); + + $temp['rfbuy']['id'] = $settings->getId(); + $temp['rfbuy']['bidInfo'] = $settings->isRfbuyBidInfo(); + $temp['rfbuy']['taxInfo'] = $settings->isRfbuyTaxInfo(); + $temp['rfbuy']['discountInfo'] = $settings->isRfbuyDiscountInfo(); + $temp['rfbuy']['note'] = $settings->isRfbuyNote(); + $temp['rfbuy']['noteString'] = $settings->getRfbuyNoteString(); + $temp['rfbuy']['pays'] = $settings->isRfbuyPays(); + + $temp['rfsell']['id'] = $settings->getId(); + $temp['rfsell']['bidInfo'] = $settings->isRfsellBidInfo(); + $temp['rfsell']['taxInfo'] = $settings->isRfsellTaxInfo(); + $temp['rfsell']['discountInfo'] = $settings->isRfsellDiscountInfo(); + $temp['rfsell']['note'] = $settings->isRfsellNote(); + $temp['rfsell']['noteString'] = $settings->getRfsellNoteString(); + $temp['rfsell']['pays'] = $settings->isRfsellPays(); return $this->json($temp); } @@ -79,6 +103,28 @@ class PrintersController extends AbstractController $settings->setSellNote($params['sell']['note']); $settings->setSellNoteString($params['sell']['noteString']); $settings->setSellPays($params['sell']['pays']); + + $settings->setBuyBidInfo($params['buy']['bidInfo']); + $settings->setBuyTaxInfo($params['buy']['taxInfo']); + $settings->setBuyDiscountInfo($params['buy']['discountInfo']); + $settings->setBuyNote($params['buy']['note']); + $settings->setBuyNoteString($params['buy']['noteString']); + $settings->setBuyPays($params['buy']['pays']); + + $settings->setRfbuyBidInfo($params['rfbuy']['bidInfo']); + $settings->setRfbuyTaxInfo($params['rfbuy']['taxInfo']); + $settings->setRfbuyDiscountInfo($params['rfbuy']['discountInfo']); + $settings->setRfbuyNote($params['rfbuy']['note']); + $settings->setRfbuyNoteString($params['rfbuy']['noteString']); + $settings->setRfbuyPays($params['rfbuy']['pays']); + + $settings->setRfsellBidInfo($params['rfsell']['bidInfo']); + $settings->setRfsellTaxInfo($params['rfsell']['taxInfo']); + $settings->setRfsellDiscountInfo($params['rfsell']['discountInfo']); + $settings->setRfsellNote($params['rfsell']['note']); + $settings->setRfsellNoteString($params['rfsell']['noteString']); + $settings->setRfsellPays($params['rfsell']['pays']); + $entityManager->persist($settings); $entityManager->flush(); $log->insert('تنظیمات چاپ', 'تنظیمات چاپ به روز رسانی شد.', $this->getUser(), $acc['bid']->getId()); diff --git a/hesabixCore/src/Controller/RfbuyController.php b/hesabixCore/src/Controller/RfbuyController.php index 18b1ea6..fcc1b8c 100644 --- a/hesabixCore/src/Controller/RfbuyController.php +++ b/hesabixCore/src/Controller/RfbuyController.php @@ -5,8 +5,17 @@ namespace App\Controller; use App\Service\Log; use App\Service\Access; use App\Service\Explore; +use App\Entity\Commodity; +use App\Service\Provider; +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\PrintOptions; use App\Entity\StoreroomTicket; +use App\Service\Printers; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -17,43 +26,446 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; class RfbuyController extends AbstractController { #[Route('/api/rfbuy/edit/can/{code}', name: 'app_rfbuy_can_edit')] - public function app_rfbuy_can_edit(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager, string $code): JsonResponse + public function app_rfbuy_can_edit(Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, string $code): JsonResponse { $canEdit = true; $acc = $access->hasRole('plugAccproRfbuy'); - if(!$acc) + if (!$acc) throw $this->createAccessDeniedException(); $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ - 'bid'=>$acc['bid'], - 'code'=>$code + 'bid' => $acc['bid'], + 'code' => $code ]); //check related documents - if(count($doc->getRelatedDocs()) != 0) + if (count($doc->getRelatedDocs()) != 0) $canEdit = false; //check storeroom tickets - $tickets = $entityManager->getRepository(StoreroomTicket::class)->findBy(['doc'=>$doc]); - if(count($tickets) != 0) + $tickets = $entityManager->getRepository(StoreroomTicket::class)->findBy(['doc' => $doc]); + if (count($tickets) != 0) $canEdit = false; return $this->json([ - 'result'=> $canEdit + 'result' => $canEdit ]); } #[Route('/api/rfbuy/get/info/{code}', name: 'app_rfbuy_get_info')] - public function app_rfbuy_get_info(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager, string $code): JsonResponse + public function app_rfbuy_get_info(Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, string $code): JsonResponse { $acc = $access->hasRole('plugAccproRfbuy'); - if(!$acc) + if (!$acc) throw $this->createAccessDeniedException(); $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ - 'bid'=>$acc['bid'], - 'code'=>$code + 'bid' => $acc['bid'], + 'code' => $code ]); - if(!$doc) + if (!$doc) throw $this->createNotFoundException(); - - return $this->json(Explore::ExploreRfbuyDoc($doc)); + + return $this->json(Explore::ExploreSellDoc($doc)); + } + + #[Route('/api/rfbuy/mod', name: 'app_rfbuy_mod')] + public function app_rfbuy_mod(Provider $provider, Extractor $extractor, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + $acc = $access->hasRole('plugAccproRfbuy'); + if (!$acc) + throw $this->createAccessDeniedException(); + + if (!array_key_exists('update', $params)) { + return $this->json($extractor->paramsNotSend()); + } + if ($params['update'] != '') { + $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ + 'bid' => $acc['bid'], + 'year' => $acc['year'], + 'code' => $params['update'] + ]); + if (!$doc) return $this->json($extractor->notFound()); + + $rows = $entityManager->getRepository(HesabdariRow::class)->findBy([ + 'doc' => $doc + ]); + foreach ($rows as $row) + $entityManager->remove($row); + } else { + $doc = new HesabdariDoc(); + $doc->setBid($acc['bid']); + $doc->setYear($acc['year']); + $doc->setDateSubmit(time()); + $doc->setType('rfbuy'); + $doc->setSubmitter($this->getUser()); + $doc->setMoney($acc['bid']->getMoney()); + $doc->setCode($provider->getAccountingCode($acc['bid'], 'accounting')); + } + if($params['transferCost'] != 0){ + $hesabdariRow = new HesabdariRow(); + $hesabdariRow->setDes('حمل و نقل کالا'); + $hesabdariRow->setBid($acc['bid']); + $hesabdariRow->setYear($acc['year']); + $hesabdariRow->setDoc($doc); + $hesabdariRow->setBs($params['transferCost']); + $hesabdariRow->setBd(0); + $ref = $entityManager->getRepository(HesabdariTable::class)->findOneBy([ + 'code' => '61' // transfer cost income + ]); + $hesabdariRow->setRef($ref); + $entityManager->persist($hesabdariRow); + } + if($params['discountAll'] != 0){ + $hesabdariRow = new HesabdariRow(); + $hesabdariRow->setDes('تخفیف فاکتور'); + $hesabdariRow->setBid($acc['bid']); + $hesabdariRow->setYear($acc['year']); + $hesabdariRow->setDoc($doc); + $hesabdariRow->setBs(0); + $hesabdariRow->setBd($params['discountAll']); + $ref = $entityManager->getRepository(HesabdariTable::class)->findOneBy([ + 'code' => '104' // سایر هزینه های پخش و برگشت از خرید + ]); + $hesabdariRow->setRef($ref); + $entityManager->persist($hesabdariRow); + } + $doc->setDes($params['des']); + $doc->setDate($params['date']); + $sumTax = 0; + $sumTotal = 0; + foreach ($params['rows'] as $row) { + $sumTax += $row['tax']; + $sumTotal += $row['sumWithoutTax']; + $hesabdariRow = new HesabdariRow(); + $hesabdariRow->setDes($row['des']); + $hesabdariRow->setBid($acc['bid']); + $hesabdariRow->setYear($acc['year']); + $hesabdariRow->setDoc($doc); + $hesabdariRow->setBs($row['sumWithoutTax'] + $row['tax']); + $hesabdariRow->setBd(0); + $hesabdariRow->setDiscount($row['discount']); + $hesabdariRow->setTax($row['tax']); + $ref = $entityManager->getRepository(HesabdariTable::class)->findOneBy([ + 'code' => '53' // rfbuy commodity + ]); + $hesabdariRow->setRef($ref); + $row['count'] = str_replace(',', '', $row['count']); + $commodity = $entityManager->getRepository(Commodity::class)->findOneBy([ + 'id' => $row['commodity']['id'], + 'bid' => $acc['bid'] + ]); + if (!$commodity) + return $this->json($extractor->paramsNotSend()); + $hesabdariRow->setCommodity($commodity); + $hesabdariRow->setCommdityCount($row['count']); + $entityManager->persist($hesabdariRow); + } + //set amount of document + $doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']); + //set person buyer + $hesabdariRow = new HesabdariRow(); + $hesabdariRow->setDes('فاکتور برگشت از خرید'); + $hesabdariRow->setBid($acc['bid']); + $hesabdariRow->setYear($acc['year']); + $hesabdariRow->setDoc($doc); + $hesabdariRow->setBs(0); + $hesabdariRow->setBd($sumTax + $sumTotal + $params['transferCost'] - $params['discountAll']); + $ref = $entityManager->getRepository(HesabdariTable::class)->findOneBy([ + 'code' => '3' // persons + ]); + $hesabdariRow->setRef($ref); + $person = $entityManager->getRepository(Person::class)->findOneBy([ + 'bid' => $acc['bid'], + 'code' => $params['buyer']['code'] + ]); + if (!$person) + return $this->json($extractor->paramsNotSend()); + $hesabdariRow->setPerson($person); + $entityManager->persist($hesabdariRow); + + //set tax info + + $entityManager->persist($doc); + $entityManager->flush(); + $log->insert( + 'حسابداری', + 'سند حسابداری شماره ' . $doc->getCode() . ' ثبت / ویرایش شد.', + $this->getUser(), + $request->headers->get('activeBid'), + $doc + ); + return $this->json($extractor->operationSuccess()); + } + + #[Route('/api/rfbuy/label/change', name: 'app_rfbuy_label_change')] + public function app_rfbuy_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('plugAccproRfbuy'); + if (!$acc) + throw $this->createAccessDeniedException(); + if ($params['label'] != 'clear') { + $label = $entityManager->getRepository(InvoiceType::class)->findOneBy([ + 'code' => $params['label']['code'], + 'type' => 'rfbuy' + ]); + 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/rfbuy/docs/search', name: 'app_rfbuy_docs_search')] + public function app_rfbuy_docs_search(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('plugAccproRfbuy'); + 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' => 'rfbuy' + ], [ + '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; + + foreach ($item->getHesabdariRows() as $item) { + if ($item->getRef()->getCode() == '104') { + $temp['discountAll'] = $item->getBd(); + } elseif ($item->getRef()->getCode() == '61') { + $temp['transferCost'] = $item->getBs(); + } + } + if(!array_key_exists('discountAll',$temp)) $temp['discountAll'] = 0; + if(!array_key_exists('transferCost',$temp)) $temp['transferCost'] = 0; + $dataTemp[] = $temp; + } + return $this->json($dataTemp); + } + + #[Route('/api/rfbuy/posprinter/invoice', name: 'app_rfbuy_posprinter_invoice')] + public function app_rfbuy_posprinter_invoice(Printers $printers, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + $acc = $access->hasRole('plugAccproRfbuy'); + if (!$acc) throw $this->createAccessDeniedException(); + + $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ + 'bid' => $acc['bid'], + 'code' => $params['code'] + ]); + if (!$doc) throw $this->createNotFoundException(); + $pdfPid = 0; + if ($params['pdf']) { + $pdfPid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/posPrinters/rfbuy.html.twig', [ + 'bid' => $acc['bid'], + 'doc'=>$doc, + 'rows'=>$doc->getHesabdariRows(), + 'printInvoice'=>$params['posPrint'], + 'printcashdeskRecp'=>$params['posPrintRecp'], + ]), + true + ); + } + + + if ($params['posPrint'] == true) { + $pid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/posPrinters/justSell.html.twig', [ + 'bid' => $acc['bid'], + 'doc' => $doc, + 'rows' => $doc->getHesabdariRows(), + ]), + true + ); + $printers->addFile($pid, $acc, "fastSellInvoice"); + } + if ($params['posPrintRecp'] == true) { + $pid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/posPrinters/cashdesk.html.twig', [ + 'bid' => $acc['bid'], + 'doc' => $doc, + 'rows' => $doc->getHesabdariRows(), + ]), + true + ); + $printers->addFile($pid, $acc, "fastSellCashdesk"); + } + + return $this->json(['id' => $pdfPid]); + } + + #[Route('/api/rfbuy/print/invoice', name: 'app_rfbuy_print_invoice')] + public function app_rfbuy_print_invoice(Printers $printers, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + $acc = $access->hasRole('plugAccproRfbuy'); + if (!$acc) throw $this->createAccessDeniedException(); + + $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ + 'bid' => $acc['bid'], + 'code' => $params['code'] + ]); + if (!$doc) throw $this->createNotFoundException(); + $person = null; + $discount = 0; + $transfer = 0; + foreach ($doc->getHesabdariRows() as $item) { + if ($item->getPerson()) { + $person = $item->getPerson(); + } elseif ($item->getRef()->getCode() == 104) { + $discount = $item->getBd(); + } elseif ($item->getRef()->getCode() == 61) { + $transfer = $item->getBs(); + } + } + $pdfPid = 0; + if ($params['pdf']) { + $printOptions = [ + 'bidInfo' => true, + 'pays' =>true, + 'taxInfo' =>true, + 'discountInfo' =>true, + 'note' =>true + ]; + if(array_key_exists('printOptions',$params)){ + if(array_key_exists('bidInfo',$params['printOptions'])){ + $printOptions['bidInfo'] = $params['printOptions']['bidInfo']; + } + if(array_key_exists('pays',$params['printOptions'])){ + $printOptions['pays'] = $params['printOptions']['pays']; + } + if(array_key_exists('taxInfo',$params['printOptions'])){ + $printOptions['taxInfo'] = $params['printOptions']['taxInfo']; + } + if(array_key_exists('discountInfo',$params['printOptions'])){ + $printOptions['discountInfo'] = $params['printOptions']['discountInfo']; + } + if(array_key_exists('note',$params['printOptions'])){ + $printOptions['note'] = $params['printOptions']['note']; + } + } + $note = ''; + $printSettings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid'=>$acc['bid']]); + if($printSettings){$note = $printSettings->getSellNoteString();} + $pdfPid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/printers/rfbuy.html.twig', [ + 'bid' => $acc['bid'], + 'doc' => $doc, + 'rows' => $doc->getHesabdariRows(), + 'person' => $person, + 'printInvoice' => $params['printers'], + 'discount' => $discount, + 'transfer' => $transfer, + 'printOptions'=> $printOptions, + 'note'=> $note + ]), + false + ); + } + if ($params['printers'] == true) { + $pid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/posPrinters/justSell.html.twig', [ + 'bid' => $acc['bid'], + 'doc' => $doc, + 'rows' => $doc->getHesabdariRows(), + ]), + false + ); + $printers->addFile($pid, $acc, "fastSellInvoice"); + } + return $this->json(['id' => $pdfPid]); } } diff --git a/hesabixCore/src/Controller/RfsellController.php b/hesabixCore/src/Controller/RfsellController.php index ad86d26..f74faaf 100644 --- a/hesabixCore/src/Controller/RfsellController.php +++ b/hesabixCore/src/Controller/RfsellController.php @@ -4,10 +4,19 @@ namespace App\Controller; use App\Service\Log; use App\Service\Access; +use App\Service\Explore; +use App\Entity\Commodity; +use App\Service\Provider; +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\PrintOptions; use App\Entity\StoreroomTicket; +use App\Service\Printers; use Doctrine\ORM\EntityManagerInterface; -use App\Service\Explore as ServiceExplore; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -55,6 +64,423 @@ class RfsellController extends AbstractController if(!$doc) throw $this->createNotFoundException(); - return $this->json(ServiceExplore::ExploreRfsellDoc($doc)); + return $this->json(Explore::ExploreBuyDoc($doc)); + } + + #[Route('/api/rfsell/get/invoices/list', name: 'app_rfsell_get_invoices_list')] + public function app_rfsell_get_invoices_list(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager, string $code): JsonResponse + { + $acc = $access->hasRole('plugAccproRfsell'); + if(!$acc) + throw $this->createAccessDeniedException(); + $invoices = $entityManager->getRepository(HesabdariDoc::class)->findBy([ + 'bid'=>$acc['bid'], + 'year'=>$acc['year'], + 'type'=>'rfsell' + ]); + return $this->json(Explore::ExploreBuyDocsList($invoices)); + } + + #[Route('/api/rfsell/mod', name: 'app_rfsell_mod')] + public function app_rfsell_mod(Provider $provider, Extractor $extractor, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + $acc = $access->hasRole('plugAccproRfsell'); + if (!$acc) + throw $this->createAccessDeniedException(); + + if (!array_key_exists('update', $params)) { + return $this->json($extractor->paramsNotSend()); + } + if ($params['update'] != '') { + $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ + 'bid' => $acc['bid'], + 'year' => $acc['year'], + 'code' => $params['update'] + ]); + if (!$doc) return $this->json($extractor->notFound()); + + $rows = $entityManager->getRepository(HesabdariRow::class)->findBy([ + 'doc' => $doc + ]); + foreach ($rows as $row) + $entityManager->remove($row); + } else { + $doc = new HesabdariDoc(); + $doc->setBid($acc['bid']); + $doc->setYear($acc['year']); + $doc->setDateSubmit(time()); + $doc->setType('rfsell'); + $doc->setSubmitter($this->getUser()); + $doc->setMoney($acc['bid']->getMoney()); + $doc->setCode($provider->getAccountingCode($acc['bid'], 'accounting')); + } + if($params['transferCost'] != 0){ + $hesabdariRow = new HesabdariRow(); + $hesabdariRow->setDes('حمل و نقل کالا'); + $hesabdariRow->setBid($acc['bid']); + $hesabdariRow->setYear($acc['year']); + $hesabdariRow->setDoc($doc); + $hesabdariRow->setBd($params['transferCost']); + $hesabdariRow->setBs(0); + $ref = $entityManager->getRepository(HesabdariTable::class)->findOneBy([ + 'code' => '90' // transfer cost income + ]); + $hesabdariRow->setRef($ref); + $entityManager->persist($hesabdariRow); + } + if($params['discountAll'] != 0){ + $hesabdariRow = new HesabdariRow(); + $hesabdariRow->setDes('تخفیف فاکتور'); + $hesabdariRow->setBid($acc['bid']); + $hesabdariRow->setYear($acc['year']); + $hesabdariRow->setDoc($doc); + $hesabdariRow->setBd(0); + $hesabdariRow->setBs($params['discountAll']); + $ref = $entityManager->getRepository(HesabdariTable::class)->findOneBy([ + 'code' => '104' // سایر هزینه های پخش و خرید + ]); + $hesabdariRow->setRef($ref); + $entityManager->persist($hesabdariRow); + } + $doc->setDes($params['des']); + $doc->setDate($params['date']); + $sumTax = 0; + $sumTotal = 0; + foreach ($params['rows'] as $row) { + $sumTax += $row['tax']; + $sumTotal += $row['sumWithoutTax']; + $hesabdariRow = new HesabdariRow(); + $hesabdariRow->setDes($row['des']); + $hesabdariRow->setBid($acc['bid']); + $hesabdariRow->setYear($acc['year']); + $hesabdariRow->setDoc($doc); + $hesabdariRow->setBd($row['sumWithoutTax'] + $row['tax']); + $hesabdariRow->setBs(0); + $hesabdariRow->setDiscount($row['discount']); + $hesabdariRow->setTax($row['tax']); + $ref = $entityManager->getRepository(HesabdariTable::class)->findOneBy([ + 'code' => '120' // commodity + ]); + $hesabdariRow->setRef($ref); + $row['count'] = str_replace(',', '', $row['count']); + $commodity = $entityManager->getRepository(Commodity::class)->findOneBy([ + 'id' => $row['commodity']['id'], + 'bid' => $acc['bid'] + ]); + if (!$commodity) + return $this->json($extractor->paramsNotSend()); + $hesabdariRow->setCommodity($commodity); + $hesabdariRow->setCommdityCount($row['count']); + $entityManager->persist($hesabdariRow); + } + //set amount of document + $doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']); + //set person buyer + $hesabdariRow = new HesabdariRow(); + $hesabdariRow->setDes('فاکتور برگشت از فروش'); + $hesabdariRow->setBid($acc['bid']); + $hesabdariRow->setYear($acc['year']); + $hesabdariRow->setDoc($doc); + $hesabdariRow->setBd(0); + $hesabdariRow->setBs($sumTax + $sumTotal + $params['transferCost'] - $params['discountAll']); + $ref = $entityManager->getRepository(HesabdariTable::class)->findOneBy([ + 'code' => '3' // persons + ]); + $hesabdariRow->setRef($ref); + $person = $entityManager->getRepository(Person::class)->findOneBy([ + 'bid' => $acc['bid'], + 'code' => $params['buyer']['code'] + ]); + if (!$person) + return $this->json($extractor->paramsNotSend()); + $hesabdariRow->setPerson($person); + $entityManager->persist($hesabdariRow); + + //set tax info + + $entityManager->persist($doc); + $entityManager->flush(); + $log->insert( + 'حسابداری', + 'سند حسابداری شماره ' . $doc->getCode() . ' ثبت / ویرایش شد.', + $this->getUser(), + $request->headers->get('activeBid'), + $doc + ); + return $this->json($extractor->operationSuccess()); + } + + #[Route('/api/rfsell/label/change', name: 'app_rfsell_label_change')] + public function app_rfsell_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('plugAccproRfsell'); + if (!$acc) + throw $this->createAccessDeniedException(); + if ($params['label'] != 'clear') { + $label = $entityManager->getRepository(InvoiceType::class)->findOneBy([ + 'code' => $params['label']['code'], + 'type' => 'rfsell' + ]); + 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/rfsell/docs/search', name: 'app_rfsell_docs_search')] + public function app_rfsell_docs_search(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('plugAccproRfsell'); + 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' => 'rfsell' + ], [ + '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; + + foreach ($item->getHesabdariRows() as $item) { + if ($item->getRef()->getCode() == '104') { + $temp['discountAll'] = $item->getBd(); + } elseif ($item->getRef()->getCode() == '90') { + $temp['transferCost'] = $item->getBs(); + } + } + if(!array_key_exists('discountAll',$temp)) $temp['discountAll'] = 0; + if(!array_key_exists('transferCost',$temp)) $temp['transferCost'] = 0; + $dataTemp[] = $temp; + } + return $this->json($dataTemp); + } + + #[Route('/api/rfsell/posprinter/invoice', name: 'app_rfsell_posprinter_invoice')] + public function app_rfsell_posprinter_invoice(Printers $printers, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + $acc = $access->hasRole('plugAccproRfsell'); + if (!$acc) throw $this->createAccessDeniedException(); + + $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ + 'bid' => $acc['bid'], + 'code' => $params['code'] + ]); + if (!$doc) throw $this->createNotFoundException(); + $pdfPid = 0; + if ($params['pdf']) { + $pdfPid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/posPrinters/rfsell.html.twig', [ + 'bid' => $acc['bid'], + 'doc'=>$doc, + 'rows'=>$doc->getHesabdariRows(), + 'printInvoice'=>$params['posPrint'], + 'printcashdeskRecp'=>$params['posPrintRecp'], + ]), + true + ); + } + + + if ($params['posPrint'] == true) { + $pid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/posPrinters/justSell.html.twig', [ + 'bid' => $acc['bid'], + 'doc' => $doc, + 'rows' => $doc->getHesabdariRows(), + ]), + true + ); + $printers->addFile($pid, $acc, "fastSellInvoice"); + } + if ($params['posPrintRecp'] == true) { + $pid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/posPrinters/cashdesk.html.twig', [ + 'bid' => $acc['bid'], + 'doc' => $doc, + 'rows' => $doc->getHesabdariRows(), + ]), + true + ); + $printers->addFile($pid, $acc, "fastSellCashdesk"); + } + + return $this->json(['id' => $pdfPid]); + } + + #[Route('/api/rfsell/print/invoice', name: 'app_rfsell_print_invoice')] + public function app_rfsell_print_invoice(Printers $printers, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + $acc = $access->hasRole('plugAccproRfsell'); + if (!$acc) throw $this->createAccessDeniedException(); + + $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ + 'bid' => $acc['bid'], + 'code' => $params['code'] + ]); + if (!$doc) throw $this->createNotFoundException(); + $person = null; + $discount = 0; + $transfer = 0; + foreach ($doc->getHesabdariRows() as $item) { + if ($item->getPerson()) { + $person = $item->getPerson(); + } elseif ($item->getRef()->getCode() == 104) { + $discount = $item->getBd(); + } elseif ($item->getRef()->getCode() == 61) { + $transfer = $item->getBs(); + } + } + $pdfPid = 0; + if ($params['pdf']) { + $printOptions = [ + 'bidInfo' => true, + 'pays' =>true, + 'taxInfo' =>true, + 'discountInfo' =>true, + 'note' =>true + ]; + if(array_key_exists('printOptions',$params)){ + if(array_key_exists('bidInfo',$params['printOptions'])){ + $printOptions['bidInfo'] = $params['printOptions']['bidInfo']; + } + if(array_key_exists('pays',$params['printOptions'])){ + $printOptions['pays'] = $params['printOptions']['pays']; + } + if(array_key_exists('taxInfo',$params['printOptions'])){ + $printOptions['taxInfo'] = $params['printOptions']['taxInfo']; + } + if(array_key_exists('discountInfo',$params['printOptions'])){ + $printOptions['discountInfo'] = $params['printOptions']['discountInfo']; + } + if(array_key_exists('note',$params['printOptions'])){ + $printOptions['note'] = $params['printOptions']['note']; + } + } + $note = ''; + $printSettings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid'=>$acc['bid']]); + if($printSettings){$note = $printSettings->getSellNoteString();} + $pdfPid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/printers/rfsell.html.twig', [ + 'bid' => $acc['bid'], + 'doc' => $doc, + 'rows' => $doc->getHesabdariRows(), + 'person' => $person, + 'printInvoice' => $params['printers'], + 'discount' => $discount, + 'transfer' => $transfer, + 'printOptions'=> $printOptions, + 'note'=> $note + ]), + false + ); + } + if ($params['printers'] == true) { + $pid = $provider->createPrint( + $acc['bid'], + $this->getUser(), + $this->renderView('pdf/posPrinters/justSell.html.twig', [ + 'bid' => $acc['bid'], + 'doc' => $doc, + 'rows' => $doc->getHesabdariRows(), + ]), + false + ); + $printers->addFile($pid, $acc, "fastSellInvoice"); + } + return $this->json(['id' => $pdfPid]); } } diff --git a/hesabixCore/src/Entity/PrintOptions.php b/hesabixCore/src/Entity/PrintOptions.php index 74a6e6d..f542ea9 100644 --- a/hesabixCore/src/Entity/PrintOptions.php +++ b/hesabixCore/src/Entity/PrintOptions.php @@ -36,6 +36,60 @@ class PrintOptions #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $sellNoteString = null; + #[ORM\Column] + private ?bool $buyBidInfo = null; + + #[ORM\Column(nullable: true)] + private ?bool $buyTaxInfo = null; + + #[ORM\Column(nullable: true)] + private ?bool $buyDiscountInfo = null; + + #[ORM\Column(nullable: true)] + private ?bool $buyNote = null; + + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $buyNoteString = null; + + #[ORM\Column(nullable: true)] + private ?bool $buyPays = null; + + #[ORM\Column(nullable: true)] + private ?bool $RfbuyBidInfo = null; + + #[ORM\Column(nullable: true)] + private ?bool $RfbuyTaxInfo = null; + + #[ORM\Column(nullable: true)] + private ?bool $RfbuyDiscountInfo = null; + + #[ORM\Column(nullable: true)] + private ?bool $RfbuyNote = null; + + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $RfbuyNoteString = null; + + #[ORM\Column(nullable: true)] + private ?bool $RfBuyPays = null; + + #[ORM\Column(nullable: true)] + private ?bool $RfsellBidInfo = null; + + #[ORM\Column(nullable: true)] + private ?bool $RfsellTaxInfo = null; + + #[ORM\Column(nullable: true)] + private ?bool $RfsellDiscountInfo = null; + + #[ORM\Column(nullable: true)] + private ?bool $RfsellNote = null; + + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $RfsellNoteString = null; + + #[ORM\Column(nullable: true)] + private ?bool $RfsellPays = null; + public function getId(): ?int { return $this->id; @@ -124,4 +178,220 @@ class PrintOptions return $this; } + + public function isBuyBidInfo(): ?bool + { + return $this->buyBidInfo; + } + + public function setBuyBidInfo(bool $buyBidInfo): static + { + $this->buyBidInfo = $buyBidInfo; + + return $this; + } + + public function isBuyTaxInfo(): ?bool + { + return $this->buyTaxInfo; + } + + public function setBuyTaxInfo(?bool $buyTaxInfo): static + { + $this->buyTaxInfo = $buyTaxInfo; + + return $this; + } + + public function isBuyDiscountInfo(): ?bool + { + return $this->buyDiscountInfo; + } + + public function setBuyDiscountInfo(?bool $buyDiscountInfo): static + { + $this->buyDiscountInfo = $buyDiscountInfo; + + return $this; + } + + public function isBuyNote(): ?bool + { + return $this->buyNote; + } + + public function setBuyNote(?bool $buyNote): static + { + $this->buyNote = $buyNote; + + return $this; + } + + public function getBuyNoteString(): ?string + { + return $this->buyNoteString; + } + + public function setBuyNoteString(?string $buyNoteString): static + { + $this->buyNoteString = $buyNoteString; + + return $this; + } + + public function isBuyPays(): ?bool + { + return $this->buyPays; + } + + public function setBuyPays(?bool $buyPays): static + { + $this->buyPays = $buyPays; + + return $this; + } + + public function isRfbuyBidInfo(): ?bool + { + return $this->RfbuyBidInfo; + } + + public function setRfbuyBidInfo(?bool $RfbuyBidInfo): static + { + $this->RfbuyBidInfo = $RfbuyBidInfo; + + return $this; + } + + public function isRfbuyTaxInfo(): ?bool + { + return $this->RfbuyTaxInfo; + } + + public function setRfbuyTaxInfo(?bool $RfbuyTaxInfo): static + { + $this->RfbuyTaxInfo = $RfbuyTaxInfo; + + return $this; + } + + public function isRfbuyDiscountInfo(): ?bool + { + return $this->RfbuyDiscountInfo; + } + + public function setRfbuyDiscountInfo(?bool $RfbuyDiscountInfo): static + { + $this->RfbuyDiscountInfo = $RfbuyDiscountInfo; + + return $this; + } + + public function isRfbuyNote(): ?bool + { + return $this->RfbuyNote; + } + + public function setRfbuyNote(?bool $RfbuyNote): static + { + $this->RfbuyNote = $RfbuyNote; + + return $this; + } + + public function getRfbuyNoteString(): ?string + { + return $this->RfbuyNoteString; + } + + public function setRfbuyNoteString(?string $RfbuyNoteString): static + { + $this->RfbuyNoteString = $RfbuyNoteString; + + return $this; + } + + public function isRfBuyPays(): ?bool + { + return $this->RfBuyPays; + } + + public function setRfBuyPays(?bool $RfBuyPays): static + { + $this->RfBuyPays = $RfBuyPays; + + return $this; + } + + public function isRfsellBidInfo(): ?bool + { + return $this->RfsellBidInfo; + } + + public function setRfsellBidInfo(?bool $RfsellBidInfo): static + { + $this->RfsellBidInfo = $RfsellBidInfo; + + return $this; + } + + public function isRfsellTaxInfo(): ?bool + { + return $this->RfsellTaxInfo; + } + + public function setRfsellTaxInfo(?bool $RfsellTaxInfo): static + { + $this->RfsellTaxInfo = $RfsellTaxInfo; + + return $this; + } + + public function isRfsellDiscountInfo(): ?bool + { + return $this->RfsellDiscountInfo; + } + + public function setRfsellDiscountInfo(?bool $RfsellDiscountInfo): static + { + $this->RfsellDiscountInfo = $RfsellDiscountInfo; + + return $this; + } + + public function isRfsellNote(): ?bool + { + return $this->RfsellNote; + } + + public function setRfsellNote(?bool $RfsellNote): static + { + $this->RfsellNote = $RfsellNote; + + return $this; + } + + public function getRfsellNoteString(): ?string + { + return $this->RfsellNoteString; + } + + public function setRfsellNoteString(?string $RfsellNoteString): static + { + $this->RfsellNoteString = $RfsellNoteString; + + return $this; + } + + public function isRfsellPays(): ?bool + { + return $this->RfsellPays; + } + + public function setRfsellPays(?bool $RfsellPays): static + { + $this->RfsellPays = $RfsellPays; + + return $this; + } } diff --git a/hesabixCore/templates/pdf/printers/buy.html.twig b/hesabixCore/templates/pdf/printers/buy.html.twig index d7db8a7..905fec2 100644 --- a/hesabixCore/templates/pdf/printers/buy.html.twig +++ b/hesabixCore/templates/pdf/printers/buy.html.twig @@ -3,12 +3,6 @@ @@ -35,7 +29,7 @@ -

فاکتور خرید کالا و خدمات

+

صورتحساب خرید کالا و خدمات

@@ -51,69 +45,75 @@ -
-
- خریدار -
- - - - - - - - - - - - - - -
-

- نام: - - {{ bid.legalName }} -

-
-

- شناسه ملی: - - {{ bid.shenasemeli }} -

-
-

- شماره ثبت: - - {{ bid.shomaresabt }} -

-
-

- شماره اقتصادی: - - {{ bid.codeeghtesadi }} -

-
-

- تلفن / نمابر: - {{ bid.tel }} -

-
-

- کد پستی: - {{ bid.postalcode }} -

-
-

- آدرس: - - استان - {{ bid.ostan }}، شهر - {{ bid.shahrestan }}، - {{ bid.address }} -

-
-
+{% if printOptions.bidInfo %} + +
+
+ خریدار +
+ + + + + + + + + + + + + + +
+

+ نام: + + {{ bid.legalName }} +

+
+

+ + شناسه ملی: + + {{ bid.shenasemeli }} +

+
+

+ شماره ثبت: + + {{ bid.shomaresabt }} +

+
+

+ شماره اقتصادی: + + {{ bid.codeeghtesadi }} +

+
+

+ تلفن / نمابر: + {{ bid.tel }} +

+
+

+ کد پستی: + {{ bid.postalcode }} +

+
+

+ آدرس: + + استان + {{ bid.ostan }}، شهر + {{ bid.shahrestan }}، + {{ bid.address }} +

+
+
+ +{% endif %} +
فروشنده @@ -186,8 +186,12 @@ شرح تعداد / مقدار مبلغ واحد - تخفیف - مالیات + {% if printOptions.discountInfo %} + تخفیف + {% endif %} + {% if printOptions.taxInfo %} + مالیات + {% endif %} مبلغ کل @@ -209,10 +213,14 @@ {{ item.commdityCount }} {{ item.commodity.unit.name }} - {{ ((item.bd - item.tax + item.discount) / item.commdityCount) | number_format }} - {{ item.discount | number_format }} - {{ item.tax | number_format}} - {{ item.bd| number_format }} + {{ ((item.bs - item.tax + item.discount) / item.commdityCount) | number_format }} + {% if printOptions.discountInfo %} + {{ item.discount | number_format }} + {% endif %} + {% if printOptions.taxInfo %} + {{ item.tax | number_format}} + {% endif %} + {{ item.bs| number_format }} {% endif %} {% endfor %} @@ -223,44 +231,63 @@ - + - - - - - - -
+ +

+ توضیحات: + {{doc.des}} +
+ {% if (doc.relatedDocs | length != 0) and (printOptions.pays == true) %} +

+ پرداخت‌ها: +

+
    + {% for item in doc.relatedDocs%} +
  • + {{item.date}} - {{ item.amount | number_format }} - {{ item.des }} +
  • + {% endfor %} +
+ {% endif %} + {% if printOptions.note == true %} +

+ یاداشت: +

+
    +
  • + {{note}} +
  • +
+ {% endif %} + + +

تخفیف: {{discount | number_format}}

-

مالیات: {{taxAll | number_format}}

-

حمل و نقل: {{transfer | number_format}}

-

- جمع کل: - {{doc.amount | number_format}} + مبلغ کل بدون تخفیف: + {{ (doc.amount + discount) | number_format}}

-

- توضیحات: - {{doc.des}} + جمع کل قابل پرداخت: + {{ doc.amount | number_format }}

-
-
+
+
diff --git a/hesabixCore/templates/pdf/printers/rfbuy.html.twig b/hesabixCore/templates/pdf/printers/rfbuy.html.twig new file mode 100644 index 0000000..eee5c16 --- /dev/null +++ b/hesabixCore/templates/pdf/printers/rfbuy.html.twig @@ -0,0 +1,311 @@ + + + + + + + +
+
+
+
+ + + + + + + +
+ + +

صورتحساب برگشت از خرید کالا و خدمات

+
+

+ تاریخ: + {{ doc.date }}

+
+

+ شماره: + {{ doc.code }}

+ +
+
+{% if printOptions.bidInfo %} + +
+
+ خریدار +
+ + + + + + + + + + + + + + +
+

+ نام: + + {{ bid.legalName }} +

+
+

+ + شناسه ملی: + + {{ bid.shenasemeli }} +

+
+

+ شماره ثبت: + + {{ bid.shomaresabt }} +

+
+

+ شماره اقتصادی: + + {{ bid.codeeghtesadi }} +

+
+

+ تلفن / نمابر: + {{ bid.tel }} +

+
+

+ کد پستی: + {{ bid.postalcode }} +

+
+

+ آدرس: + + استان + {{ bid.ostan }}، شهر + {{ bid.shahrestan }}، + {{ bid.address }} +

+
+
+ +{% endif %} + +
+
+ فروشنده +
+ + + + + + + + + + + + + + +
+

+ نام: + + {{ person.nikename }} +

+
+

+ شناسه ملی: + + {{ person.shenasemeli }} +

+
+

+ شماره ثبت: + + {{ person.sabt }} +

+
+

+ شماره اقتصادی: + + {{ person.codeeghtesadi }} +

+
+

+ تلفن / نمابر: + {{ person.tel }} +

+
+

+ کد پستی: + {{ person.postalcode }} +

+
+

+ آدرس: + + استان + {{ person.ostan }}، شهر + {{ person.shahr }}، + {{ person.address }} +

+
+
+
+ + + + + + + + + {% if printOptions.discountInfo %} + + {% endif %} + {% if printOptions.taxInfo %} + + {% endif %} + + + + + {% set taxAll = 0 %} + {% set rowIndex = 0 %} + {% for item in rows%} + {% if item.commodity %} + {% set taxAll = taxAll + item.tax %} + {% set rowIndex = rowIndex + 1 %} + + + + + + + {% if printOptions.discountInfo %} + + {% endif %} + {% if printOptions.taxInfo %} + + {% endif %} + + + {% endif %} + {% endfor %} + +
ردیفکالا/خدماتشرحتعداد / مقدارمبلغ واحدتخفیفمالیاتمبلغ کل
{{rowIndex}} + {{ item.commodity.code }} + - + {{ item.commodity.name }}{{ item.des }} + {{ item.commdityCount }} + {{ item.commodity.unit.name }} + {{ ((item.bs - item.tax + item.discount) / item.commdityCount) | number_format }}{{ item.discount | number_format }}{{ item.tax | number_format}}{{ item.bs| number_format }}
+
+
+ + + + + + + +
+

+ توضیحات: + {{doc.des}} +
+ {% if (doc.relatedDocs | length != 0) and (printOptions.pays == true) %} +

+ پرداخت‌ها: +

+
    + {% for item in doc.relatedDocs%} +
  • + {{item.date}} - {{ item.amount | number_format }} - {{ item.des }} +
  • + {% endfor %} +
+ {% endif %} + {% if printOptions.note == true %} +

+ یاداشت: +

+
    +
  • + {{note}} +
  • +
+ {% endif %} + + +
+

+ تخفیف: + {{discount | number_format}} +

+

+ مالیات: + {{taxAll | number_format}} +

+

+ حمل و نقل: + {{transfer | number_format}} +

+

+ مبلغ کل بدون تخفیف: + {{ (doc.amount + discount) | number_format}} +

+

+ جمع کل قابل پرداخت: + {{ doc.amount | number_format }} +

+
+
+
+ + + + + + + +
+

+ مهر و امضا خریدار +

+
+

+ مهر و امضا فروشنده: +

+
+
+
+ + + diff --git a/hesabixCore/templates/pdf/printers/rfsell.html.twig b/hesabixCore/templates/pdf/printers/rfsell.html.twig new file mode 100644 index 0000000..3f52e54 --- /dev/null +++ b/hesabixCore/templates/pdf/printers/rfsell.html.twig @@ -0,0 +1,311 @@ + + + + + + + +
+
+
+ + + + + + + + +
+ + +

صورتحساب برگشت از فروش کالا و خدمات

+
+

+ تاریخ: + {{ doc.date }}

+
+

+ شماره: + {{ doc.code }}

+ +
+
+{% if printOptions.bidInfo %} + +
+
+ فروشنده +
+ + + + + + + + + + + + + + +
+

+ نام: + + {{ bid.legalName }} +

+
+

+ + شناسه ملی: + + {{ bid.shenasemeli }} +

+
+

+ شماره ثبت: + + {{ bid.shomaresabt }} +

+
+

+ شماره اقتصادی: + + {{ bid.codeeghtesadi }} +

+
+

+ تلفن / نمابر: + {{ bid.tel }} +

+
+

+ کد پستی: + {{ bid.postalcode }} +

+
+

+ آدرس: + + استان + {{ bid.ostan }}، شهر + {{ bid.shahrestan }}، + {{ bid.address }} +

+
+
+ +{% endif %} + +
+
+ خریدار +
+ + + + + + + + + + + + + + +
+

+ نام: + + {{ person.nikename }} +

+
+

+ شناسه ملی: + + {{ person.shenasemeli }} +

+
+

+ شماره ثبت: + + {{ person.sabt }} +

+
+

+ شماره اقتصادی: + + {{ person.codeeghtesadi }} +

+
+

+ تلفن / نمابر: + {{ person.tel }} +

+
+

+ کد پستی: + {{ person.postalcode }} +

+
+

+ آدرس: + + استان + {{ person.ostan }}، شهر + {{ person.shahr }}، + {{ person.address }} +

+
+
+
+ + + + + + + + + {% if printOptions.discountInfo %} + + {% endif %} + {% if printOptions.taxInfo %} + + {% endif %} + + + + + {% set taxAll = 0 %} + {% set rowIndex = 0 %} + {% for item in rows%} + {% if item.commodity %} + {% set taxAll = taxAll + item.tax %} + {% set rowIndex = rowIndex + 1 %} + + + + + + + {% if printOptions.discountInfo %} + + {% endif %} + {% if printOptions.taxInfo %} + + {% endif %} + + + {% endif %} + {% endfor %} + +
ردیفکالا/خدماتشرحتعداد / مقدارمبلغ واحدتخفیفمالیاتمبلغ کل
{{rowIndex}} + {{ item.commodity.code }} + - + {{ item.commodity.name }}{{ item.des }} + {{ item.commdityCount }} + {{ item.commodity.unit.name }} + {{ ((item.bs - item.tax + item.discount) / item.commdityCount) | number_format }}{{ item.discount | number_format }}{{ item.tax | number_format}}{{ item.bs| number_format }}
+
+
+ + + + + + + +
+

+ توضیحات: + {{doc.des}} +
+ {% if (doc.relatedDocs | length != 0) and (printOptions.pays == true) %} +

+ پرداخت‌ها: +

+
    + {% for item in doc.relatedDocs%} +
  • + {{item.date}} - {{ item.amount | number_format }} - {{ item.des }} +
  • + {% endfor %} +
+ {% endif %} + {% if printOptions.note == true %} +

+ یاداشت: +

+
    +
  • + {{note}} +
  • +
+ {% endif %} + + +
+

+ تخفیف: + {{discount | number_format}} +

+

+ مالیات: + {{taxAll | number_format}} +

+

+ حمل و نقل: + {{transfer | number_format}} +

+

+ مبلغ کل بدون تخفیف: + {{ (doc.amount + discount) | number_format}} +

+

+ جمع کل قابل پرداخت: + {{ doc.amount | number_format }} +

+
+
+
+ + + + + + + +
+

+ مهر و امضا خریدار +

+
+

+ مهر و امضا فروشنده: +

+
+
+
+ +
+