some progress in sell

This commit is contained in:
babak alizadeh 2024-06-04 22:17:56 +03:30
parent 1804a01c2a
commit 4973110073
7 changed files with 223 additions and 0 deletions

BIN
hesabixCore/src.zip Normal file

Binary file not shown.

View file

@ -226,6 +226,13 @@ class HesabdariController extends AbstractController
$temp['person'] = Explore::ExplorePerson($mainRow->getPerson());
}
$temp['label'] = null;
if ($item->getInvoiceLabel()) {
$temp['label'] = [
'code' => $item->getInvoiceLabel()->getCode(),
'label' => $item->getInvoiceLabel()->getLabel()
];
}
//get status of doc
$temp['status'] = 'تسویه نشده';
$pays = 0;

View file

@ -0,0 +1,33 @@
<?php
namespace App\Controller;
use App\Entity\InvoiceType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class InvoiceController extends AbstractController
{
#[Route('/api/invoice/types', name: 'api_invoice_types')]
public function api_invoice_types(Request $request, EntityManagerInterface $entityManagerInterface): JsonResponse
{
$params = [];
if ($content = $request->getContent()) {
$params = json_decode($content, true);
}
$items = $entityManagerInterface->getRepository(InvoiceType::class)->findBy(['type' => $params['type']]);
$res = [];
foreach ($items as $item) {
$res[] = [
'label' => $item->getlabel(),
'code' => $item->getCode(),
'checked' => false
];
}
return $this->json($res);
}
}

View file

@ -95,6 +95,9 @@ class HesabdariDoc
#[ORM\OneToMany(mappedBy: 'doc', targetEntity: Log::class)]
private Collection $logs;
#[ORM\ManyToOne(inversedBy: 'hesabdariDocs')]
private ?InvoiceType $InvoiceLabel = null;
public function __construct()
{
$this->hesabdariRows = new ArrayCollection();
@ -456,4 +459,16 @@ class HesabdariDoc
return $this;
}
public function getInvoiceLabel(): ?InvoiceType
{
return $this->InvoiceLabel;
}
public function setInvoiceLabel(?InvoiceType $InvoiceLabel): static
{
$this->InvoiceLabel = $InvoiceLabel;
return $this;
}
}

View file

@ -0,0 +1,120 @@
<?php
namespace App\Entity;
use App\Repository\InvoiceTypeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: InvoiceTypeRepository::class)]
class InvoiceType
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $label = null;
#[ORM\Column(length: 255)]
private ?string $code = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $checked = null;
#[ORM\Column(length: 255)]
private ?string $type = null;
#[ORM\OneToMany(mappedBy: 'InvoiceLabel', targetEntity: HesabdariDoc::class)]
private Collection $hesabdariDocs;
public function __construct()
{
$this->hesabdariDocs = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): static
{
$this->label = $label;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): static
{
$this->code = $code;
return $this;
}
public function getChecked(): ?string
{
return $this->checked;
}
public function setChecked(?string $checked): static
{
$this->checked = $checked;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): static
{
$this->type = $type;
return $this;
}
/**
* @return Collection<int, HesabdariDoc>
*/
public function getHesabdariDocs(): Collection
{
return $this->hesabdariDocs;
}
public function addHesabdariDoc(HesabdariDoc $hesabdariDoc): static
{
if (!$this->hesabdariDocs->contains($hesabdariDoc)) {
$this->hesabdariDocs->add($hesabdariDoc);
$hesabdariDoc->setInvoiceLabel($this);
}
return $this;
}
public function removeHesabdariDoc(HesabdariDoc $hesabdariDoc): static
{
if ($this->hesabdariDocs->removeElement($hesabdariDoc)) {
// set the owning side to null (unless already changed)
if ($hesabdariDoc->getInvoiceLabel() === $this) {
$hesabdariDoc->setInvoiceLabel(null);
}
}
return $this;
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace App\Repository;
use App\Entity\InvoiceType;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<InvoiceType>
*
* @method InvoiceType|null find($id, $lockMode = null, $lockVersion = null)
* @method InvoiceType|null findOneBy(array $criteria, array $orderBy = null)
* @method InvoiceType[] findAll()
* @method InvoiceType[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class InvoiceTypeRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, InvoiceType::class);
}
// /**
// * @return InvoiceType[] Returns an array of InvoiceType objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('i')
// ->andWhere('i.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('i.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?InvoiceType
// {
// return $this->createQueryBuilder('i')
// ->andWhere('i.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

BIN
hesabixCore/templates.zip Normal file

Binary file not shown.