No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

DocumentBuilder.php 1.2KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Lc\CaracoleBundle\Builder\File;
  3. use Lc\CaracoleBundle\Model\File\DocumentInterface;
  4. use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
  5. use Lc\CaracoleBundle\Generator\DocumentReferenceGenerator;
  6. class DocumentBuilder
  7. {
  8. protected DocumentReferenceGenerator $documentReferenceGenerator;
  9. public function __construct(DocumentReferenceGenerator $documentReferenceGenerator)
  10. {
  11. $this->documentReferenceGenerator = $documentReferenceGenerator;
  12. }
  13. public function initFromOrderShop(DocumentInterface $document, OrderShopInterface $orderShop) :DocumentInterface
  14. {
  15. $merchantAddress = $orderShop->getMerchant()->getAddress();
  16. $buyerAddress = $orderShop->getInvoiceAddress();
  17. $document->setReference($this->documentReferenceGenerator->buildReference($orderShop->getMerchant())) ;
  18. $document->setMerchantAddress($merchantAddress);
  19. $document->setBuyerAddress($buyerAddress);
  20. $document->setMerchantAddressText($merchantAddress->getSummary());
  21. $document->setBuyerAddressText($buyerAddress->getSummary());
  22. $document->addOrderShop($orderShop);
  23. $document->setCreatedBy($orderShop->getUser());
  24. return $document;
  25. }
  26. }