<commit_before>module Tray
  module Calculator
    class Register
      include Virtus.model

      attribute :event
      attribute :package
      attribute :line_items, Tray::Models::LineItemCollection[Tray::Models::LineItem], default: []
      attribute :line_items_total, Integer, default: 0
      attribute :applied_codes, Array[Hash], default: []
      attribute :applied_credits, Array[Hash], default: []
      attribute :applied_subscriptions, Array[Hash], default: []
      attribute :applied_reduction_codes, Array[Hash], default: []

      def discounted_total
        ttl_with_delivery_fee = line_items_total + delivery_fee_in_cents
        ttl_less_credits = ttl_with_delivery_fee - customer_credits_total
        ttl_less_membership = ttl_less_credits - membership_discount_total
        ttl_less_reduction = ttl_less_membership - reduction_code_credit_total
        #Totals Can't Go Negative
        [ttl_less_reduction, 0.0].max
      end

      def bare_ticket_cost
        line_items.reduce(0) do |memo, item|
          ticket_price = item.entity.price_for_level_in_cents(item.options[:price_level])
          memo += ticket_price * (item.quantity || 1)
        end
      end

      def delivery_method
        line_items.first.options[:delivery_method]
      end

      def delivery_fee_in_cents
        line_items.first.delivery_fee
      end<commit_msg>Need to subtract promo code from discountable total.<commit_after>module Tray
  module Calculator
    class Register
      include Virtus.model

      attribute :event
      attribute :package
      attribute :line_items, Tray::Models::LineItemCollection[Tray::Models::LineItem], default: []
      attribute :line_items_total, Integer, default: 0
      attribute :applied_codes, Array[Hash], default: []
      attribute :applied_credits, Array[Hash], default: []
      attribute :applied_subscriptions, Array[Hash], default: []
      attribute :applied_reduction_codes, Array[Hash], default: []

      def discounted_total
        ttl_with_delivery_fee = line_items_total + delivery_fee_in_cents
        ttl_less_credits = ttl_with_delivery_fee - customer_credits_total - promo_code_total
        ttl_less_membership = ttl_less_credits - membership_discount_total
        ttl_less_reduction = ttl_less_membership - reduction_code_credit_total
        #Totals Can't Go Negative
        [ttl_less_reduction, 0.0].max
      end

      def bare_ticket_cost
        line_items.reduce(0) do |memo, item|
          ticket_price = item.entity.price_for_level_in_cents(item.options[:price_level])
          memo += ticket_price * (item.quantity || 1)
        end
      end

      def delivery_method
        line_items.first.options[:delivery_method]
      end

      def delivery_fee_in_cents
        line_items.first.delivery_fee
      end
{'fraction_non_alphanumeric': 0.07412687099073414, 'fraction_numerical': 0.003563791874554526, 'mean_word_length': 3.253030303030303, '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': '7296807', 'n_tokens_mistral': 870, 'n_tokens_neox': 816, 'n_words': 167}