From 5ca9c6e241202bd7696e96ff120946eca60c707a Mon Sep 17 00:00:00 2001 From: babak alizadeh Date: Wed, 16 Oct 2024 21:00:14 +0330 Subject: [PATCH] bug fix in archive buy storage --- .../src/Controller/ArchiveController.php | 2 +- hesabixCore/src/Entity/Commodity.php | 37 ++++++++++ hesabixCore/src/Entity/Person.php | 37 ++++++++++ hesabixCore/src/Entity/PreInvoiceDoc.php | 67 +++++++++++++++++++ hesabixCore/src/Entity/PreInvoiceItem.php | 36 ++++++++++ hesabixCore/src/Entity/User.php | 37 ++++++++++ .../Repository/PreInvoiceDocRepository.php | 43 ++++++++++++ .../Repository/PreInvoiceItemRepository.php | 43 ++++++++++++ 8 files changed, 301 insertions(+), 1 deletion(-) create mode 100644 hesabixCore/src/Entity/PreInvoiceDoc.php create mode 100644 hesabixCore/src/Entity/PreInvoiceItem.php create mode 100644 hesabixCore/src/Repository/PreInvoiceDocRepository.php create mode 100644 hesabixCore/src/Repository/PreInvoiceItemRepository.php diff --git a/hesabixCore/src/Controller/ArchiveController.php b/hesabixCore/src/Controller/ArchiveController.php index 9680203..c4ec04d 100644 --- a/hesabixCore/src/Controller/ArchiveController.php +++ b/hesabixCore/src/Controller/ArchiveController.php @@ -165,7 +165,7 @@ class ArchiveController extends AbstractController } else { if(array_key_exists('code',$result['data'])){ if ($result['data']['code'] == 100) { - $req->setStatus($request->get('Status')); + $req->setStatus(100); $req->setRefID($result['data']['ref_id']); $req->setCardPan($result['data']['card_pan']); $req->setExpireDate(time() + ($req->getMonth() * 30 * 24 * 60 * 60)); diff --git a/hesabixCore/src/Entity/Commodity.php b/hesabixCore/src/Entity/Commodity.php index 591777a..2b87f30 100644 --- a/hesabixCore/src/Entity/Commodity.php +++ b/hesabixCore/src/Entity/Commodity.php @@ -86,6 +86,12 @@ class Commodity #[ORM\OneToMany(mappedBy: 'commodity', targetEntity: PriceListDetail::class, orphanRemoval: true)] private Collection $priceListDetails; + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'commodity', targetEntity: PreInvoiceItem::class, orphanRemoval: true)] + private Collection $preInvoiceItems; + public function __construct() { $this->setPriceBuy(0); @@ -95,6 +101,7 @@ class Commodity $this->storeroomItems = new ArrayCollection(); $this->plugRepserviceOrders = new ArrayCollection(); $this->priceListDetails = new ArrayCollection(); + $this->preInvoiceItems = new ArrayCollection(); } public function getId(): ?int @@ -443,4 +450,34 @@ class Commodity 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->setCommodity($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->getCommodity() === $this) { + $preInvoiceItem->setCommodity(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/Person.php b/hesabixCore/src/Entity/Person.php index 38a5114..c33eeb1 100644 --- a/hesabixCore/src/Entity/Person.php +++ b/hesabixCore/src/Entity/Person.php @@ -131,6 +131,12 @@ class Person #[ORM\OneToMany(mappedBy: 'person', targetEntity: PlugRepserviceOrder::class, orphanRemoval: true)] private Collection $plugRepserviceOrders; + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'person', targetEntity: PreInvoiceDoc::class, orphanRemoval: true)] + private Collection $preInvoiceDocs; + public function __construct() { $this->hesabdariRows = new ArrayCollection(); @@ -142,6 +148,7 @@ class Person $this->type = new ArrayCollection(); $this->personCards = new ArrayCollection(); $this->plugRepserviceOrders = new ArrayCollection(); + $this->preInvoiceDocs = new ArrayCollection(); } public function getId(): ?int @@ -736,4 +743,34 @@ class Person 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->setPerson($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->getPerson() === $this) { + $preInvoiceDoc->setPerson(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/PreInvoiceDoc.php b/hesabixCore/src/Entity/PreInvoiceDoc.php new file mode 100644 index 0000000..6f0ddbe --- /dev/null +++ b/hesabixCore/src/Entity/PreInvoiceDoc.php @@ -0,0 +1,67 @@ +id; + } + + public function getSubmitter(): ?User + { + return $this->submitter; + } + + public function setSubmitter(?User $submitter): static + { + $this->submitter = $submitter; + + return $this; + } + + public function getCode(): ?string + { + return $this->code; + } + + public function setCode(string $code): static + { + $this->code = $code; + + return $this; + } + + public function getPerson(): ?Person + { + return $this->person; + } + + public function setPerson(?Person $person): static + { + $this->person = $person; + + return $this; + } +} diff --git a/hesabixCore/src/Entity/PreInvoiceItem.php b/hesabixCore/src/Entity/PreInvoiceItem.php new file mode 100644 index 0000000..709f933 --- /dev/null +++ b/hesabixCore/src/Entity/PreInvoiceItem.php @@ -0,0 +1,36 @@ +id; + } + + public function getCommodity(): ?Commodity + { + return $this->commodity; + } + + public function setCommodity(?Commodity $commodity): static + { + $this->commodity = $commodity; + + return $this; + } +} diff --git a/hesabixCore/src/Entity/User.php b/hesabixCore/src/Entity/User.php index 52c8c74..5fdd9c6 100644 --- a/hesabixCore/src/Entity/User.php +++ b/hesabixCore/src/Entity/User.php @@ -113,6 +113,12 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\OneToMany(mappedBy: 'submitter', targetEntity: Note::class, orphanRemoval: true)] private Collection $notes; + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'submitter', targetEntity: PreInvoiceDoc::class, orphanRemoval: true)] + private Collection $preInvoiceDocs; + public function __construct() { $this->userTokens = new ArrayCollection(); @@ -137,6 +143,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface $this->mostDes = new ArrayCollection(); $this->plugRepserviceOrders = new ArrayCollection(); $this->notes = new ArrayCollection(); + $this->preInvoiceDocs = new ArrayCollection(); } public function getId(): ?int @@ -940,4 +947,34 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface 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->setSubmitter($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->getSubmitter() === $this) { + $preInvoiceDoc->setSubmitter(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Repository/PreInvoiceDocRepository.php b/hesabixCore/src/Repository/PreInvoiceDocRepository.php new file mode 100644 index 0000000..fd89341 --- /dev/null +++ b/hesabixCore/src/Repository/PreInvoiceDocRepository.php @@ -0,0 +1,43 @@ + + */ +class PreInvoiceDocRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, PreInvoiceDoc::class); + } + + // /** + // * @return PreInvoiceDoc[] Returns an array of PreInvoiceDoc objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('p') + // ->andWhere('p.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('p.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?PreInvoiceDoc + // { + // return $this->createQueryBuilder('p') + // ->andWhere('p.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/hesabixCore/src/Repository/PreInvoiceItemRepository.php b/hesabixCore/src/Repository/PreInvoiceItemRepository.php new file mode 100644 index 0000000..0d10355 --- /dev/null +++ b/hesabixCore/src/Repository/PreInvoiceItemRepository.php @@ -0,0 +1,43 @@ + + */ +class PreInvoiceItemRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, PreInvoiceItem::class); + } + + // /** + // * @return PreInvoiceItem[] Returns an array of PreInvoiceItem objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('p') + // ->andWhere('p.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('p.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?PreInvoiceItem + // { + // return $this->createQueryBuilder('p') + // ->andWhere('p.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +}