Quellcode durchsuchen

Gestion des documents

feature/export_comptable
Guillaume vor 4 Jahren
Ursprung
Commit
965ad46ad6
13 geänderte Dateien mit 313 neuen und 321 gelöschten Zeilen
  1. +0
    -8
      ShopBundle/Context/DocumentDeliveryNoteInterface.php
  2. +1
    -1
      ShopBundle/Context/DocumentInterface.php
  3. +0
    -8
      ShopBundle/Context/DocumentQuotationInterface.php
  4. +227
    -0
      ShopBundle/Model/Document.php
  5. +0
    -55
      ShopBundle/Model/DocumentDeliveryNote.php
  6. +0
    -56
      ShopBundle/Model/DocumentInvoice.php
  7. +0
    -73
      ShopBundle/Model/DocumentQuotation.php
  8. +33
    -53
      ShopBundle/Model/OrderShop.php
  9. +0
    -21
      ShopBundle/Repository/DocumentDeliveryNoteRepository.php
  10. +0
    -23
      ShopBundle/Repository/DocumentInvoiceRepository.php
  11. +0
    -23
      ShopBundle/Repository/DocumentQuotationRepository.php
  12. +23
    -0
      ShopBundle/Repository/DocumentRepository.php
  13. +29
    -0
      ShopBundle/Services/OrderUtils.php

+ 0
- 8
ShopBundle/Context/DocumentDeliveryNoteInterface.php Datei anzeigen

@@ -1,8 +0,0 @@
<?php

namespace Lc\ShopBundle\Context;

interface DocumentDeliveryNoteInterface
{

}

ShopBundle/Context/DocumentInvoiceInterface.php → ShopBundle/Context/DocumentInterface.php Datei anzeigen

@@ -2,7 +2,7 @@

namespace Lc\ShopBundle\Context;

interface DocumentInvoiceInterface
interface DocumentInterface
{

}

+ 0
- 8
ShopBundle/Context/DocumentQuotationInterface.php Datei anzeigen

@@ -1,8 +0,0 @@
<?php

namespace Lc\ShopBundle\Context;

interface DocumentQuotationInterface
{

}

+ 227
- 0
ShopBundle/Model/Document.php Datei anzeigen

@@ -0,0 +1,227 @@
<?php

namespace Lc\ShopBundle\Model;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\MappedSuperclass()
*/
abstract class Document extends AbstractDocumentEntity
{
const TYPE_INVOICE = 'invoice' ;
const TYPE_QUOTATION = 'quotation' ;
const TYPE_PURCHASE_ORDER = 'purchase-order' ;
const TYPE_DELIVERY_NOTE = 'delivery-note' ;

/**
* @ORM\Column(type="string", length=64)
*/
protected $type;

/**
* @ORM\Column(type="string", length=128, nullable=true)
*/
protected $reference;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $logo;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchantAddress;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $buyerAddress;

/**
* @ORM\Column(type="text")
*/
protected $merchantAddressText;

/**
* @ORM\Column(type="text")
*/
protected $buyerAddressText;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $deliveryAddressText;

/**
* @ORM\Column(type="boolean", nullable=true)
*/
protected $isSent;

/**
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documents")
*/
protected $orderShops;

public function __construct()
{
$this->orderShops = new ArrayCollection();
}

public function getLabel()
{
if($this->getType() == self::TYPE_INVOICE) {
return 'Facture' ;
}
elseif($this->getType() == self::TYPE_QUOTATION) {
return 'Devis' ;
}
elseif($this->getType() == self::TYPE_PURCHASE_ORDER) {
return 'Bon de commande' ;
}
elseif($this->getType() == self::TYPE_DELIVERY_NOTE) {
return 'Bon de livraison' ;
}
}

public function getType(): ?string
{
return $this->type;
}

public function setType(string $type): self
{
$this->type = $type;

return $this;
}

public function getReference(): ?string
{
return $this->reference;
}

public function setReference(?string $reference): self
{
$this->reference = $reference;

return $this;
}

public function getLogo(): ?string
{
return $this->logo;
}

public function setLogo(string $logo): self
{
$this->logo = $logo;

return $this;
}

public function getMerchantAddress(): ?Address
{
return $this->merchantAddress;
}

public function setMerchantAddress(?Address $merchantAddress): self
{
$this->merchantAddress = $merchantAddress;

return $this;
}

public function getBuyerAddress(): ?Address
{
return $this->buyerAddress;
}

public function setBuyerAddress(?Address $buyerAddress): self
{
$this->buyerAddress = $buyerAddress;

return $this;
}

public function getMerchantAddressText(): ?string
{
return $this->merchantAddressText;
}

public function setMerchantAddressText(string $merchantAddressText): self
{
$this->merchantAddressText = $merchantAddressText;

return $this;
}

public function getBuyerAddressText(): ?string
{
return $this->buyerAddressText;
}

public function setBuyerAddressText(string $buyerAddressText): self
{
$this->buyerAddressText = $buyerAddressText;

return $this;
}

public function getDeliveryAddressText(): ?string
{
return $this->deliveryAddressText;
}

public function setDeliveryAddressText(?string $deliveryAddressText): self
{
$this->deliveryAddressText = $deliveryAddressText;

return $this;
}

public function getIsSent(): ?bool
{
return $this->isSent;
}

public function setIsSent(?bool $isSent): self
{
$this->isSent = $isSent;

return $this;
}

/**
* @return Collection|OrderShop[]
*/
public function getOrderShops(): Collection
{
return $this->orderShops;
}

public function addOrderShop(OrderShop $orderShop): self
{
if (!$this->orderShops->contains($orderShop)) {
$this->orderShops[] = $orderShop;
$orderShop->addDocument($this);
}

return $this;
}

public function removeOrderShop(OrderShop $orderShop): self
{
if ($this->orderShops->contains($orderShop)) {
$this->orderShops->removeElement($orderShop);
$orderShop->removeDocument($this);
}

return $this;
}
}

