code: private function persistAssignment(StockAssignmentInterface $assignment)
      {
          // Remove if empty
          if (0 == $assignment->getSoldQuantity()) {
              $assignment
                  ->setSaleItem(null)
                  ->setStockUnit(null);
  
              $this->persistenceHelper->remove($assignment, true);
  
              return;
          }
  
          // Persist without scheduling event
          $this->persistenceHelper->persistAndRecompute($assignment, true);
      }
docs: Persists (or removes) the stock assignment.
  
  @param StockAssignmentInterface $assignment