From 6f30c0b11ad5f11ddacece7829cfc58260e2248c Mon Sep 17 00:00:00 2001 From: Babak Alizadeh Date: Sun, 12 Jan 2025 11:00:34 +0000 Subject: [PATCH] bug fix in buy pdf export and start working on dashboard customizition --- hesabixCore/src/Entity/Business.php | 37 ++++ hesabixCore/src/Entity/DashboardSettings.php | 172 ++++++++++++++++++ hesabixCore/src/Entity/User.php | 37 ++++ .../DashboardSettingsRepository.php | 43 +++++ .../templates/pdf/printers/buy.html.twig | 4 +- 5 files changed, 291 insertions(+), 2 deletions(-) create mode 100644 hesabixCore/src/Entity/DashboardSettings.php create mode 100644 hesabixCore/src/Repository/DashboardSettingsRepository.php diff --git a/hesabixCore/src/Entity/Business.php b/hesabixCore/src/Entity/Business.php index c501719..68cc2b7 100644 --- a/hesabixCore/src/Entity/Business.php +++ b/hesabixCore/src/Entity/Business.php @@ -270,6 +270,12 @@ class Business #[ORM\OneToMany(mappedBy: 'bid', targetEntity: PreInvoiceItem::class, orphanRemoval: true)] private Collection $preInvoiceItems; + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'bid', targetEntity: DashboardSettings::class, orphanRemoval: true)] + private Collection $dashboardSettings; + public function __construct() { $this->logs = new ArrayCollection(); @@ -308,6 +314,7 @@ class Business $this->extraMoney = new ArrayCollection(); $this->preInvoiceDocs = new ArrayCollection(); $this->preInvoiceItems = new ArrayCollection(); + $this->dashboardSettings = new ArrayCollection(); } public function getId(): ?int @@ -1892,4 +1899,34 @@ class Business return $this; } + + /** + * @return Collection + */ + public function getDashboardSettings(): Collection + { + return $this->dashboardSettings; + } + + public function addDashboardSetting(DashboardSettings $dashboardSetting): static + { + if (!$this->dashboardSettings->contains($dashboardSetting)) { + $this->dashboardSettings->add($dashboardSetting); + $dashboardSetting->setBid($this); + } + + return $this; + } + + public function removeDashboardSetting(DashboardSettings $dashboardSetting): static + { + if ($this->dashboardSettings->removeElement($dashboardSetting)) { + // set the owning side to null (unless already changed) + if ($dashboardSetting->getBid() === $this) { + $dashboardSetting->setBid(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/DashboardSettings.php b/hesabixCore/src/Entity/DashboardSettings.php new file mode 100644 index 0000000..653c2e9 --- /dev/null +++ b/hesabixCore/src/Entity/DashboardSettings.php @@ -0,0 +1,172 @@ +id; + } + + public function getSubmitter(): ?User + { + return $this->submitter; + } + + public function setSubmitter(?User $submitter): static + { + $this->submitter = $submitter; + + return $this; + } + + public function getBid(): ?Business + { + return $this->bid; + } + + public function setBid(?Business $bid): static + { + $this->bid = $bid; + + return $this; + } + + public function isWallet(): ?bool + { + return $this->wallet; + } + + public function setWallet(?bool $wallet): static + { + $this->wallet = $wallet; + + return $this; + } + + public function isBanks(): ?bool + { + return $this->banks; + } + + public function setBanks(?bool $banks): static + { + $this->banks = $banks; + + return $this; + } + + public function isAccDocs(): ?bool + { + return $this->accDocs; + } + + public function setAccDocs(?bool $accDocs): static + { + $this->accDocs = $accDocs; + + return $this; + } + + public function isCommodities(): ?bool + { + return $this->commodities; + } + + public function setCommodities(?bool $commodities): static + { + $this->commodities = $commodities; + + return $this; + } + + public function isPersons(): ?bool + { + return $this->persons; + } + + public function setPersons(?bool $persons): static + { + $this->persons = $persons; + + return $this; + } + + public function isBuys(): ?bool + { + return $this->buys; + } + + public function setBuys(?bool $buys): static + { + $this->buys = $buys; + + return $this; + } + + public function isSells(): ?bool + { + return $this->sells; + } + + public function setSells(?bool $sells): static + { + $this->sells = $sells; + + return $this; + } + + public function isAccountingTotal(): ?bool + { + return $this->accountingTotal; + } + + public function setAccountingTotal(?bool $accountingTotal): static + { + $this->accountingTotal = $accountingTotal; + + return $this; + } +} diff --git a/hesabixCore/src/Entity/User.php b/hesabixCore/src/Entity/User.php index 73739be..002d32e 100644 --- a/hesabixCore/src/Entity/User.php +++ b/hesabixCore/src/Entity/User.php @@ -107,6 +107,12 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\OneToMany(mappedBy: 'submitter', targetEntity: PreInvoiceDoc::class, orphanRemoval: true)] private Collection $preInvoiceDocs; + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'submitter', targetEntity: DashboardSettings::class, orphanRemoval: true)] + private Collection $dashboardSettings; + public function __construct() { $this->userTokens = new ArrayCollection(); @@ -128,6 +134,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface $this->plugRepserviceOrders = new ArrayCollection(); $this->notes = new ArrayCollection(); $this->preInvoiceDocs = new ArrayCollection(); + $this->dashboardSettings = new ArrayCollection(); } public function getId(): ?int @@ -819,4 +826,34 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface return $this; } + + /** + * @return Collection + */ + public function getDashboardSettings(): Collection + { + return $this->dashboardSettings; + } + + public function addDashboardSetting(DashboardSettings $dashboardSetting): static + { + if (!$this->dashboardSettings->contains($dashboardSetting)) { + $this->dashboardSettings->add($dashboardSetting); + $dashboardSetting->setSubmitter($this); + } + + return $this; + } + + public function removeDashboardSetting(DashboardSettings $dashboardSetting): static + { + if ($this->dashboardSettings->removeElement($dashboardSetting)) { + // set the owning side to null (unless already changed) + if ($dashboardSetting->getSubmitter() === $this) { + $dashboardSetting->setSubmitter(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Repository/DashboardSettingsRepository.php b/hesabixCore/src/Repository/DashboardSettingsRepository.php new file mode 100644 index 0000000..e10b0d0 --- /dev/null +++ b/hesabixCore/src/Repository/DashboardSettingsRepository.php @@ -0,0 +1,43 @@ + + */ +class DashboardSettingsRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, DashboardSettings::class); + } + + // /** + // * @return DashboardSettings[] Returns an array of DashboardSettings objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('d') + // ->andWhere('d.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('d.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?DashboardSettings + // { + // return $this->createQueryBuilder('d') + // ->andWhere('d.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/hesabixCore/templates/pdf/printers/buy.html.twig b/hesabixCore/templates/pdf/printers/buy.html.twig index 905fec2..2608d9b 100644 --- a/hesabixCore/templates/pdf/printers/buy.html.twig +++ b/hesabixCore/templates/pdf/printers/buy.html.twig @@ -213,14 +213,14 @@ {{ item.commdityCount }} {{ item.commodity.unit.name }} - {{ ((item.bs - item.tax + item.discount) / item.commdityCount) | number_format }} + {{ ((item.bd - item.tax + item.discount) / item.commdityCount) | number_format }} {% if printOptions.discountInfo %} {{ item.discount | number_format }} {% endif %} {% if printOptions.taxInfo %} {{ item.tax | number_format}} {% endif %} - {{ item.bs| number_format }} + {{ item.bd| number_format }} {% endif %} {% endfor %}