+ 0
- 55
ShopBundle/Model/DocumentDeliveryNote.php Datei anzeigen

@@ -1,55 +0,0 @@
<?php

namespace Lc\ShopBundle\Model;

use Lc\ShopBundle\Model\OrderShop;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\MappedSuperclass()
*/
abstract class DocumentDeliveryNote extends AbstractDocumentOrder
{
/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documentDeliveryNote")
*/
protected $orderShops;

public function __construct()
{
$this->orderShops = new ArrayCollection();
}

/**
* @return Collection|OrderShop[]
*/
public function getOrderShops(): Collection
{
return $this->orderShops;
}

public function addOrderShop(OrderShop $orderShop): self
{
if (!$this->orderShops->contains($orderShop)) {
$this->orderShops[] = $orderShop;
$orderShop->setDocumentDeliveryNote($this);
}

return $this;
}

public function removeOrderShop(OrderShop $orderShop): self
{
if ($this->orderShops->contains($orderShop)) {
$this->orderShops->removeElement($orderShop);
// set the owning side to null (unless already changed)
if ($orderShop->getDocumentDeliveryNote() === $this) {
$orderShop->setDocumentDeliveryNote(null);
}
}

return $this;
}
}

+ 0
- 56
ShopBundle/Model/DocumentInvoice.php Datei anzeigen

@@ -1,56 +0,0 @@
<?php

namespace Lc\ShopBundle\Model;

use Lc\ShopBundle\Model\OrderShop;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\MappedSuperclass()
*/
abstract class DocumentInvoice extends AbstractDocumentOrder
{
/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documentInvoice")
*/
protected $orderShops;

public function __construct()
{
$this->orderShops = new ArrayCollection();
}

/**
* @return Collection|OrderShop[]
*/
public function getOrderShops(): Collection
{
return $this->orderShops;
}

public function addOrderShop(OrderShop $orderShop): self
{
if (!$this->orderShops->contains($orderShop)) {
$this->orderShops[] = $orderShop;
$orderShop->setDocumentInvoice($this);
}

return $this;
}

public function removeOrderShop(OrderShop $orderShop): self
{
if ($this->orderShops->contains($orderShop)) {
$this->orderShops->removeElement($orderShop);
// set the owning side to null (unless already changed)
if ($orderShop->getDocumentInvoice() === $this) {
$orderShop->setDocumentInvoice(null);
}
}

return $this;
}

}

