<commit_before>class InstrumentPricePolicy < PricePolicy
  @@intervals = [1, 5, 10, 15, 30, 60]

  belongs_to :instrument, :class_name => 'Product', :foreign_key => :instrument_id

  validates_numericality_of :minimum_cost, :usage_rate, :reservation_rate, :overage_rate, :usage_subsidy, :overage_subsidy, :reservation_subsidy, :cancellation_cost, :allow_nil => true, :greater_than_or_equal_to => 0
  validates_inclusion_of :usage_mins, :reservation_mins, :overage_mins, :in => @@intervals, :unless => :restrict_purchase
  validates_presence_of :usage_rate, :unless => lambda { |o| o.usage_subsidy.nil? || o.restrict_purchase?}
  validates_presence_of :reservation_rate, :unless => lambda { |o| o.reservation_subsidy.nil? || o.restrict_purchase?}
  validate :has_usage_or_reservation_rate?, :unless => :restrict_purchase
  validate :subsidy_less_than_rate?, :unless => :restrict_purchase

  scope :current,  lambda { |instrument|             { :conditions => [dateize('start_date', ' = ? AND instrument_id = ?'), current_date(instrument), instrument.id] } }
  scope :next,     lambda { |instrument|             { :conditions => [dateize('start_date', ' = ? AND instrument_id = ?'), next_date(instrument), instrument.id] } }
  scope :for_date, lambda { |instrument, start_date| { :conditions => [dateize('start_date', ' = ? AND instrument_id = ?'), start_date, instrument.id] } }

  before_save do |o|
    o.usage_subsidy       = 0 if o.usage_subsidy.nil?       && !o.usage_rate.nil?<commit_msg>Task #36227 : Forced to enter "0" in Actual when creating price rule with only "Scheduled" pricing<commit_after>class InstrumentPricePolicy < PricePolicy
  @@intervals = [1, 5, 10, 15, 30, 60]

  belongs_to :instrument, :class_name => 'Product', :foreign_key => :instrument_id

  validates_numericality_of :minimum_cost, :usage_rate, :reservation_rate, :overage_rate, :usage_subsidy, :overage_subsidy, :reservation_subsidy, :cancellation_cost, :allow_nil => true, :greater_than_or_equal_to => 0
  validates_inclusion_of :usage_mins, :reservation_mins, :overage_mins, :in => @@intervals, :unless => :restrict_purchase
  validates_presence_of :usage_rate, :unless => lambda { |o| o.reservation_rate || o.usage_subsidy.nil? || o.restrict_purchase?}
  validates_presence_of :reservation_rate, :unless => lambda { |o| o.usage_rate || o.reservation_subsidy.nil? || o.restrict_purchase?}
  validate :has_usage_or_reservation_rate?, :unless => :restrict_purchase
  validate :subsidy_less_than_rate?, :unless => :restrict_purchase

  scope :current,  lambda { |instrument|             { :conditions => [dateize('start_date', ' = ? AND instrument_id = ?'), current_date(instrument), instrument.id] } }
  scope :next,     lambda { |instrument|             { :conditions => [dateize('start_date', ' = ? AND instrument_id = ?'), next_date(instrument), instrument.id] } }
  scope :for_date, lambda { |instrument, start_date| { :conditions => [dateize('start_date', ' = ? AND instrument_id = ?'), start_date, instrument.id] } }

  before_save do |o|
    o.usage_subsidy       = 0 if o.usage_subsidy.nil?       && !o.usage_rate.nil?
{'fraction_non_alphanumeric': 0.1389514313284014, 'fraction_numerical': 0.00964940495336121, 'mean_word_length': 5.386036960985626, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '1196712', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1062, 'n_words': 212}