|
12345678910111213141516171819202122232425262728293031323334 |
- <?php
-
- namespace Lc\CaracoleBundle\Builder\File;
-
- use Lc\CaracoleBundle\Model\File\DocumentInterface;
- use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
- use Lc\CaracoleBundle\Generator\DocumentReferenceGenerator;
-
- class DocumentBuilder
- {
- protected DocumentReferenceGenerator $documentReferenceGenerator;
-
- public function __construct(DocumentReferenceGenerator $documentReferenceGenerator)
- {
- $this->documentReferenceGenerator = $documentReferenceGenerator;
- }
-
- public function initFromOrderShop(DocumentInterface $document, OrderShopInterface $orderShop) :DocumentInterface
- {
- $merchantAddress = $orderShop->getMerchant()->getAddress();
- $buyerAddress = $orderShop->getInvoiceAddress();
-
- $document->setReference($this->documentReferenceGenerator->buildReference($orderShop->getMerchant())) ;
- $document->setMerchantAddress($merchantAddress);
- $document->setBuyerAddress($buyerAddress);
- $document->setMerchantAddressText($merchantAddress->getSummary());
- $document->setBuyerAddressText($buyerAddress->getSummary());
- $document->addOrderShop($orderShop);
- $document->setCreatedBy($orderShop->getUser());
-
- return $document;
- }
-
- }
|