15 use Magento\Tax\Setup\TaxSetupFactory;
    22     private $moduleDataSetup;
    27     private $taxRateRepository;
    32     private $searchCriteriaFactory;
    37     private $regionFactory;
    52         $this->moduleDataSetup = $moduleDataSetup;
    53         $this->taxRateRepository = $taxRateRepository;
    54         $this->searchCriteriaFactory = $searchCriteriaFactory;
    55         $this->regionFactory = $regionFactory;
    61     public function apply()
    63         $this->moduleDataSetup->getConnection()->startSetup();
    66         $taxRateList = $this->taxRateRepository->getList($this->searchCriteriaFactory->create());
    68         foreach ($taxRateList->getItems() as $taxRateData) {
    69             $regionCode = $this->parseRegionFromTaxCode($taxRateData->getCode());
    72                 $region = $this->regionFactory->create();
    73                 $region->loadByCode($regionCode, $taxRateData->getTaxCountryId());
    74                 if ($taxRateData->getTaxPostcode() === 
null) {
    75                     $taxRateData->setTaxPostcode(
'*');
    77                 $taxRateData->setTaxRegionId($region->getRegionId());
    78                 $this->taxRateRepository->save($taxRateData);
    81         $this->moduleDataSetup->getConnection()->endSetup();
    90             UpdateTaxClassAttributeVisibility::class
   116     private function parseRegionFromTaxCode($taxCode)
   119         $parts = explode(
'-', $taxCode, 3);
   121         if (isset($parts[1])) {
 
__construct(\Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup, TaxRateRepositoryInterface $taxRateRepository, SearchCriteriaFactory $searchCriteriaFactory, \Magento\Directory\Model\RegionFactory $regionFactory)