+ 0
- 73
ShopBundle/Model/DocumentQuotation.php Datei anzeigen

@@ -1,73 +0,0 @@
<?php

namespace Lc\ShopBundle\Model;

use App\Entity\OrderShop;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\MappedSuperclass()
*/
abstract class DocumentQuotation extends AbstractDocumentOrder
{

/**
* @ORM\Column(type="integer", nullable=true)
*/
protected $duration;

/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documentQuotation")
*/
protected $orderShops;

public function __construct()
{
$this->orderShops = new ArrayCollection();
}

public function getDuration(): ?int
{
return $this->duration;
}

public function setDuration(?int $duration): self
{
$this->duration = $duration;

return $this;
}

/**
* @return Collection|OrderShop[]
*/
public function getOrderShops(): Collection
{
return $this->orderShops;
}

public function addOrderShop(OrderShop $orderShop): self
{
if (!$this->orderShops->contains($orderShop)) {
$this->orderShops[] = $orderShop;
$orderShop->setDocumentQuotation($this);
}

return $this;
}

public function removeOrderShop(OrderShop $orderShop): self
{
if ($this->orderShops->contains($orderShop)) {
$this->orderShops->removeElement($orderShop);
// set the owning side to null (unless already changed)
if ($orderShop->getDocumentQuotation() === $this) {
$orderShop->setDocumentQuotation(null);
}
}

return $this;
}
}

+ 33
- 53
ShopBundle/Model/OrderShop.php Datei anzeigen

@@ -2,10 +2,10 @@

namespace Lc\ShopBundle\Model;

use App\Entity\Visitor;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\DocumentInterface;
use Lc\ShopBundle\Context\FilterMerchantInterface;

/**
@@ -13,7 +13,6 @@ use Lc\ShopBundle\Context\FilterMerchantInterface;
*/
abstract class OrderShop extends AbstractEntity implements FilterMerchantInterface
{

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies")
* @ORM\JoinColumn(nullable=false)
@@ -65,21 +64,6 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
*/
protected $creditHistories;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\DocumentInvoiceInterface", inversedBy="orderShops")
*/
protected $documentInvoice;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\DocumentQuotationInterface", inversedBy="orderShops")
*/
protected $documentQuotation;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\DocumentDeliveryNoteInterface", inversedBy="orderShops")
*/
protected $documentDeliveryNote;

/**
* @ORM\Column(type="text", nullable=true)
*/
@@ -101,6 +85,11 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
*/
protected $orderReductionCredits;

/**
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\DocumentInterface", inversedBy="orderShops")
*/
protected $documents;

public function __construct()
{
$this->orderStatusHistories = new ArrayCollection();
@@ -108,6 +97,7 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
$this->creditHistories = new ArrayCollection();
$this->orderReductionCarts = new ArrayCollection();
$this->orderReductionCredits = new ArrayCollection();
$this->documents = new ArrayCollection();
}

public function getDateCreated()
@@ -299,42 +289,6 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
return $this;
}

public function getDocumentInvoice(): ?DocumentInvoice
{
return $this->documentInvoice;
}

public function setDocumentInvoice(?DocumentInvoice $documentInvoice): self
{
$this->documentInvoice = $documentInvoice;

return $this;
}

public function getDocumentQuotation(): ?DocumentQuotation
{
return $this->documentQuotation;
}

public function setDocumentQuotation(?DocumentQuotation $documentQuotation): self
{
$this->documentQuotation = $documentQuotation;

return $this;
}

public function getDocumentDeliveryNote(): ?DocumentDeliveryNote
{
return $this->documentDeliveryNote;
}

public function setDocumentDeliveryNote(?DocumentDeliveryNote $documentDeliveryNote): self
{
$this->documentDeliveryNote = $documentDeliveryNote;

return $this;
}

public function getVisitor(): ?Visitor
{
return $this->visitor;
@@ -435,4 +389,30 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
return $this;
}

