<commit_before>namespace :payments do
  desc "Report withholdings"
  task :withheld => :environment do
    require 'csv'

    csv = CSV.generate do |csv|
      csv << ['Requested At', 'Paid At', 'Username', 'Email', 'Total Requested', 'Amount Withheld', 'Amount Paid']
      User::Withdrawal.paid.where('amount_withheld > 0').order(:created_at).each do |w|
        csv << [
          w.created_at.iso8601,
          w.payment_sent_at.iso8601,
          w.user.username,
          w.user.email,
          w.total_amount,
          w.amount_withheld,
          w.total_amount - w.amount_withheld
        ]
      end
    end

    puts csv
  end
end<commit_msg>add tax info rake task<commit_after>namespace :payments do
  desc "Report withholdings"
  task :withheld => :environment do
    require 'csv'

    csv = CSV.generate do |csv|
      csv << ['Requested At', 'Paid At', 'Username', 'Email', 'Total Requested', 'Amount Withheld', 'Amount Paid']
      User::Withdrawal.paid.where('amount_withheld > 0').order(:created_at).each do |w|
        csv << [
          w.created_at.iso8601,
          w.payment_sent_at.iso8601,
          w.user.username,
          w.user.email,
          w.total_amount,
          w.amount_withheld,
          w.total_amount - w.amount_withheld
        ]
      end
    end

    puts csv
  end

  desc "Report tax information"
  task :tax_info => :environment do
    require 'csv'

    csv = CSV.generate do |csv|
      csv << [
        'Full Name',
        'Form Type',
        'Business Name',
        'Tax ID',
        'Taxpayer Type',
        'Classification',
        'Address',
        'City',
        'State',
        'Zip',
        'Country',
        'Foreign Tax ID',
        'Reference Number',
        'Date of Birth',
        'Signatory',
        'Citizenship',
        'Mailing Address',
        'Mailing City',
        'Mailing State',
        'Mailing Zip',
        'Mailing Country',
        'Treaty Article',
        'Treaty Withholding',
        'Treaty Income Type',
        'Treaty Reasons',
        'Signature Capacity',
      ]
      User.where(id: User::Withdrawal.paid.group(:user_id).pluck(:user_id)).joins(:tax_info).order('user_tax_infos.full_name').each do |user|
        i = user.tax_info
        csv << [
          i.full_name,
          i.type,
          i.business_name,
          i.taxpayer_id,
          i.taxpayer_type,
          i.classification,
          i.address,
          i.city,
          i.state,
          i.zip,
          i.country,
          i.foreign_tax_id,
          i.reference_number,
          i.date_of_birth,
          i.signatory,
          i.citizenship,
          i.mailing_address,
          i.mailing_city,
          i.mailing_state,
          i.mailing_zip,
          i.mailing_country,
          i.treaty_article,
          i.treaty_withholding,
          i.treaty_income_type,
          i.treaty_reasons,
          i.signature_capacity,
        ]
      end
    end

    puts csv
  end

end
{'fraction_non_alphanumeric': 0.1134989926124916, 'fraction_numerical': 0.006044325050369375, 'mean_word_length': 1.723034734917733, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 8, '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': '1967439', 'n_tokens_mistral': 991, 'n_tokens_neox': 940, 'n_words': 199}