<commit_before>module Fakturan
  class Invoice < Base
    uri "invoices/(:id)"

    # The foreign_key decides which attribute will be used to set the id
    belongs_to :client, uri: "clients/:id", foreign_key: 'client_id'
    has_one :address, uri: nil
    
    has_many :rows, uri: nil

    accepts_nested_attributes_for :rows, :address, :client

    # These create getter methods on new instances, mostly for use in forms
    attributes :number, :date, :client_id, :days, :our_reference, :your_reference, :sent, :paid, :paid_at, :interval_period, :auto_send, :recurring, :last_day_of_month, :start_recurring_from, :locale, :currency

    def rows=(attrs_or_obj_array)
      if attrs_or_obj_array.first.respond_to?(:each)
        send(:rows_attributes=, attrs_or_obj_array)
      else<commit_msg>Client_id should of course be optional.<commit_after>module Fakturan
  class Invoice < Base
    uri "invoices/(:id)"

    # The foreign_key decides which attribute will be used to set the id
    belongs_to :client, uri: "clients/(:id)", foreign_key: 'client_id'
    has_one :address, uri: nil
    
    has_many :rows, uri: nil

    accepts_nested_attributes_for :rows, :address, :client

    # These create getter methods on new instances, mostly for use in forms
    attributes :number, :date, :client_id, :days, :our_reference, :your_reference, :sent, :paid, :paid_at, :interval_period, :auto_send, :recurring, :last_day_of_month, :start_recurring_from, :locale, :currency

    def rows=(attrs_or_obj_array)
      if attrs_or_obj_array.first.respond_to?(:each)
        send(:rows_attributes=, attrs_or_obj_array)
      else
{'fraction_non_alphanumeric': 0.10049321824907521, 'fraction_numerical': 0.0, 'mean_word_length': 4.4280936454849495, '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': '3277829', 'n_tokens_mistral': 537, 'n_tokens_neox': 533, 'n_words': 150}