<commit_before><?php
/**
 * User: <NAME> <<EMAIL>>
 */

namespace Praxigento\Odoo\Service\Replicate\Sub;

use Praxigento\Odoo\Config as Cfg;
use Praxigento\Odoo\Data\Agg\Lot as AggLot;
use Praxigento\Odoo\Data\Odoo\Inventory\Lot as ApiLot;
use Praxigento\Odoo\Data\Odoo\Inventory\Warehouse as ApiWarehouse;
use Praxigento\Odoo\Repo\Agg\ILot as IRepoAggLot;
use Praxigento\Odoo\Repo\Agg\IWarehouse as IRepoAggWarehouse;
use Praxigento\Odoo\Repo\IPv as IRepoPv;
use Praxigento\Odoo\Repo\IRegistry;

class Replicator
{
    /** @var  IRepoAggLot */
    protected $repoAggLot;
    /** @var  IRepoAggWarehouse */
    protected $repoAggWrhs;
    /** @var  IRepoPv */
    protected $repoPv;
    /** @var IRegistry */
    protected $repoRegistry;
    /** @var Replicator\Product\Category */
    protected $subProdCategory;
    /** @var Replicator\Product\Warehouse */
    protected $subProdWarehouse;
    /** @var Replicator\Product */
    protected $subProduct;

    public function __construct(
        \Praxigento\Odoo\Repo\IRegistry $repoRegistry,
        \Praxigento\Odoo\Repo\Agg\ILot $repoAggLot,
        \Praxigento\Odoo\Repo\IPv $repoPv,
        \Praxigento\Odoo\Repo\Agg\IWarehouse $repoAggWrhs,
        Replicator\Product $subProduct,
        Replicator\Product\Category $subProdCategory,
        Replicator\Product\Warehouse $subProdWarehouse
    ) {
        $this->repoRegistry = $repoRegistry;
        $this->repoAggLot = $repoAggLot;
        $this->repoPv = $repoPv;
        $this->repoAggWrhs = $repoAggWrhs;
        $this->subProduct = $subProduct;
        $this->subProdCategory = $subProdCategory;
        $this->subProdWarehouse = $subProdWarehouse;
    }

    /**
     * @param ApiLot[] $lots
     * @throws \Exception
     */
    public function processLots($lots)
    {
        /** @var  $data AggLot */
        $data = new \Praxigento\Odoo\Data\Agg\Lot();
        foreach ($lots as $item) {
            $data->setOdooId($item->getIdOdoo());
            $data->setCode($item->getNumber());
            $data->setExpDate($item->getExpirationDate());
            $lotExists = $this->repoAggLot->getByOdooId($data->getOdooId());
            if (!$lotExists) {
                $this->repoAggLot->create($data);
            }
        }
    }

    /**
     * @param \Praxigento\Odoo\Data\Odoo\Inventory\Product $product
     */
    public function processProductItem($product)
    {
        assert($product instanceof \Praxigento\Odoo\Data\Odoo\Inventory\Product);
        $idOdoo = $product->getIdOdoo();
        $sku = $product->getSku();
        $name = $product->getName();
        $isActive = $product->getIsActive();
        $skipReplication = false; // skip replication for inactive products are missed in Mage
        $priceWholesale = $product->getPriceWholesale();
        $weight = $product->getWeight();
        $pvWholesale = $product->getPvWholesale();
        /* check does product item is already registered in Magento */
        if (!$this->repoRegistry->isProductRegisteredInMage($idOdoo)) {
            if ($isActive) {<commit_msg>MOBI-721 - Tax & discount mismatch with the reference order<commit_after><?php
/**
 * User: <NAME> <<EMAIL>>
 */

namespace Praxigento\Odoo\Service\Replicate\Sub;

use Praxigento\Odoo\Config as Cfg;
use Praxigento\Odoo\Data\Agg\Lot as AggLot;
use Praxigento\Odoo\Data\Odoo\Inventory\Lot as ApiLot;
use Praxigento\Odoo\Data\Odoo\Inventory\Warehouse as ApiWarehouse;
use Praxigento\Odoo\Repo\Agg\ILot as IRepoAggLot;
use Praxigento\Odoo\Repo\Agg\IWarehouse as IRepoAggWarehouse;
use Praxigento\Odoo\Repo\IPv as IRepoPv;
use Praxigento\Odoo\Repo\IRegistry;

class Replicator
{
    /** @var  IRepoAggLot */
    protected $repoAggLot;
    /** @var  IRepoAggWarehouse */
    protected $repoAggWrhs;
    /** @var  IRepoPv */
    protected $repoPv;
    /** @var IRegistry */
    protected $repoRegistry;
    /** @var Replicator\Product\Category */
    protected $subProdCategory;
    /** @var Replicator\Product\Warehouse */
    protected $subProdWarehouse;
    /** @var Replicator\Product */
    protected $subProduct;

    public function __construct(
        \Praxigento\Odoo\Repo\IRegistry $repoRegistry,
        \Praxigento\Odoo\Repo\Agg\ILot $repoAggLot,
        \Praxigento\Odoo\Repo\IPv $repoPv,
        \Praxigento\Odoo\Repo\Agg\IWarehouse $repoAggWrhs,
        Replicator\Product $subProduct,
        Replicator\Product\Category $subProdCategory,
        Replicator\Product\Warehouse $subProdWarehouse
    ) {
        $this->repoRegistry = $repoRegistry;
        $this->repoAggLot = $repoAggLot;
        $this->repoPv = $repoPv;
        $this->repoAggWrhs = $repoAggWrhs;
        $this->subProduct = $subProduct;
        $this->subProdCategory = $subProdCategory;
        $this->subProdWarehouse = $subProdWarehouse;
    }

    /**
     * @param ApiLot[] $lots
     * @throws \Exception
     */
    public function processLots($lots)
    {
        /** @var  $data AggLot */
        $data = new \Praxigento\Odoo\Data\Agg\Lot();
        foreach ($lots as $item) {
            $data->setOdooId($item->getIdOdoo());
            $data->setCode($item->getNumber());
            $data->setExpDate($item->getExpirationDate());
            $lotExists = $this->repoAggLot->getByOdooId($data->getOdooId());
            if (!$lotExists) {
                $this->repoAggLot->create($data);
            }
        }
    }

    /**
     * @param \Praxigento\Odoo\Data\Odoo\Inventory\Product $product
     */
    public function processProductItem($product)
    {
        assert($product instanceof \Praxigento\Odoo\Data\Odoo\Inventory\Product);
        $idOdoo = $product->getIdOdoo();
        $sku = trim($product->getSku());
        $name = trim($product->getName());
        $isActive = $product->getIsActive();
        $skipReplication = false; // skip replication for inactive products are missed in Mage
        $priceWholesale = $product->getPriceWholesale();
        $weight = $product->getWeight();
        $pvWholesale = $product->getPvWholesale();
        /* check does product item is already registered in Magento */
        if (!$this->repoRegistry->isProductRegisteredInMage($idOdoo)) {
            if ($isActive) {
{'fraction_non_alphanumeric': 0.13654033041788144, 'fraction_numerical': 0.00048590864917395527, 'mean_word_length': 2.7109375, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3003848', 'n_tokens_mistral': 2208, 'n_tokens_neox': 2189, 'n_words': 347}