From c630bc7dca737b7a3d7590bd52a1a75bb25b150c Mon Sep 17 00:00:00 2001 From: Babak Alizadeh Date: Sun, 13 Apr 2025 13:09:35 +0000 Subject: [PATCH] almost finish preinvoice and cheque parts --- hesabixCore/config/services.yaml | 3 + .../src/Controller/PreinvoiceController.php | 776 +++----- hesabixCore/src/Controller/YearController.php | 6 +- hesabixCore/src/Entity/PreInvoiceDoc.php | 127 ++ hesabixCore/src/Entity/PreInvoiceItem.php | 146 +- hesabixCore/src/Entity/Year.php | 7 + .../src/Twig/NumberFormatExtension.php | 25 + .../pdf/posPrinters/justPreinvoice.html.twig | 98 + .../pdf/printers/preinvoice.html.twig | 278 +++ .../src/components/forms/Hcommoditysearch.vue | 527 ++++++ webUI/src/components/forms/Hnumberinput.vue | 11 +- webUI/src/i18n/en_lang.ts | 15 +- webUI/src/i18n/fa_lang.ts | 6 + webUI/src/views/acc/App.vue | 27 +- webUI/src/views/acc/component/mostdes.vue | 57 +- webUI/src/views/acc/presell/list.vue | 412 ++-- webUI/src/views/acc/presell/mod.vue | 1675 +++++++---------- webUI/src/views/acc/presell/view.vue | 170 ++ webUI/src/views/acc/presell/viewInvoice.vue | 1054 +++++------ 19 files changed, 2906 insertions(+), 2514 deletions(-) create mode 100644 hesabixCore/src/Twig/NumberFormatExtension.php create mode 100644 hesabixCore/templates/pdf/posPrinters/justPreinvoice.html.twig create mode 100644 hesabixCore/templates/pdf/printers/preinvoice.html.twig create mode 100644 webUI/src/components/forms/Hcommoditysearch.vue create mode 100644 webUI/src/views/acc/presell/view.vue diff --git a/hesabixCore/config/services.yaml b/hesabixCore/config/services.yaml index f7bc1f3..1567675 100644 --- a/hesabixCore/config/services.yaml +++ b/hesabixCore/config/services.yaml @@ -92,3 +92,6 @@ services: Printers: class: App\Service\Printers arguments: [ '@doctrine.orm.entity_manager' ] + + App\Twig\NumberFormatExtension: + tags: ['twig.extension'] diff --git a/hesabixCore/src/Controller/PreinvoiceController.php b/hesabixCore/src/Controller/PreinvoiceController.php index f910fd7..da190f1 100644 --- a/hesabixCore/src/Controller/PreinvoiceController.php +++ b/hesabixCore/src/Controller/PreinvoiceController.php @@ -2,7 +2,6 @@ namespace App\Controller; -use App\Entity\PreInvoiceDoc; use App\Service\Log; use App\Service\Access; use App\Service\Explore; @@ -10,8 +9,8 @@ use App\Entity\Commodity; use App\Service\PluginService; use App\Service\Provider; use App\Service\Extractor; -use App\Entity\HesabdariDoc; -use App\Entity\HesabdariRow; +use App\Entity\PreInvoiceDoc; +use App\Entity\PreInvoiceItem; use App\Entity\HesabdariTable; use App\Entity\InvoiceType; use App\Entity\Person; @@ -29,524 +28,282 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; class PreinvoiceController extends AbstractController { - - #[Route('/api/presell/get/info/{code}', name: 'app_sell_get_info')] - public function app_sell_get_info(Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, string $code): JsonResponse + + private $access; + private $extractor; + + public function __construct(Access $access, Extractor $extractor) { - $acc = $access->hasRole('sell'); - if (!$acc) - throw $this->createAccessDeniedException(); - $doc = $entityManager->getRepository(PreInvoiceDoc::class)->findOneBy([ - 'bid' => $acc['bid'], - 'code' => $code, - 'money'=> $acc['money'] - ]); - if (!$doc) - throw $this->createNotFoundException(); - $result = Explore::ExploreSellDoc($doc); - $profit = 0; - //calculate profit - foreach ($doc->getHesabdariRows() as $item) { - if ($item->getCommodity() && $item->getCommdityCount()) { - if ($acc['bid']->getProfitCalctype() == 'simple') { - $profit = $profit + (($item->getCommodity()->getPriceSell() - $item->getCommodity()->getPriceSell()) * $item->getCommdityCount()); - } - elseif ($acc['bid']->getProfitCalctype() == 'lis') { - $last = $entityManager->getRepository(HesabdariRow::class)->findOneBy([ - 'commodity' => $item->getCommodity(), - 'bs' => 0 - ], [ - 'id' => 'DESC' - ]); - if ($last) { - $price = $last->getBd() / $last->getCommdityCount(); - $profit = $profit + ((($item->getBs() / $item->getCommdityCount()) - $price) * $item->getCommdityCount()); - } else { - $profit = $profit + $item->getBs(); - } - } else { - $lasts = $entityManager->getRepository(HesabdariRow::class)->findBy([ - 'commodity' => $item->getCommodity(), - 'bs' => 0 - ], [ - 'id' => 'DESC' - ]); - $avg = 0; - $count = 0; - foreach ($lasts as $last) { - $avg = $avg + $last->getBd(); - $count = $count + $last->getCommdityCount(); - } - if ($count != 0) { - $price = $avg / $count; - $profit = $profit + ((($item->getBs() / $item->getCommdityCount()) - $price) * $item->getCommdityCount()); - } - else{ - $profit = $profit + $item->getBs(); - } - - } - - //round output - $profit = round($profit); - } - } - $result['profit'] = $profit; - return $this->json($result); + $this->access = $access; + $this->extractor = $extractor; } - #[Route('/api/presell/mod', name: 'app_sell_mod')] - public function app_sell_mod(registryMGR $registryMGR, PluginService $pluginService, SMS $SMS, Provider $provider, Extractor $extractor, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + + #[Route('/api/preinvoice/get/{id}', name: 'app_preinvoice_get')] + public function getPreinvoice(EntityManagerInterface $entityManager, int $id): JsonResponse { - $params = []; - if ($content = $request->getContent()) { - $params = json_decode($content, true); + $acc = $this->access->hasRole('preinvoice'); + if (!$acc) { + return new JsonResponse($this->extractor->operationFail('دسترسی ندارید'), 403); } - - $acc = $access->hasRole('sell'); - if (!$acc) - throw $this->createAccessDeniedException(); - - if (!array_key_exists('update', $params)) { - return $this->json($extractor->paramsNotSend()); + + $preinvoice = $entityManager->getRepository(PreInvoiceDoc::class)->findOneBy(['code' => $id, 'bid' => $acc['bid'], 'year' => $acc['year']]); + if (!$preinvoice) { + return new JsonResponse(['error' => 'پیش فاکتور یافت نشد'], 404); } - if ($params['update'] != '') { - $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ - 'bid' => $acc['bid'], - 'year' => $acc['year'], - 'code' => $params['update'], - 'money'=> $acc['money'] - ]); - if (!$doc) - return $this->json($extractor->notFound()); - - $rows = $doc->getHesabdariRows(); - foreach ($rows as $row) - $entityManager->remove($row); - } else { - $doc = new HesabdariDoc(); - $doc->setBid($acc['bid']); - $doc->setYear($acc['year']); - $doc->setDateSubmit(time()); - $doc->setType('sell'); - $doc->setSubmitter($this->getUser()); - $doc->setMoney($acc['money']); - $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' // sell 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); - - //update commodity price for auto update price option - if ($acc['bid']->isCommodityUpdateSellPriceAuto() == true && $commodity->getPriceSell() != $row['price']) { - $commodity->setPriceSell($row['price']); - $entityManager->persist($commodity); - } - } - //set amount of document - $doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']); - //set person person - $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['person']['code'] - ]); - if (!$person) - return $this->json($extractor->paramsNotSend()); - $hesabdariRow->setPerson($person); - $entityManager->persist($hesabdariRow); - - //set tax info - - $entityManager->persist($doc); - $entityManager->flush(); - if(!$doc->getShortlink()){ - $doc->setShortlink($provider->RandomString(8)); - } - - //add pair docs - if(array_key_exists('pair_docs',$params)){ - foreach($params['pair_docs'] as $pairCode){ - $pair = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ - 'bid'=>$acc['bid'], - 'code'=>$pairCode, - 'type'=>'buy' - ]); - if($pair){ - $doc->addPairDoc($pair); - } - } - } - $entityManager->persist($doc); - $entityManager->flush(); - - $log->insert( - 'حسابداری', - 'سند حسابداری شماره ' . $doc->getCode() . ' ثبت / ویرایش شد.', - $this->getUser(), - $request->headers->get('activeBid'), - $doc - ); - //send sms to customer - if (array_key_exists('sms', $params)) { - if ($params['sms'] == true) { - if ($pluginService->isActive('accpro', $acc['bid']) && $person->getMobile() != '' && $acc['bid']->getTel()) { - return $this->json([ - 'result' => - $SMS->sendByBalance( - [$person->getnikename(), 'sell/' . $acc['bid']->getId() . '/' . $doc->getId(), $acc['bid']->getName(), $acc['bid']->getTel()], - $registryMGR->get('sms', 'plugAccproSharefaktor'), - $person->getMobile(), - $acc['bid'], - $this->getUser(), - 3 - ) - ]); - } else { - return $this->json([ - 'result' => - $SMS->sendByBalance( - [$acc['bid']->getName(), 'sell/' . $acc['bid']->getId() . '/' . $doc->getId()], - $registryMGR->get('sms', 'sharefaktor'), - $person->getMobile(), - $acc['bid'], - $this->getUser(), - 3 - ) - ]); - } - } - } - return $this->json($extractor->operationSuccess()); - } - - #[Route('/api/presell/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'], - 'money'=> $acc['money'] - ]); - 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/presell/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', - 'money'=> $acc['money'] - ], [ - '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() + + $data = [ + 'id' => $preinvoice->getId(), + 'code' => $preinvoice->getCode(), + 'date' => $preinvoice->getDate(), + 'des' => $preinvoice->getDes(), + 'person' => Explore::ExplorePerson($preinvoice->getPerson()), + 'amount' => $preinvoice->getAmount(), + 'taxPercent' => $preinvoice->getTaxPercent(), + 'totalDiscount' => $preinvoice->getTotalDiscount(), + 'totalDiscountPercent' => $preinvoice->getTotalDiscountPercent(), + 'shippingCost' => $preinvoice->getShippingCost(), + 'showPercentDiscount' => $preinvoice->isShowPercentDiscount(), + 'showTotalPercentDiscount' => $preinvoice->isShowTotalPercentDiscount(), + 'items' => array_map(function($item) { + return [ + 'id' => $item->getId(), + 'commodity' => [ + 'id' => $item->getCommodity()->getId(), + 'name' => $item->getCommodity()->getName() + ], + 'count' => $item->getCommodityCount(), + 'price' => $item->getBs(), + 'discountPercent' => $item->getDiscountPercent(), + 'discountAmount' => $item->getDiscountAmount(), + 'description' => $item->getDes(), + 'showPercentDiscount' => $item->isShowPercentDiscount() ]; - } + }, $preinvoice->getPreInvoiceItems()->toArray()) + ]; - $temp['relatedDocsCount'] = count($item->getRelatedDocs()); - $pays = 0; - foreach ($item->getRelatedDocs() as $relatedDoc) { - $pays += $relatedDoc->getAmount(); - } - $temp['relatedDocsPays'] = $pays; - // this variable is for store profit of invoice - $temp['profit'] = 0; - foreach ($item->getHesabdariRows() as $item) { - if ($item->getRef()->getCode() == '104') { - $temp['discountAll'] = $item->getBd(); - } elseif ($item->getRef()->getCode() == '61') { - $temp['transferCost'] = $item->getBs(); - } - - //calculate profit - if ($item->getCommodity() && $item->getCommdityCount()) { - if ($acc['bid']->getProfitCalctype() == 'lis') { - $last = $entityManager->getRepository(HesabdariRow::class)->findOneBy([ - 'commodity' => $item->getCommodity(), - 'bs' => 0 - ], [ - 'id' => 'DESC' - ]); - if ($last) { - $price = $last->getBd() / $last->getCommdityCount(); - $temp['profit'] = $temp['profit'] + ((($item->getBs() / $item->getCommdityCount()) - $price) * $item->getCommdityCount()); - } else { - $temp['profit'] = $temp['profit'] + $item->getBs(); - } - } else { - $lasts = $entityManager->getRepository(HesabdariRow::class)->findBy([ - 'commodity' => $item->getCommodity(), - 'bs' => 0 - ], [ - 'id' => 'DESC' - ]); - $avg = 0; - $count = 0; - foreach ($lasts as $last) { - $avg = $avg + $last->getBd(); - $count = $count + $last->getCommdityCount(); - } - if ($count != 0) { - $price = $avg / $count; - $temp['profit'] = $temp['profit'] + ((($item->getBs() / $item->getCommdityCount()) - $price) * $item->getCommdityCount()); - } - else{ - $temp['profit'] = $temp['profit'] + $item->getBs(); - } - } - - //round output - $temp['profit'] = round($temp['profit']); - } - - } - if (!array_key_exists('discountAll', $temp)) - $temp['discountAll'] = 0; - if (!array_key_exists('transferCost', $temp)) - $temp['transferCost'] = 0; - $dataTemp[] = $temp; - } - return $this->json($dataTemp); + return new JsonResponse($data); } - #[Route('/api/presell/posprinter/invoice', name: 'app_sell_posprinter_invoice')] - public function app_sell_posprinter_invoice(Printers $printers, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + #[Route('/api/preinvoice/save', name: 'app_preinvoice_save')] + public function savePreinvoice(Access $access,Provider $provider, Log $log, EntityManagerInterface $entityManager, Request $request): JsonResponse + { + $acc = $access->hasRole('preinvoice'); + if (!$acc) { + return new JsonResponse($this->extractor->operationFail('دسترسی ندارید'), 403); + } + + $data = json_decode($request->getContent(), true); + + if (isset($data['id']) && $data['id']) { + $preinvoice = $entityManager->getRepository(PreInvoiceDoc::class)->findOneBy(['code' => $data['id'], 'bid' => $acc['bid'], 'year' => $acc['year']]); + if (!$preinvoice) { + return new JsonResponse(['error' => 'پیش فاکتور یافت نشد'], 404); + } + } else { + $preinvoice = new PreInvoiceDoc(); + $preinvoice->setCode($this->generateCode($entityManager)); + $preinvoice->setSubmitter($this->getUser()); + $preinvoice->setYear($acc['year']); + $preinvoice->setBid($acc['bid']); + $preinvoice->setMoney($acc['money']); + $preinvoice->setStatus(1); + + $preinvoice->setCode($provider->getAccountingCode($acc['bid'], 'accounting')); + } + + $person = $entityManager->getRepository(Person::class)->find($data['person']); + if (!$person) { + return new JsonResponse(['error' => 'شخص یافت نشد'], 404); + } + + $preinvoice->setPerson($person); + $preinvoice->setDate($data['date']); + $preinvoice->setDes($data['des']); + $preinvoice->setAmount($data['amount']); + $preinvoice->setTaxPercent($data['taxPercent']); + $preinvoice->setTotalDiscount($data['totalDiscount']); + $preinvoice->setTotalDiscountPercent($data['totalDiscountPercent']); + $preinvoice->setShippingCost($data['shippingCost']); + $preinvoice->setShowPercentDiscount($data['showPercentDiscount']); + $preinvoice->setShowTotalPercentDiscount($data['showTotalPercentDiscount']); + + $entityManager->persist($preinvoice); + $entityManager->flush(); + + // حذف آیتم‌های قبلی + if (isset($data['id']) && $data['id']) { + foreach ($preinvoice->getPreInvoiceItems() as $oldItem) { + $entityManager->remove($oldItem); + } + } + + // اضافه کردن آیتم‌های جدید + foreach ($data['items'] as $itemData) { + $item = new PreInvoiceItem(); + $commodity = $entityManager->getRepository(Commodity::class)->find($itemData['commodity']); + if (!$commodity) { + continue; + } + + $item->setCommodity($commodity); + $item->setCommodityCount($itemData['count']); + $item->setBs($itemData['price']); + $item->setDiscountPercent($itemData['discountPercent']); + $item->setDiscountAmount($itemData['discountAmount']); + $item->setDes($itemData['description']); + $item->setShowPercentDiscount($itemData['showPercentDiscount']); + $item->setDoc($preinvoice); + $entityManager->persist($item); + } + + $entityManager->flush(); + $log->insert( + 'پیش فاکتور', + 'پیش فاکتور شماره ' . $preinvoice->getCode() . ' ثبت / ویرایش شد.', + $this->getUser(), + $acc['bid'], + ); + return new JsonResponse(['id' => $preinvoice->getId()]); + } + + #[Route('/api/preinvoice/delete/{id}', name: 'app_preinvoice_delete')] + public function deletePreinvoice(Access $access, Log $log, EntityManagerInterface $entityManager, int $id): JsonResponse + { + $acc = $access->hasRole('preinvoice'); + if (!$acc) { + return new JsonResponse($this->extractor->operationFail('دسترسی ندارید'), 403); + } + + $preinvoice = $entityManager->getRepository(PreInvoiceDoc::class)->findOneBy(['code' => $id, 'bid' => $acc['bid'], 'year' => $acc['year']] ); + if (!$preinvoice) { + return new JsonResponse(['error' => 'پیش فاکتور یافت نشد'], 404); + } + + foreach ($preinvoice->getPreInvoiceItems() as $item) { + $entityManager->remove($item); + } + + $entityManager->remove($preinvoice); + $entityManager->flush(); + $log->insert( + 'پیش فاکتور', + 'پیش فاکتور شماره ' . $preinvoice->getCode() . ' حذف شد.', + $this->getUser(), + $acc['bid'], + ); + return new JsonResponse(['message' => 'پیش فاکتور با موفقیت حذف شد']); + } + + private function generateCode(EntityManagerInterface $entityManager): string + { + $lastPreinvoice = $entityManager->getRepository(PreInvoiceDoc::class) + ->findOneBy([], ['id' => 'DESC']); + + $lastNumber = $lastPreinvoice ? (int)substr($lastPreinvoice->getCode(), 1) : 0; + return 'P' . str_pad($lastNumber + 1, 6, '0', STR_PAD_LEFT); + } + + #[Route('/api/preinvoice/docs/search', name: 'app_presell_search')] + public function searchPreinvoices(Access $access, EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('preinvoice'); + if (!$acc) { + return new JsonResponse($this->extractor->operationFail('دسترسی ندارید'), 403); + } + + $preinvoices = $entityManager->getRepository(PreInvoiceDoc::class) + ->findBy(['bid' => $acc['bid'], 'year' => $acc['year']], ['id' => 'DESC']); + + $result = []; + foreach ($preinvoices as $preinvoice) { + $totalAmount = $preinvoice->getAmount() - $preinvoice->getTotalDiscount() + $preinvoice->getShippingCost(); + + $result[] = [ + 'code' => $preinvoice->getCode(), + 'date' => $preinvoice->getDate(), + 'des' => $preinvoice->getDes(), + 'person' => [ + 'code' => $preinvoice->getPerson()->getId(), + 'nikename' => $preinvoice->getPerson()->getNikename() + ], + 'amount' => $preinvoice->getAmount(), + 'discountAll' => $preinvoice->getTotalDiscount(), + 'transferCost' => $preinvoice->getShippingCost(), + 'totalAmount' => $totalAmount, + 'label' => $preinvoice->getInvoiceLabel() ? [ + 'code' => $preinvoice->getInvoiceLabel()->getCode(), + 'label' => $preinvoice->getInvoiceLabel()->getLabel() + ] : null + ]; + } + + return new JsonResponse($result); + } + + #[Route('/api/preinvoice/remove/group', name: 'app_presell_delete_group')] + public function deletePreinvoiceGroup(Log $log, Access $access, EntityManagerInterface $entityManager, Request $request): JsonResponse + { + $acc = $access->hasRole('preinvoice'); + if (!$acc) { + return new JsonResponse($this->extractor->operationFail('دسترسی ندارید'), 403); + } + + $data = json_decode($request->getContent(), true); + $items = $data['items'] ?? []; + + if (empty($items)) { + return new JsonResponse(['result' => 2, 'message' => 'هیچ موردی انتخاب نشده است']); + } + + foreach ($items as $itemCode) { + $preinvoice = $entityManager->getRepository(PreInvoiceDoc::class) + ->findOneBy(['code' => $itemCode['code'], 'bid' => $acc['bid'], 'year' => $acc['year']]); + + if ($preinvoice) { + // حذف آیتم‌های پیش فاکتور + foreach ($preinvoice->getPreInvoiceItems() as $item) { + $entityManager->remove($item); + } + + $entityManager->remove($preinvoice); + } + $log->insert( + 'پیش فاکتور', + 'پیش فاکتور شماره ' . $preinvoice->getCode() . ' حذف شد.', + $this->getUser(), + $acc['bid'], + ); + } + + $entityManager->flush(); + + return new JsonResponse(['result' => 1, 'message' => 'پیش فاکتورها با موفقیت حذف شدند']); + } + + #[Route('/api/preinvoice/print/invoice', name: 'app_preinvoice_print_invoice')] + public function printPreinvoice(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('sell'); - if (!$acc) + $acc = $access->hasRole('preinvoice'); + if (!$acc) { throw $this->createAccessDeniedException(); + } - $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ + $preinvoice = $entityManager->getRepository(PreInvoiceDoc::class)->findOneBy([ 'bid' => $acc['bid'], 'code' => $params['code'], - 'money'=> $acc['money'] + 'year' => $acc['year'] ]); - if (!$doc) + + if (!$preinvoice) { throw $this->createNotFoundException(); - $pdfPid = 0; - if ($params['pdf']) { - $pdfPid = $provider->createPrint( - $acc['bid'], - $this->getUser(), - $this->renderView('pdf/posPrinters/presell.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/presell/print/invoice', name: 'app_sell_print_invoice')] - public function app_sell_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('sell'); - if (!$acc) - throw $this->createAccessDeniedException(); - - $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ - 'bid' => $acc['bid'], - 'code' => $params['code'], - 'money'=> $acc['money'] - ]); - 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 = [ @@ -557,6 +314,7 @@ class PreinvoiceController extends AbstractController 'note' => true, 'paper' => 'A4-L' ]; + if (array_key_exists('printOptions', $params)) { if (array_key_exists('bidInfo', $params['printOptions'])) { $printOptions['bidInfo'] = $params['printOptions']['bidInfo']; @@ -577,22 +335,24 @@ class PreinvoiceController extends AbstractController $printOptions['paper'] = $params['printOptions']['paper']; } } + $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/presell.html.twig', [ + $this->renderView('pdf/printers/preinvoice.html.twig', [ 'bid' => $acc['bid'], - 'doc' => $doc, - 'rows' => $doc->getHesabdariRows(), - 'person' => $person, + 'doc' => $preinvoice, + 'items' => $preinvoice->getPreInvoiceItems(), + 'person' => $preinvoice->getPerson(), 'printInvoice' => $params['printers'], - 'discount' => $discount, - 'transfer' => $transfer, + 'discount' => $preinvoice->getTotalDiscount(), + 'transfer' => $preinvoice->getShippingCost(), 'printOptions' => $printOptions, 'note' => $note ]), @@ -600,19 +360,21 @@ class PreinvoiceController extends AbstractController $printOptions['paper'] ); } + if ($params['printers'] == true) { $pid = $provider->createPrint( $acc['bid'], $this->getUser(), - $this->renderView('pdf/posPrinters/justSell.html.twig', [ + $this->renderView('pdf/posPrinters/justPreinvoice.html.twig', [ 'bid' => $acc['bid'], - 'doc' => $doc, - 'rows' => $doc->getHesabdariRows(), + 'doc' => $preinvoice, + 'items' => $preinvoice->getPreInvoiceItems(), ]), false ); - $printers->addFile($pid, $acc, "fastSellInvoice"); + $printers->addFile($pid, $acc, "fastPreinvoice"); } + return $this->json(['id' => $pdfPid]); } } diff --git a/hesabixCore/src/Controller/YearController.php b/hesabixCore/src/Controller/YearController.php index 3d11270..8ef60e4 100644 --- a/hesabixCore/src/Controller/YearController.php +++ b/hesabixCore/src/Controller/YearController.php @@ -18,6 +18,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\Serializer\Annotation\Groups; class YearController extends AbstractController { @@ -46,7 +47,7 @@ class YearController extends AbstractController //no year created create first year $years = [$this->createDefaultYear($business,$entityManager)]; } - return $this->json($years); + return $this->json($years, 200, [], ['groups' => ['year:read']]); } #[Route('/api/year/get', name: 'app_year_get')] @@ -65,7 +66,8 @@ class YearController extends AbstractController $yearLoad->setStart($jdate->jdate('Y/m/d', $yearLoad->getStart())); $yearLoad->setEnd($jdate->jdate('Y/m/d', $yearLoad->getEnd())); $yearLoad->setNow($jdate->jdate('Y/m/d', time())); - return $this->json($yearLoad); + + return $this->json($yearLoad, 200, [], ['groups' => ['year:read']]); } #[Route('/api/year/lastyear/info', name: 'app_year_last_year_info')] diff --git a/hesabixCore/src/Entity/PreInvoiceDoc.php b/hesabixCore/src/Entity/PreInvoiceDoc.php index cf9d1f9..cff3f92 100644 --- a/hesabixCore/src/Entity/PreInvoiceDoc.php +++ b/hesabixCore/src/Entity/PreInvoiceDoc.php @@ -3,6 +3,8 @@ namespace App\Entity; use App\Repository\PreInvoiceDocRepository; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: PreInvoiceDocRepository::class)] @@ -45,6 +47,24 @@ class PreInvoiceDoc #[ORM\Column(length: 255, nullable: true)] private ?string $amount = null; + #[ORM\Column(length: 255, nullable: true)] + private ?string $taxPercent = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $totalDiscount = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $totalDiscountPercent = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $shippingCost = null; + + #[ORM\Column(type: 'boolean', nullable: true)] + private ?bool $showPercentDiscount = null; + + #[ORM\Column(type: 'boolean', nullable: true)] + private ?bool $showTotalPercentDiscount = null; + #[ORM\Column(length: 255, nullable: true)] private ?string $mdate = null; @@ -66,6 +86,17 @@ class PreInvoiceDoc #[ORM\ManyToOne(inversedBy: 'preinvoiceDocsSalemans')] private ?Person $salesman = null; + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'doc', targetEntity: PreInvoiceItem::class, orphanRemoval: true)] + private Collection $preInvoiceItems; + + public function __construct() + { + $this->preInvoiceItems = new ArrayCollection(); + } + public function getId(): ?int { return $this->id; @@ -179,6 +210,72 @@ class PreInvoiceDoc return $this; } + public function getTaxPercent(): ?string + { + return $this->taxPercent; + } + + public function setTaxPercent(?string $taxPercent): static + { + $this->taxPercent = $taxPercent; + return $this; + } + + public function getTotalDiscount(): ?string + { + return $this->totalDiscount; + } + + public function setTotalDiscount(?string $totalDiscount): static + { + $this->totalDiscount = $totalDiscount; + return $this; + } + + public function getTotalDiscountPercent(): ?string + { + return $this->totalDiscountPercent; + } + + public function setTotalDiscountPercent(?string $totalDiscountPercent): static + { + $this->totalDiscountPercent = $totalDiscountPercent; + return $this; + } + + public function getShippingCost(): ?string + { + return $this->shippingCost; + } + + public function setShippingCost(?string $shippingCost): static + { + $this->shippingCost = $shippingCost; + return $this; + } + + public function isShowPercentDiscount(): ?bool + { + return $this->showPercentDiscount; + } + + public function setShowPercentDiscount(?bool $showPercentDiscount): static + { + $this->showPercentDiscount = $showPercentDiscount; + return $this; + } + + public function isShowTotalPercentDiscount(): ?bool + { + return $this->showTotalPercentDiscount; + } + + public function setShowTotalPercentDiscount(?bool $showTotalPercentDiscount): static + { + $this->showTotalPercentDiscount = $showTotalPercentDiscount; + return $this; + } + public function getMdate(): ?string { return $this->mdate; @@ -262,4 +359,34 @@ class PreInvoiceDoc return $this; } + + /** + * @return Collection + */ + public function getPreInvoiceItems(): Collection + { + return $this->preInvoiceItems; + } + + public function addPreInvoiceItem(PreInvoiceItem $preInvoiceItem): static + { + if (!$this->preInvoiceItems->contains($preInvoiceItem)) { + $this->preInvoiceItems->add($preInvoiceItem); + $preInvoiceItem->setDoc($this); + } + + return $this; + } + + public function removePreInvoiceItem(PreInvoiceItem $preInvoiceItem): static + { + if ($this->preInvoiceItems->removeElement($preInvoiceItem)) { + // set the owning side to null (unless already changed) + if ($preInvoiceItem->getDoc() === $this) { + $preInvoiceItem->setDoc(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/PreInvoiceItem.php b/hesabixCore/src/Entity/PreInvoiceItem.php index 0ce48dd..3d982b6 100644 --- a/hesabixCore/src/Entity/PreInvoiceItem.php +++ b/hesabixCore/src/Entity/PreInvoiceItem.php @@ -26,38 +26,27 @@ class PreInvoiceItem #[ORM\Column(length: 100, nullable: true)] private ?string $bd = null; + #[ORM\Column(length: 100, nullable: true)] + private ?string $discountPercent = null; + + #[ORM\Column(length: 100, nullable: true)] + private ?string $discountAmount = null; + #[ORM\Column(length: 255, nullable: true)] private ?string $des = null; - #[ORM\ManyToOne] - private ?Person $person = null; - - #[ORM\ManyToOne] - private ?BankAccount $bank = null; - - #[ORM\ManyToOne] - private ?Cashdesk $cashdesk = null; - - #[ORM\ManyToOne] - private ?Salary $salary = null; - - #[ORM\ManyToOne(inversedBy: 'preInvoiceItems')] - #[ORM\JoinColumn(nullable: false)] - private ?Business $bid = null; - - #[ORM\ManyToOne] - #[ORM\JoinColumn(nullable: false)] - private ?Year $year = null; - #[ORM\Column(length: 255, nullable: true)] private ?string $discount = null; #[ORM\Column(length: 255, nullable: true)] private ?string $tax = null; - #[ORM\ManyToOne] + #[ORM\Column(type: 'boolean', nullable: true)] + private ?bool $showPercentDiscount = null; + + #[ORM\ManyToOne(inversedBy: 'preInvoiceItems')] #[ORM\JoinColumn(nullable: false)] - private ?HesabdariTable $refID = null; + private ?PreInvoiceDoc $doc = null; public function getId(): ?int { @@ -112,6 +101,28 @@ class PreInvoiceItem return $this; } + public function getDiscountPercent(): ?string + { + return $this->discountPercent; + } + + public function setDiscountPercent(?string $discountPercent): static + { + $this->discountPercent = $discountPercent; + return $this; + } + + public function getDiscountAmount(): ?string + { + return $this->discountAmount; + } + + public function setDiscountAmount(?string $discountAmount): static + { + $this->discountAmount = $discountAmount; + return $this; + } + public function getDes(): ?string { return $this->des; @@ -124,78 +135,6 @@ class PreInvoiceItem return $this; } - public function getPerson(): ?Person - { - return $this->person; - } - - public function setPerson(?Person $person): static - { - $this->person = $person; - - return $this; - } - - public function getBank(): ?BankAccount - { - return $this->bank; - } - - public function setBank(?BankAccount $bank): static - { - $this->bank = $bank; - - return $this; - } - - public function getCashdesk(): ?Cashdesk - { - return $this->cashdesk; - } - - public function setCashdesk(?Cashdesk $cashdesk): static - { - $this->cashdesk = $cashdesk; - - return $this; - } - - public function getSalary(): ?Salary - { - return $this->salary; - } - - public function setSalary(?Salary $salary): static - { - $this->salary = $salary; - - return $this; - } - - public function getBid(): ?Business - { - return $this->bid; - } - - public function setBid(?Business $bid): static - { - $this->bid = $bid; - - return $this; - } - - public function getYear(): ?Year - { - return $this->year; - } - - public function setYear(?Year $year): static - { - $this->year = $year; - - return $this; - } - public function getDiscount(): ?string { return $this->discount; @@ -220,14 +159,25 @@ class PreInvoiceItem return $this; } - public function getRefID(): ?HesabdariTable + public function isShowPercentDiscount(): ?bool { - return $this->refID; + return $this->showPercentDiscount; } - public function setRefID(?HesabdariTable $refID): static + public function setShowPercentDiscount(?bool $showPercentDiscount): static { - $this->refID = $refID; + $this->showPercentDiscount = $showPercentDiscount; + return $this; + } + + public function getDoc(): ?PreInvoiceDoc + { + return $this->doc; + } + + public function setDoc(?PreInvoiceDoc $doc): static + { + $this->doc = $doc; return $this; } diff --git a/hesabixCore/src/Entity/Year.php b/hesabixCore/src/Entity/Year.php index 501a2d3..b7b9062 100644 --- a/hesabixCore/src/Entity/Year.php +++ b/hesabixCore/src/Entity/Year.php @@ -6,6 +6,7 @@ use App\Repository\YearRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Ignore; #[ORM\Entity(repositoryClass: YearRepository::class)] @@ -14,9 +15,11 @@ class Year #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] + #[Groups(['year:read'])] private ?int $id = null; #[ORM\Column(length: 255)] + #[Groups(['year:read'])] private ?string $label = null; #[ORM\ManyToOne(inversedBy: 'years')] @@ -25,6 +28,7 @@ class Year private ?Business $bid = null; #[ORM\Column(nullable: true)] + #[Groups(['year:read'])] private ?bool $head = null; #[ORM\OneToMany(mappedBy: 'year', targetEntity: HesabdariDoc::class, orphanRemoval: true)] @@ -32,12 +36,15 @@ class Year private Collection $hesabdariDocs; #[ORM\Column(length: 255)] + #[Groups(['year:read'])] private ?string $start = null; #[ORM\Column(length: 255)] + #[Groups(['year:read'])] private ?string $end = null; #[ORM\Column(length: 255, nullable: true)] + #[Groups(['year:read'])] private ?string $now = null; #[ORM\OneToMany(mappedBy: 'year', targetEntity: HesabdariRow::class, orphanRemoval: true)] diff --git a/hesabixCore/src/Twig/NumberFormatExtension.php b/hesabixCore/src/Twig/NumberFormatExtension.php new file mode 100644 index 0000000..1b62ec8 --- /dev/null +++ b/hesabixCore/src/Twig/NumberFormatExtension.php @@ -0,0 +1,25 @@ + + + + + پیش فاکتور {{ doc.code }} + + + +
+

پیش فاکتور فروش

+

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

+

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

+
+ +
+ + + + + + + + + + + {% for item in items %} + + + + + + + {% endfor %} + +
نام کالاتعدادقیمتجمع
{{ item.commodity.name }}{{ item.commodityCount }}{{ item.bs|number_format }}{{ (item.bs * item.commodityCount)|number_format }}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
جمع کل:{{ doc.amount|number_format }}
تخفیف:{{ doc.totalDiscount|number_format }}
مالیات:{{ (doc.amount * doc.taxPercent / 100)|number_format }}
هزینه حمل:{{ doc.shippingCost|number_format }}
قابل پرداخت:{{ (doc.amount - doc.totalDiscount + doc.shippingCost + (doc.amount * doc.taxPercent / 100))|number_format }}
+
+ + \ No newline at end of file diff --git a/hesabixCore/templates/pdf/printers/preinvoice.html.twig b/hesabixCore/templates/pdf/printers/preinvoice.html.twig new file mode 100644 index 0000000..29a81fa --- /dev/null +++ b/hesabixCore/templates/pdf/printers/preinvoice.html.twig @@ -0,0 +1,278 @@ + + + + + + + +
+
+
+ + + + + + + + +
+ + +

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

+
+

+ تاریخ: + {{ 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 %} + +
+
+ خریدار +
+ + + + + + + + + + + + + + +
+

+ نام: + {% if person.prelabel is not null %}{{ person.prelabel.label }}{% 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 items %} + {% if doc.taxPercent %} + {% set itemTax = (item.bs * item.commodityCount * doc.taxPercent / 100) | round %} + {% else %} + {% set itemTax = item.tax %} + {% endif %} + {% set taxAll = taxAll + itemTax %} + {% set rowIndex = rowIndex + 1 %} + + + + + + + {% if printOptions.discountInfo %} + + {% endif %} + {% if printOptions.taxInfo %} + + {% endif %} + + + {% endfor %} + +
ردیفکالا/خدماتشرحتعداد / مقدارمبلغ واحدتخفیفمالیاتمبلغ کل
{{ rowIndex }} + {{ item.commodity.code }} - {{ item.commodity.name }} + {{ item.des }} + {{ item.commodityCount }} {{ item.commodity.unit.name }} + {{ item.bs|number_format(0, '.', ',', doc.money.shortName) }} + {% if item.showPercentDiscount %} + {{ item.discountPercent }}% + ({{ (item.bs * item.commodityCount * item.discountPercent / 100)|round|number_format(0, '.', ',', doc.money.shortName) }}) + {% else %} + {{ item.discountAmount|number_format(0, '.', ',', doc.money.shortName) }} + {% endif %} + + {{ itemTax|number_format(0, '.', ',', doc.money.shortName) }} + + {% if item.showPercentDiscount %} + {{ (item.bs * item.commodityCount - (item.bs * item.commodityCount * item.discountPercent / 100)|round)|number_format(0, '.', ',', doc.money.shortName) }} + {% else %} + {{ (item.bs * item.commodityCount - item.discountAmount)|number_format(0, '.', ',', doc.money.shortName) }} + {% endif %} +
+
+ +
+ + + + + + + +
+

+ توضیحات: {{ doc.des }} +
+ {% if printOptions.note == true %} +

یادداشت:

+
    +
  • {{ note }}
  • +
+ {% endif %} + +
+ {% set totalDiscount = doc.showTotalPercentDiscount ? (doc.amount * doc.totalDiscountPercent / 100) | round : doc.totalDiscount %} +

تخفیف: {{ totalDiscount|number_format(0, '.', ',', doc.money.shortName) }}

+

مالیات: {{ taxAll|number_format(0, '.', ',', doc.money.shortName) }}

+

حمل و نقل: {{ doc.shippingCost|number_format(0, '.', ',', doc.money.shortName) }}

+

جمع کل: {{ doc.amount|number_format(0, '.', ',', doc.money.shortName) }}

+

جمع کل نهایی: {{ (doc.amount + taxAll - totalDiscount + doc.shippingCost)|number_format(0, '.', ',', doc.money.shortName) }}

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

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

+
+

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

+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/webUI/src/components/forms/Hcommoditysearch.vue b/webUI/src/components/forms/Hcommoditysearch.vue new file mode 100644 index 0000000..3abc1a8 --- /dev/null +++ b/webUI/src/components/forms/Hcommoditysearch.vue @@ -0,0 +1,527 @@ + + + + + diff --git a/webUI/src/components/forms/Hnumberinput.vue b/webUI/src/components/forms/Hnumberinput.vue index cdab38f..792711d 100644 --- a/webUI/src/components/forms/Hnumberinput.vue +++ b/webUI/src/components/forms/Hnumberinput.vue @@ -9,7 +9,11 @@ dir="ltr" dense hide-details="auto" - /> + > + + - \ No newline at end of file + \ No newline at end of file diff --git a/webUI/src/views/acc/presell/mod.vue b/webUI/src/views/acc/presell/mod.vue index 6357e3b..c3bacdc 100644 --- a/webUI/src/views/acc/presell/mod.vue +++ b/webUI/src/views/acc/presell/mod.vue @@ -9,1067 +9,678 @@ - - - - - + + + + + + - - - - -
-
-
-
-

- - تاریخ -

-
+ + + + + + + + + + + + + + + + + + نام کالا + تعداد + قیمت + تخفیف + جمع کل + + + + + + + افزودن سطر جدید + + + + -
+ +
+ + +
+ ردیف: + {{ index + 1 }} +
+
+ +
+
+
+
-
-

- -

+
+
-
-
-
-
-

- - طرف حساب -

-
- - -
-
-
- - - - - - تراز: - {{ $filters.formatNumber(Math.abs(parseInt(this.selectedPersonWithDet.bs) - - parseInt(this.selectedPersonWithDet.bd))) }} - - بدهکار - - بستانکار - -
-
-
-
-
-
-

- - شرح -

-
- -
-
-
- -
-
-
-
- - - - -
-
- - - - +
+
+ - - - - - - - - -
-
-
-
-
-

- - کالا و خدمات -

-
- - -
-
-
- - - - - -
-
-
-
-
-
-

- - شرح -

-
- -
-
-
- -
-
-
-
-
- - -
-
-
-
-
- - -
-
-
-
-
- - -
-
-
-
- - -
-
-
-
-
-
- - - - - +
+ - - - - - - -
-
-
-
-

- - کالا و خدمات -

-
- - -
-
-
- - - - - -
-
-
-
-
-
-

- - شرح -

-
- -
-
-
- -
-
-
-
-
- - -
-
-
-
-
- - -
-
-
-
-
- - -
-
-
-
- - -
-
-
- - - - - - - - - - - - - -
-
-
- - - مالیات - % - - -
-
-
-
- - تخفیف - - -
-
-
-
- - حمل و نقل - - -
+
- -
- - - - +
+ جمع کل: + {{ item.total.toLocaleString('fa-IR') }} +
+ + + + + + + افزودن کالای جدید +
+ + + + + + + + +
+ + + + + + +
+
+ + + +
+
+ + +
+ جمع کل فاکتور: + {{ totalInvoice.toLocaleString('fa-IR') }} +
+
+ تخفیف کلی: + {{ (showTotalPercentDiscount ? Math.round((totalInvoice * totalDiscountPercent) / 100) : totalDiscount).toLocaleString('fa-IR') }} +
+
+ هزینه حمل: + {{ shippingCost.toLocaleString('fa-IR') }} +
+
+ جمع کل با تخفیف و حمل: + {{ (totalInvoice - (showTotalPercentDiscount ? Math.round((totalInvoice * totalDiscountPercent) / 100) : totalDiscount) + shippingCost).toLocaleString('fa-IR') }} +
+
+ مبلغ مالیات: + {{ taxAmount.toLocaleString('fa-IR') }} +
+
+ جمع کل نهایی: + {{ finalTotal.toLocaleString('fa-IR') }} +
+
+
+
+
+ + + + + مبلغ تخفیف نمی‌تواند از قیمت پایه بیشتر باشد + + + مبلغ تخفیف کلی نمی‌تواند از جمع کل فاکتور بیشتر باشد + + + {{ error }} + + + {{ successMessage }} + + +
    +
  • {{ error }}
  • +
+
+ + + + + + + + + حذف پیش فاکتور + + + آیا مطمئن هستید که می‌خواهید این پیش فاکتور را حذف کنید؟ + + + + + انصراف + + + حذف + + + + - - \ No newline at end of file diff --git a/webUI/src/views/acc/presell/view.vue b/webUI/src/views/acc/presell/view.vue new file mode 100644 index 0000000..2ccec60 --- /dev/null +++ b/webUI/src/views/acc/presell/view.vue @@ -0,0 +1,170 @@ + + + + + \ No newline at end of file diff --git a/webUI/src/views/acc/presell/viewInvoice.vue b/webUI/src/views/acc/presell/viewInvoice.vue index 9928cd9..98cdf8d 100644 --- a/webUI/src/views/acc/presell/viewInvoice.vue +++ b/webUI/src/views/acc/presell/viewInvoice.vue @@ -1,632 +1,466 @@ - - - \ No newline at end of file