<commit_before>class SettlementCheckJob < Struct.new(:contribution_id)
  def perform
    @contribution = Contribution.find(contribution_id)
    transaction = Braintree::Transaction.find(@contribution.transaction_id)
    
    if transaction.status == 'settled'
      @contribution.increment(:net_amount, @contribution.amount)  # add_amount_to_net
      @contribution.status = 'settled'                            # mark as settled
      @contribution.save!
    else
      raise Stumpwise::Transaction::NotSettledError
    end
  end
end<commit_msg>[FIX] SettlementCheckJob shouldn't "settle" a transaction that's been voided/refunded<commit_after>class SettlementCheckJob < Struct.new(:contribution_id)
  def perform
    @contribution = Contribution.find(contribution_id)
    transaction = Braintree::Transaction.find(@contribution.transaction_id)
    
    if @contribution.approved? # don't do anything if it's been voided or refunded
      if transaction.status == 'settled'
        @contribution.increment(:net_amount, @contribution.amount)  # add_amount_to_net
        @contribution.status = 'settled'                            # mark as settled
        @contribution.save!
      else
        raise Stumpwise::Transaction::NotSettledError
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08589440504334121, 'fraction_numerical': 0.0, 'mean_word_length': 3.3493150684931505, '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': '3606040', 'n_tokens_mistral': 387, 'n_tokens_neox': 353, 'n_words': 73}