<commit_before>module Spree
  class Calculator::DefaultTaxWithShipping < Calculator::DefaultTax
    def self.description
      I18n.t(:default_tax_with_shipping)
    end

    def compute(computable)
      if computable.is_a?(Spree::Adjustment)
        compute_adjustment(computable)
      else
        super(computable)
      end
    end

    private

      def compute_adjustment(adjustment)
        deduced_total_by_rate(adjustment.amount, rate)
      end

      def compute_order(order)
        matched_line_items = order.line_items.select do |line_item|
          line_item.product.tax_category == rate.tax_category
        end

        # computer order total for UK VAT, by calculating vat on each line item separately
        line_items_total = matched_line_items.sum {|li|  round_to_two_places(li.total * rate.amount)}
        debugger
        line_items_total + order.shipments.sum {|shipment| round_to_two_places(shipment.adjustment.amount * rate.amount)}
      end

  end
end<commit_msg>fixing no adjustment bug<commit_after>module Spree
  class Calculator::DefaultTaxWithShipping < Calculator::DefaultTax
    def self.description
      I18n.t(:default_tax_with_shipping)
    end

    def compute(computable)
      if computable.is_a?(Spree::Adjustment)
        compute_adjustment(computable)
      else
        super(computable)
      end
    end

    private

      def compute_adjustment(adjustment)
        deduced_total_by_rate(adjustment.amount, rate)
      end

      def compute_order(order)
        matched_line_items = order.line_items.select do |line_item|
          line_item.product.tax_category == rate.tax_category
        end

        # computer order total for UK VAT, by calculating vat on each line item separately
        line_items_total = matched_line_items.sum {|li|  round_to_two_places(li.total * rate.amount)}
        line_items_total + order.shipments.sum {|shipment| shipment.adjustment ? (round_to_two_places(shipment.adjustment.amount * rate.amount)) : 0}
      end

  end
end
{'fraction_non_alphanumeric': 0.07093253968253968, 'fraction_numerical': 0.00248015873015873, 'mean_word_length': 3.0995934959349594, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6537555', 'n_tokens_mistral': 629, 'n_tokens_neox': 601, 'n_words': 125}