12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- /**
- * 2007-2021 PrestaShop
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Academic Free License (AFL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/afl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@prestashop.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
- * versions in the future. If you wish to customize PrestaShop for your
- * needs please refer to http://www.prestashop.com for more information.
- *
- * @author PrestaShop SA <contact@prestashop.com>
- * @copyright 2007-2021 PrestaShop SA
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
- * International Registered Trademark & Property of PrestaShop SA
- */
- namespace Core\App\Service;
- class InvoiceService
- {
- protected $marketplaceInvoiceRepository;
- protected $marketplaceProductRepository;
- protected $facturisInvoiceRepository;
- protected $facturisCustomerRepository;
- protected $facturisProductRepository;
- protected $settingsRepository;
- public function __construct(
- \Core\App\Repository\Marketplace\InvoiceInterface $marketplaceInvoiceRepository,
- \Core\App\Repository\Marketplace\ProductInterface $marketplaceProductRepository,
- \Core\App\Repository\Facturis\CustomerInterface $facturisCustomerRepository,
- \Core\App\Repository\Facturis\ProductInterface $facturisProductRepository,
- \Core\App\Repository\Facturis\InvoiceInterface $facturisInvoiceRepository,
- \Core\App\Repository\Marketplace\SettingsInterface $settingsRepository
- ) {
- $this->marketplaceInvoiceRepository = $marketplaceInvoiceRepository;
- $this->marketplaceProductRepository = $marketplaceProductRepository;
- $this->facturisInvoiceRepository = $facturisInvoiceRepository;
- $this->facturisCustomerRepository = $facturisCustomerRepository;
- $this->facturisProductRepository = $facturisProductRepository;
- $this->settingsRepository = $settingsRepository;
- }
- public function add($orderId)
- {
- $facturisCustomers = $this->facturisCustomerRepository->getAll();
- $facturisProducts = $this->facturisProductRepository->getAll();
- $this->marketplaceInvoiceRepository->setRemoteCustomers($facturisCustomers);
- $this->marketplaceInvoiceRepository->setRemoteProducts($facturisProducts);
- /*if(!empty($series))
- {
- $this->marketplaceInvoiceRepository->setInvoiceSerie($series);
- }
- else
- {
- $this->marketplaceInvoiceRepository->setInvoiceSerie($this->settingsRepository->getOptionProformaSerie());
- }*/
-
- $this->marketplaceInvoiceRepository->setInvoiceSerie($this->settingsRepository->getOptionInvoiceSerie());
- $withOutDiscount = true;
- $marketplaceProducts = $this->marketplaceProductRepository->getAll($withOutDiscount);
- $this->marketplaceInvoiceRepository->setLocalProducts((array) $marketplaceProducts);
- $this->marketplaceInvoiceRepository->setWithDiscount($this->settingsRepository->getOptionWithDiscount());
- $marketplaceInvoice = $this->marketplaceInvoiceRepository->getByOrderId($orderId);
- if (!empty($marketplaceInvoice)) {
- $result = $this->facturisInvoiceRepository->add($marketplaceInvoice);
- // $this->marketplaceInvoiceRepository->addInvoice($marketplaceInvoice, $result);
- return $result;
- }
- }
- }
|