<commit_before>module InvoicePrinter
  class PDFDocument
    # Expose the document as an array of attributes in order as their
    # appear on PDF
    def to_a
      strings = []

      strings << @labels[:name]
      strings << @document.number

      strings << @labels[:provider]
      strings << @document.provider_name
      strings << "#{@document.provider_street}    #{@document.provider_street_number}".strip
      strings << @document.provider_postcode
      strings << @document.provider_city
      strings << @document.provider_city_part
      strings << @document.provider_extra_address_line

      strings << "#{@labels[:ic]}:    #{@document.provider_ic}" unless @document.provider_ic.empty?
      strings << "#{@labels[:dic]}:    #{@document.provider_dic}" unless @document.provider_dic.empty?

      strings << @labels[:purchaser]
      strings << @document.purchaser_name
      strings << "#{@document.purchaser_street}    #{@document.purchaser_street_number}".strip
      strings << @document.purchaser_postcode
      strings << @document.purchaser_city
      strings << @document.purchaser_city_part
      strings << @document.purchaser_extra_address_line

      strings << "#{@labels[:ic]}:    #{@document.purchaser_ic}" unless @document.purchaser_ic.empty?
      strings << "#{@labels[:dic]}:    #{@document.purchaser_dic}" unless @document.purchaser_dic.empty?

      # Account
      if @document.bank_account_number.nil?
        strings << @labels[:payment_in_cash]
      else
        strings << @labels[:payment_by_transfer]
      end

      strings << "#{@labels[:account_number]}:"
      strings << @document.bank_account_number
      strings << "#{@labels[:swift]}:"
      strings << @document.account_swift
      strings << "#{@labels[:iban]}:"
      strings << @document.account_iban

      # Dates
      strings << "#{@labels[:issue_date]}:"
      strings << @document.issue_date
      strings << "#{@labels[:due_date]}:"
      strings << @document.due_date

      strings << items_table
      strings << totals_table

      # TODO: dynamically test page numbers
      #strings << '1 / 1'

      strings.flatten.reject(&:empty?)
    end

    private

    # Strings representaion of items table
    def items_table
      strings = []
      strings << @labels[:item] if determine_items_structure[:names]
      strings << @labels[:quantity] if determine_items_structure[:quantities]
      strings << @labels[:unit] if determine_items_structure[:units]
      strings << @labels[:price_per_item] if determine_items_structure[:prices]
      strings << @labels[:tax] if determine_items_structure[:taxes]
      strings << @labels[:amount] if determine_items_structure[:amounts]
      strings << items_to_a(@document.items)
      strings
    end

    # Strings representaion of totals table
    def totals_table
      strings = []
      strings << "#{@labels[:subtotal]}:"
      strings << @document.subtotal
      strings << "#{@labels[:tax]}:"
      strings << @document.tax
      strings << "#{@labels[:tax2]}:"<commit_msg>Refactor boxes string representations<commit_after>module InvoicePrinter
  class PDFDocument
    # Expose the document as an array of attributes in order as their
    # appear on PDF
    def to_a
      strings = []

      strings << @labels[:name]
      strings << @document.number

      strings << provider_box
      strings << purchaser_box

      # Account
      if @document.bank_account_number.nil?
        strings << @labels[:payment_in_cash]
      else
        strings << @labels[:payment_by_transfer]
      end

      strings << "#{@labels[:account_number]}:"
      strings << @document.bank_account_number
      strings << "#{@labels[:swift]}:"
      strings << @document.account_swift
      strings << "#{@labels[:iban]}:"
      strings << @document.account_iban

      # Dates
      strings << "#{@labels[:issue_date]}:"
      strings << @document.issue_date
      strings << "#{@labels[:due_date]}:"
      strings << @document.due_date

      strings << items_table
      strings << totals_table

      # TODO: dynamically test page numbers
      #strings << '1 / 1'

      strings.flatten.reject(&:empty?)
    end

    private

    # Strings representaion of provider's box
    def provider_box
      strings = []
      strings << @labels[:provider]
      strings << @document.provider_name
      strings << "#{@document.provider_street}    #{@document.provider_street_number}".strip
      strings << @document.provider_postcode
      strings << @document.provider_city
      strings << @document.provider_city_part
      strings << @document.provider_extra_address_line
      strings << "#{@labels[:ic]}:    #{@document.provider_ic}" unless @document.provider_ic.empty?
      strings << "#{@labels[:dic]}:    #{@document.provider_dic}" unless @document.provider_dic.empty?
      strings
    end

    # Strings representaion of purchaser's box
    def purchaser_box
      strings = []
      strings << @labels[:purchaser]
      strings << @document.purchaser_name
      strings << "#{@document.purchaser_street}    #{@document.purchaser_street_number}".strip
      strings << @document.purchaser_postcode
      strings << @document.purchaser_city
      strings << @document.purchaser_city_part
      strings << @document.purchaser_extra_address_line
      strings << "#{@labels[:ic]}:    #{@document.purchaser_ic}" unless @document.purchaser_ic.empty?
      strings << "#{@labels[:dic]}:    #{@document.purchaser_dic}" unless @document.purchaser_dic.empty?
      strings
    end

    # Strings representaion of items table
    def items_table
      strings = []
      strings << @labels[:item] if determine_items_structure[:names]
      strings << @labels[:quantity] if determine_items_structure[:quantities]
      strings << @labels[:unit] if determine_items_structure[:units]
      strings << @labels[:price_per_item] if determine_items_structure[:prices]
      strings << @labels[:tax] if determine_items_structure[:taxes]
      strings << @labels[:amount] if determine_items_structure[:amounts]
      strings << items_to_a(@document.items)
      strings
    end

    # Strings representaion of totals table
    def totals_table
      strings = []
      strings << "#{@labels[:subtotal]}:"
      strings << @document.subtotal
      strings << "#{@labels[:tax]}:"
      strings << @document.tax
      strings << "#{@labels[:tax2]}:"
{'fraction_non_alphanumeric': 0.13137316233969346, 'fraction_numerical': 0.0009383797309978105, 'mean_word_length': 3.260493004663558, 'pattern_counts': {'":': 0, '<': 195, '<?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': '6491823', 'n_tokens_mistral': 1869, 'n_tokens_neox': 1824, 'n_words': 376}