Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

34 linhas
1.2KB

  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\Resolver\Reference\DocumentReferenceResolver;
  6. class DocumentBuilder
  7. {
  8. protected DocumentReferenceResolver $documentReferenceResolver;
  9. public function __construct(DocumentReferenceResolver $documentReferenceResolver)
  10. {
  11. $this->documentReferenceResolver = $documentReferenceResolver;
  12. }
  13. public function initFromOrderShop(DocumentInterface $document, OrderShopInterface $orderShop)
  14. {
  15. $merchantAddress = $orderShop->getMerchant()->getAddress();
  16. $buyerAddress = $orderShop->getInvoiceAddress();
  17. $document->setReference($this->documentReferenceResolver->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. }