<commit_before>module SpreeQuickbooks
  module Grabbers
    class Inventory
      attr_reader :item_service

      def initialize
        @item_service = SpreeQuickbooks::Services::Item.new
      end

      def perform
        Spree::Variant.all.find_each do |variant|
          @item = item_service.find_by_sku(variant.sku, 'Name, QtyOnHand')
          stock_adjustment = @item.quantity_on_hand.to_i - variant.total_on_hand
          stock_location = Spree::StockLocation.first
          stock_movement = stock_location.stock_movements.build({quantity: stock_adjustment})
          stock_movement.stock_item = stock_location.set_up_stock_item(variant)
          stock_movement.save!
        end
      end
    end
  end
end<commit_msg>Check inventory adjustment<commit_after>module SpreeQuickbooks
  module Grabbers
    class Inventory
      attr_reader :item_service

      def initialize
        @item_service = SpreeQuickbooks::Services::Item.new
      end

      def perform
        Spree::Variant.all.find_each do |variant|
          @item = item_service.find_by_sku(variant.sku, 'Name, QtyOnHand')
          stock_adjustment = @item.quantity_on_hand.to_i - variant.total_on_hand
          if stock_adjustment != 0
            stock_location = Spree::StockLocation.first
            stock_movement = stock_location.stock_movements.build({quantity: stock_adjustment})
            stock_movement.stock_item = stock_location.set_up_stock_item(variant)
            stock_movement.save!
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.06883116883116883, 'fraction_numerical': 0.0006493506493506494, 'mean_word_length': 2.7585365853658534, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3858672', 'n_tokens_mistral': 463, 'n_tokens_neox': 448, 'n_words': 81}