<commit_before>class DonationApplicationPdf < FillablePdfForm

  def initialize(args = {})
    @user = args[:user]
    @listing = args[:listing]
    @user_questionnaire = Questionnaire.find_by(name: @user.account_type)
    @address = get_sanitized_attributes(@user.addresses.first, Address.new)
    @contact = get_sanitized_attributes(@user.contact_infos.find_by(primary: true), ContactInfo.new)
    @contact_name = "#{@contact[:first_name]} #{@contact[:last_name]}".titleize
    super()
  end

  protected

    def fill_out
      not_applicable = 'N/A'

      fill :donation_request, @listing.description
      fill :email, @user.email.downcase
      fill :title, @contact.title.titleize
      fill :applicant_name, @contact_name

      [:sign_date, :application_date].each do |field|
        fill field, Date.today.to_s
      end

      fill :address, (@address.street_address_1.titleize + ' ' + @address.street_address_2.titleize).strip

      fill :city, @address.city.titleize

      [:phone, :fax].each do |field|
        fill field, @contact.send(field)
      end<commit_msg>Update PDF form filler to find 'primary' setting<commit_after>class DonationApplicationPdf < FillablePdfForm

  def initialize(args = {})
    @user = args[:user]
    @listing = args[:listing]
    @user_questionnaire = Questionnaire.find_by(name: @user.account_type)
    address = @user.addresses.find_by(primary: true) || @user.addresses.first
    contact = @user.contact_infos.find_by(primary: true) || @user.contact_infos.first
    @address = get_sanitized_attributes(address, Address.new)
    @contact = get_sanitized_attributes(contact, ContactInfo.new)
    @contact_name = "#{@contact[:first_name]} #{@contact[:last_name]}".titleize
    super()
  end

  protected

    def fill_out
      not_applicable = 'N/A'

      fill :donation_request, @listing.description
      fill :email, @user.email.downcase
      fill :title, @contact.title.titleize
      fill :applicant_name, @contact_name

      [:sign_date, :application_date].each do |field|
        fill field, Date.today.to_s
      end

      fill :address, (@address.street_address_1.titleize + ' ' + @address.street_address_2.titleize).strip

      fill :city, @address.city.titleize

      [:phone, :fax].each do |field|
        fill field, @contact.send(field)
      end
{'fraction_non_alphanumeric': 0.12316335350043216, 'fraction_numerical': 0.001728608470181504, 'mean_word_length': 3.676767676767677, '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': '2253667', 'n_tokens_mistral': 769, 'n_tokens_neox': 727, 'n_words': 141}