diff --git a/hesabixCore/src/Controller/PreinvoiceController.php b/hesabixCore/src/Controller/PreinvoiceController.php index fb06ea9..733fe57 100644 --- a/hesabixCore/src/Controller/PreinvoiceController.php +++ b/hesabixCore/src/Controller/PreinvoiceController.php @@ -2,17 +2,617 @@ namespace App\Controller; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use App\Entity\PreInvoiceDoc; +use App\Service\Log; +use App\Service\Access; +use App\Service\Explore; +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\HesabdariTable; +use App\Entity\InvoiceType; +use App\Entity\Person; +use App\Entity\PrintOptions; +use App\Entity\StoreroomTicket; +use App\Service\Printers; +use App\Service\registryMGR; +use App\Service\SMS; +use Doctrine\ORM\EntityManagerInterface; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Attribute\Route; +use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; class PreinvoiceController extends AbstractController { - #[Route('/preinvoice', name: 'app_preinvoice')] - public function index(): Response + + #[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 { - return $this->render('preinvoice/index.html.twig', [ - 'controller_name' => 'PreinvoiceController', + $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); + } + + #[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 + { + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + $acc = $access->hasRole('sell'); + 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'], + '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($doc->getId()); + } + + //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() + ]; + } + + $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); + } + + #[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 + { + $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(); + $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 = [ + 'bidInfo' => true, + 'pays' => true, + 'taxInfo' => true, + 'discountInfo' => true, + 'note' => true, + 'paper' => 'A4-L' + ]; + 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']; + } + if (array_key_exists('paper', $params['printOptions'])) { + $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', [ + 'bid' => $acc['bid'], + 'doc' => $doc, + 'rows' => $doc->getHesabdariRows(), + 'person' => $person, + 'printInvoice' => $params['printers'], + 'discount' => $discount, + 'transfer' => $transfer, + 'printOptions' => $printOptions, + 'note' => $note + ]), + false, + $printOptions['paper'] + ); + } + 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/Business.php b/hesabixCore/src/Entity/Business.php index 8ebc29b..c501719 100644 --- a/hesabixCore/src/Entity/Business.php +++ b/hesabixCore/src/Entity/Business.php @@ -258,6 +258,18 @@ class Business #[ORM\ManyToMany(targetEntity: Money::class, inversedBy: 'bids')] private Collection $extraMoney; + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'bid', targetEntity: PreInvoiceDoc::class, orphanRemoval: true)] + private Collection $preInvoiceDocs; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'bid', targetEntity: PreInvoiceItem::class, orphanRemoval: true)] + private Collection $preInvoiceItems; + public function __construct() { $this->logs = new ArrayCollection(); @@ -294,6 +306,8 @@ class Business $this->printOptions = new ArrayCollection(); $this->projects = new ArrayCollection(); $this->extraMoney = new ArrayCollection(); + $this->preInvoiceDocs = new ArrayCollection(); + $this->preInvoiceItems = new ArrayCollection(); } public function getId(): ?int @@ -1818,4 +1832,64 @@ class Business return $this; } + + /** + * @return Collection + */ + public function getPreInvoiceDocs(): Collection + { + return $this->preInvoiceDocs; + } + + public function addPreInvoiceDoc(PreInvoiceDoc $preInvoiceDoc): static + { + if (!$this->preInvoiceDocs->contains($preInvoiceDoc)) { + $this->preInvoiceDocs->add($preInvoiceDoc); + $preInvoiceDoc->setBid($this); + } + + return $this; + } + + public function removePreInvoiceDoc(PreInvoiceDoc $preInvoiceDoc): static + { + if ($this->preInvoiceDocs->removeElement($preInvoiceDoc)) { + // set the owning side to null (unless already changed) + if ($preInvoiceDoc->getBid() === $this) { + $preInvoiceDoc->setBid(null); + } + } + + 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->setBid($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->getBid() === $this) { + $preInvoiceItem->setBid(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/InvoiceType.php b/hesabixCore/src/Entity/InvoiceType.php index 432aff7..0e55350 100644 --- a/hesabixCore/src/Entity/InvoiceType.php +++ b/hesabixCore/src/Entity/InvoiceType.php @@ -30,9 +30,16 @@ class InvoiceType #[ORM\OneToMany(mappedBy: 'InvoiceLabel', targetEntity: HesabdariDoc::class)] private Collection $hesabdariDocs; + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'invoiceLabel', targetEntity: PreInvoiceDoc::class)] + private Collection $preInvoiceDocs; + public function __construct() { $this->hesabdariDocs = new ArrayCollection(); + $this->preInvoiceDocs = new ArrayCollection(); } public function getId(): ?int @@ -117,4 +124,34 @@ class InvoiceType return $this; } + + /** + * @return Collection + */ + public function getPreInvoiceDocs(): Collection + { + return $this->preInvoiceDocs; + } + + public function addPreInvoiceDoc(PreInvoiceDoc $preInvoiceDoc): static + { + if (!$this->preInvoiceDocs->contains($preInvoiceDoc)) { + $this->preInvoiceDocs->add($preInvoiceDoc); + $preInvoiceDoc->setInvoiceLabel($this); + } + + return $this; + } + + public function removePreInvoiceDoc(PreInvoiceDoc $preInvoiceDoc): static + { + if ($this->preInvoiceDocs->removeElement($preInvoiceDoc)) { + // set the owning side to null (unless already changed) + if ($preInvoiceDoc->getInvoiceLabel() === $this) { + $preInvoiceDoc->setInvoiceLabel(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/Money.php b/hesabixCore/src/Entity/Money.php index d59d781..146c4d4 100644 --- a/hesabixCore/src/Entity/Money.php +++ b/hesabixCore/src/Entity/Money.php @@ -51,6 +51,12 @@ class Money #[ORM\OneToMany(mappedBy: 'money', targetEntity: Salary::class)] private Collection $salaries; + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'money', targetEntity: PreInvoiceDoc::class, orphanRemoval: true)] + private Collection $preInvoiceDocs; + public function __construct() { $this->businesses = new ArrayCollection(); @@ -58,6 +64,7 @@ class Money $this->bids = new ArrayCollection(); $this->cashdesks = new ArrayCollection(); $this->salaries = new ArrayCollection(); + $this->preInvoiceDocs = new ArrayCollection(); } public function getId(): ?int @@ -259,4 +266,34 @@ class Money return $this; } + + /** + * @return Collection + */ + public function getPreInvoiceDocs(): Collection + { + return $this->preInvoiceDocs; + } + + public function addPreInvoiceDoc(PreInvoiceDoc $preInvoiceDoc): static + { + if (!$this->preInvoiceDocs->contains($preInvoiceDoc)) { + $this->preInvoiceDocs->add($preInvoiceDoc); + $preInvoiceDoc->setMoney($this); + } + + return $this; + } + + public function removePreInvoiceDoc(PreInvoiceDoc $preInvoiceDoc): static + { + if ($this->preInvoiceDocs->removeElement($preInvoiceDoc)) { + // set the owning side to null (unless already changed) + if ($preInvoiceDoc->getMoney() === $this) { + $preInvoiceDoc->setMoney(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/Person.php b/hesabixCore/src/Entity/Person.php index a8d3830..185e559 100644 --- a/hesabixCore/src/Entity/Person.php +++ b/hesabixCore/src/Entity/Person.php @@ -143,6 +143,12 @@ class Person #[ORM\OneToMany(mappedBy: 'salesman', targetEntity: HesabdariDoc::class)] private Collection $hesabdariDocs; + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'salesman', targetEntity: PreInvoiceDoc::class)] + private Collection $preinvoiceDocsSalemans; + public function __construct() { $this->hesabdariRows = new ArrayCollection(); @@ -156,6 +162,7 @@ class Person $this->plugRepserviceOrders = new ArrayCollection(); $this->preInvoiceDocs = new ArrayCollection(); $this->hesabdariDocs = new ArrayCollection(); + $this->preinvoiceDocsSalemans = new ArrayCollection(); } public function getId(): ?int @@ -810,4 +817,34 @@ class Person return $this; } + + /** + * @return Collection + */ + public function getPreinvoiceDocsSalemans(): Collection + { + return $this->preinvoiceDocsSalemans; + } + + public function addPreinvoiceDocsSaleman(PreInvoiceDoc $preinvoiceDocsSaleman): static + { + if (!$this->preinvoiceDocsSalemans->contains($preinvoiceDocsSaleman)) { + $this->preinvoiceDocsSalemans->add($preinvoiceDocsSaleman); + $preinvoiceDocsSaleman->setSalesman($this); + } + + return $this; + } + + public function removePreinvoiceDocsSaleman(PreInvoiceDoc $preinvoiceDocsSaleman): static + { + if ($this->preinvoiceDocsSalemans->removeElement($preinvoiceDocsSaleman)) { + // set the owning side to null (unless already changed) + if ($preinvoiceDocsSaleman->getSalesman() === $this) { + $preinvoiceDocsSaleman->setSalesman(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/PreInvoiceDoc.php b/hesabixCore/src/Entity/PreInvoiceDoc.php index 6f0ddbe..cf9d1f9 100644 --- a/hesabixCore/src/Entity/PreInvoiceDoc.php +++ b/hesabixCore/src/Entity/PreInvoiceDoc.php @@ -24,6 +24,48 @@ class PreInvoiceDoc #[ORM\JoinColumn(nullable: false)] private ?Person $person = null; + #[ORM\ManyToOne(inversedBy: 'preInvoiceDocs')] + #[ORM\JoinColumn(nullable: false)] + private ?Business $bid = null; + + #[ORM\ManyToOne(inversedBy: 'preInvoiceDocs')] + #[ORM\JoinColumn(nullable: false)] + private ?Money $money = null; + + #[ORM\ManyToOne(inversedBy: 'preInvoiceDocs')] + #[ORM\JoinColumn(nullable: false)] + private ?Year $year = null; + + #[ORM\Column(length: 80)] + private ?string $date = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $des = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $amount = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $mdate = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $plugin = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $refData = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $shortlink = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $status = null; + + #[ORM\ManyToOne(inversedBy: 'preInvoiceDocs')] + private ?InvoiceType $invoiceLabel = null; + + #[ORM\ManyToOne(inversedBy: 'preinvoiceDocsSalemans')] + private ?Person $salesman = null; + public function getId(): ?int { return $this->id; @@ -64,4 +106,160 @@ class PreInvoiceDoc return $this; } + + public function getBid(): ?Business + { + return $this->bid; + } + + public function setBid(?Business $bid): static + { + $this->bid = $bid; + + return $this; + } + + public function getMoney(): ?Money + { + return $this->money; + } + + public function setMoney(?Money $money): static + { + $this->money = $money; + + return $this; + } + + public function getYear(): ?Year + { + return $this->year; + } + + public function setYear(?Year $year): static + { + $this->year = $year; + + return $this; + } + + public function getDate(): ?string + { + return $this->date; + } + + public function setDate(string $date): static + { + $this->date = $date; + + return $this; + } + + public function getDes(): ?string + { + return $this->des; + } + + public function setDes(?string $des): static + { + $this->des = $des; + + return $this; + } + + public function getAmount(): ?string + { + return $this->amount; + } + + public function setAmount(?string $amount): static + { + $this->amount = $amount; + + return $this; + } + + public function getMdate(): ?string + { + return $this->mdate; + } + + public function setMdate(?string $mdate): static + { + $this->mdate = $mdate; + + return $this; + } + + public function getPlugin(): ?string + { + return $this->plugin; + } + + public function setPlugin(?string $plugin): static + { + $this->plugin = $plugin; + + return $this; + } + + public function getRefData(): ?string + { + return $this->refData; + } + + public function setRefData(?string $refData): static + { + $this->refData = $refData; + + return $this; + } + + public function getShortlink(): ?string + { + return $this->shortlink; + } + + public function setShortlink(?string $shortlink): static + { + $this->shortlink = $shortlink; + + return $this; + } + + public function getStatus(): ?string + { + return $this->status; + } + + public function setStatus(?string $status): static + { + $this->status = $status; + + return $this; + } + + public function getInvoiceLabel(): ?InvoiceType + { + return $this->invoiceLabel; + } + + public function setInvoiceLabel(?InvoiceType $invoiceLabel): static + { + $this->invoiceLabel = $invoiceLabel; + + return $this; + } + + public function getSalesman(): ?Person + { + return $this->salesman; + } + + public function setSalesman(?Person $salesman): static + { + $this->salesman = $salesman; + + return $this; + } } diff --git a/hesabixCore/src/Entity/PreInvoiceItem.php b/hesabixCore/src/Entity/PreInvoiceItem.php index 709f933..0ce48dd 100644 --- a/hesabixCore/src/Entity/PreInvoiceItem.php +++ b/hesabixCore/src/Entity/PreInvoiceItem.php @@ -17,6 +17,48 @@ class PreInvoiceItem #[ORM\JoinColumn(nullable: false)] private ?Commodity $commodity = null; + #[ORM\Column(length: 100, nullable: true)] + private ?string $commodityCount = null; + + #[ORM\Column(length: 100, nullable: true)] + private ?string $bs = null; + + #[ORM\Column(length: 100, nullable: true)] + private ?string $bd = 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\JoinColumn(nullable: false)] + private ?HesabdariTable $refID = null; + public function getId(): ?int { return $this->id; @@ -33,4 +75,160 @@ class PreInvoiceItem return $this; } + + public function getCommodityCount(): ?string + { + return $this->commodityCount; + } + + public function setCommodityCount(?string $commodityCount): static + { + $this->commodityCount = $commodityCount; + + return $this; + } + + public function getBs(): ?string + { + return $this->bs; + } + + public function setBs(?string $bs): static + { + $this->bs = $bs; + + return $this; + } + + public function getBd(): ?string + { + return $this->bd; + } + + public function setBd(?string $bd): static + { + $this->bd = $bd; + + return $this; + } + + public function getDes(): ?string + { + return $this->des; + } + + public function setDes(?string $des): static + { + $this->des = $des; + + 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; + } + + public function setDiscount(?string $discount): static + { + $this->discount = $discount; + + return $this; + } + + public function getTax(): ?string + { + return $this->tax; + } + + public function setTax(?string $tax): static + { + $this->tax = $tax; + + return $this; + } + + public function getRefID(): ?HesabdariTable + { + return $this->refID; + } + + public function setRefID(?HesabdariTable $refID): static + { + $this->refID = $refID; + + return $this; + } } diff --git a/hesabixCore/src/Entity/Year.php b/hesabixCore/src/Entity/Year.php index 0d5d10a..501a2d3 100644 --- a/hesabixCore/src/Entity/Year.php +++ b/hesabixCore/src/Entity/Year.php @@ -48,11 +48,18 @@ class Year #[Ignore] private Collection $storeroomTickets; + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'year', targetEntity: PreInvoiceDoc::class, orphanRemoval: true)] + private Collection $preInvoiceDocs; + public function __construct() { $this->hesabdariDocs = new ArrayCollection(); $this->hesabdariRows = new ArrayCollection(); $this->storeroomTickets = new ArrayCollection(); + $this->preInvoiceDocs = new ArrayCollection(); } public function getId(): ?int @@ -221,4 +228,34 @@ class Year return $this; } + + /** + * @return Collection + */ + public function getPreInvoiceDocs(): Collection + { + return $this->preInvoiceDocs; + } + + public function addPreInvoiceDoc(PreInvoiceDoc $preInvoiceDoc): static + { + if (!$this->preInvoiceDocs->contains($preInvoiceDoc)) { + $this->preInvoiceDocs->add($preInvoiceDoc); + $preInvoiceDoc->setYear($this); + } + + return $this; + } + + public function removePreInvoiceDoc(PreInvoiceDoc $preInvoiceDoc): static + { + if ($this->preInvoiceDocs->removeElement($preInvoiceDoc)) { + // set the owning side to null (unless already changed) + if ($preInvoiceDoc->getYear() === $this) { + $preInvoiceDoc->setYear(null); + } + } + + return $this; + } } diff --git a/public_html/img/logo.png b/public_html/img/logo.png new file mode 100644 index 0000000..acbb09c Binary files /dev/null and b/public_html/img/logo.png differ diff --git a/public_html/img/logo32.png b/public_html/img/logo32.png new file mode 100644 index 0000000..d33117f Binary files /dev/null and b/public_html/img/logo32.png differ