12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace Core\App\Service;
- class ProformaService {
- protected $marketplaceProformaRepository;
- protected $marketplaceProductRepository;
- protected $facturisProformaRepository;
- protected $facturisCustomerRepository;
- protected $facturisProductRepository;
- protected $settingsRepository;
- public function __construct(
- \Core\App\Repository\Marketplace\ProformaInterface $marketplaceProformaRepository,
- \Core\App\Repository\Marketplace\ProductInterface $marketplaceProductRepository,
- \Core\App\Repository\Facturis\CustomerInterface $facturisCustomerRepository,
- \Core\App\Repository\Facturis\ProductInterface $facturisProductRepository,
- \Core\App\Repository\Facturis\ProformaInterface $facturisProformaRepository,
- \Core\App\Repository\Marketplace\SettingsInterface $settingsRepository
- )
- {
- $this->marketplaceProformaRepository = $marketplaceProformaRepository;
- $this->marketplaceProductRepository = $marketplaceProductRepository;
- $this->facturisProformaRepository = $facturisProformaRepository;
- $this->facturisCustomerRepository = $facturisCustomerRepository;
- $this->facturisProductRepository = $facturisProductRepository;
- $this->settingsRepository = $settingsRepository;
- }
- public function sync() {
- $facturisCustomers = $this->facturisCustomerRepository->getAll();
- $facturisProducts = $this->facturisProductRepository->getAll();
- $this->marketplaceProformaRepository->setRemoteCustomers($facturisCustomers);
- $this->marketplaceProformaRepository->setRemoteProducts($facturisProducts);
- $this->marketplaceProformaRepository->setOrderedDaysAgo($this->settingsRepository->getOptionOrderedDaysAgo());
- $this->marketplaceProformaRepository->setProformaSerie($this->settingsRepository->getOptionProformaSerie());
- $withOutDiscount = true;
- $marketplaceProducts = $this->marketplaceProductRepository->getAll($withOutDiscount);
- $this->marketplaceProformaRepository->setLocalProducts((array) $marketplaceProducts);
- $this->marketplaceProformaRepository->setWithDiscount($this->settingsRepository->getOptionWithDiscount());
- $marketplaceProformas = $this->marketplaceProformaRepository->getAll();
- if(!empty($marketplaceProformas))
- {
- foreach($marketplaceProformas as $marketplaceProforma)
- {
- $result = $this->facturisProformaRepository->add($marketplaceProforma);
- //$this->marketplaceProformaRepository->addProforma($marketplaceProforma, $result);
- }
- }
- }
- }
|