<commit_before>module ACH::Records
  class BatchControl < Record
    @fields = []

    const_field :record_type, '8'

    # TODO: many of the fields are calculated in Batch.to_ach, so the defaults
    #       should be removed
    field :service_class_code, String,
        lambda { |f| f.to_s }, '200',
        lambda { |f| ACH::SERVICE_CLASS_CODES.include?(f.to_i) }
    field :entry_count, Integer, lambda { |f| sprintf('%06d', f)}
    field :entry_hash, Integer, lambda { |f| sprintf('%010d', f % (10 ** 10))}
    field :debit_total, Integer, lambda { |f| sprintf('%012d', f)}
    field :credit_total, Integer, lambda { |f| sprintf('%012d', f)}
    field :company_identification_code_designator, String, nil, '1',
        /\A[0-9 ]\z/
    field :company_identification, String,
        nil, nil, /\A\d{9}\z/

    field :message_authentication_code, String,
        lambda { |f| left_justify(f, 19)}, ''

    const_field :reserved, (' ' * 6)

    field :originating_dfi_identification, String,
        nil, nil, /\A\d{8}\z/

    field :batch_number, Integer, lambda { |f| sprintf('%07d', f)}, 1<commit_msg>Fixed batch control company_id regex also<commit_after>module ACH::Records
  class BatchControl < Record
    @fields = []

    const_field :record_type, '8'

    # TODO: many of the fields are calculated in Batch.to_ach, so the defaults
    #       should be removed
    field :service_class_code, String,
        lambda { |f| f.to_s }, '200',
        lambda { |f| ACH::SERVICE_CLASS_CODES.include?(f.to_i) }
    field :entry_count, Integer, lambda { |f| sprintf('%06d', f)}
    field :entry_hash, Integer, lambda { |f| sprintf('%010d', f % (10 ** 10))}
    field :debit_total, Integer, lambda { |f| sprintf('%012d', f)}
    field :credit_total, Integer, lambda { |f| sprintf('%012d', f)}
    field :company_identification_code_designator, String, nil, '1',
        /\A[0-9 ]\z/
    field :company_identification, String,
        nil, nil, /.{9}/

    field :message_authentication_code, String,
        lambda { |f| left_justify(f, 19)}, ''

    const_field :reserved, (' ' * 6)

    field :originating_dfi_identification, String,
        nil, nil, /\A\d{8}\z/

    field :batch_number, Integer, lambda { |f| sprintf('%07d', f)}, 1
{'fraction_non_alphanumeric': 0.15171798304328424, 'fraction_numerical': 0.02677376171352075, 'mean_word_length': 3.246212121212121, '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': '3845776', 'n_tokens_mistral': 815, 'n_tokens_neox': 775, 'n_words': 206}