code: protected function refreshProductBuyPrices(ProductInterface $product)
      {
          $buyPrice    = $product->getBuyPrice();
          $grossAmount = $buyPrice->getGrossAmount();
          $taxRate     = $product->getBuyPriceTax()->getValue();
          $netAmount   = TaxHelper::calculateNetPrice($grossAmount, $taxRate);
          
          $buyPrice->setTaxRate($taxRate);
          $buyPrice->setTaxAmount($grossAmount - $netAmount);
          $buyPrice->setNetAmount($netAmount);
      }
docs: Recalculates buy prices for product
  
  @param ProductInterface $product