/**
* @return Collection|Document[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}

public function addDocument(Document $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
}

return $this;
}

public function removeDocument(Document $document): self
{
if ($this->documents->contains($document)) {
$this->documents->removeElement($document);
}

return $this;
}

}

+ 0
- 21
ShopBundle/Repository/DocumentDeliveryNoteRepository.php Datei anzeigen

@@ -1,21 +0,0 @@
<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\DocumentDeliveryNoteInterface;

/**
* @method DocumentDeliveryNoteInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method DocumentDeliveryNoteInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method DocumentDeliveryNoteInterface[] findAll()
* @method DocumentDeliveryNoteInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class DocumentDeliveryNoteRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return DocumentDeliveryNoteInterface::class;
}

}

+ 0
- 23
ShopBundle/Repository/DocumentInvoiceRepository.php Datei anzeigen

@@ -1,23 +0,0 @@
<?php

namespace Lc\ShopBundle\Repository;

use App\Entity\DocumentInvoice;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\DocumentInvoiceInterface;

/**
* @method DocumentInvoice|null find($id, $lockMode = null, $lockVersion = null)
* @method DocumentInvoice|null findOneBy(array $criteria, array $orderBy = null)
* @method DocumentInvoice[] findAll()
* @method DocumentInvoice[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class DocumentInvoiceRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return DocumentInvoiceInterface::class;
}
}

+ 0
- 23
ShopBundle/Repository/DocumentQuotationRepository.php Datei anzeigen

@@ -1,23 +0,0 @@
<?php

namespace Lc\ShopBundle\Repository;

use App\Entity\DocumentQuotation;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\DocumentQuotationInterface;

/**
* @method DocumentQuotation|null find($id, $lockMode = null, $lockVersion = null)
* @method DocumentQuotation|null findOneBy(array $criteria, array $orderBy = null)
* @method DocumentQuotation[] findAll()
* @method DocumentQuotation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class DocumentQuotationRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return DocumentQuotationInterface::class;
}
}

+ 23
- 0
ShopBundle/Repository/DocumentRepository.php Datei anzeigen

@@ -0,0 +1,23 @@
<?php

namespace Lc\ShopBundle\Repository;

use App\Entity\DocumentQuotation;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\DocumentInterface;

/**
* @method Document|null find($id, $lockMode = null, $lockVersion = null)
* @method Document|null findOneBy(array $criteria, array $orderBy = null)
* @method Document[] findAll()
* @method Document[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class DocumentRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return DocumentInterface::class;
}
}

+ 29
- 0
ShopBundle/Services/OrderUtils.php Datei anzeigen

@@ -5,6 +5,7 @@ namespace Lc\ShopBundle\Services;
use App\Entity\OrderProductReductionCatalog;
use App\Entity\OrderShop;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\DocumentInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
@@ -15,6 +16,7 @@ use Lc\ShopBundle\Context\ProductFamilyUtilsInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Context\ReductionCreditInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Model\Document;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Core\Security;

@@ -348,6 +350,7 @@ class OrderUtils

}
}*/

public function mergeOrderShops($orderShop1, $orderShop2)
{
if ($orderShop1 && $orderShop2) {
@@ -364,4 +367,30 @@ class OrderUtils
return $orderShop1;
}
}

public function createDocumentInvoice(OrderShopInterface $orderShop)
{
$documentClass = $this->em->getClassMetadata(DocumentInterface::class)->getName();
$invoice = new $documentClass ;

$merchantAddress = $orderShop->getMerchant()->getAddress() ;
$buyerAddress = $orderShop->getBillingAddress() ;

$invoice->addOrderShop($orderShop) ;
$invoice->setType(Document::TYPE_INVOICE) ;
$invoice->setTitle('Test facture') ;
$invoice->setStatus(1) ;
$invoice->setReference('0001') ;
$invoice->setMerchantAddress($merchantAddress) ;
$invoice->setBuyerAddress($buyerAddress) ;
$invoice->setMerchantAddressText($merchantAddress->getSummary()) ;
$invoice->setBuyerAddressText($buyerAddress->getSummary()) ;
$invoice->setCreatedBy($orderShop->getUser()) ;
$invoice->setUpdatedBy($orderShop->getUser()) ;

$this->em->persist($invoice);
$this->em->flush() ;

return $invoice ;
}
}

Laden…
Abbrechen
Speichern