<commit_before>module Cmxl
  module Fields
    class AccountBalance < Field
      self.tag = 60
      self.parser = /(?<funds_code>\A[a-zA-Z]{1})(?<date>\d{6})(?<currency>[a-zA-Z]{3})(?<amount>[\d|,|\.]{4,15})/i

      def date
        to_date(data['date'])
      end

      def credit?
        data['funds_code'].to_s.casecmp('C').zero?
      end

      def debit?
        !credit?
      end

      def amount
        to_amount(data['amount'])
      end

      def sign
        credit? ? 1 : -1
      end

      def amount_in_cents
        to_amount_in_cents(data['amount'])
      end

      def to_h
        super.merge(
          'date' => date,
          'funds_code' => funds_code,<commit_msg>allow handling of broken opening balance amounts<commit_after>module Cmxl
  module Fields
    class AccountBalance < Field
      self.tag = 60
      self.parser = /(?<funds_code>\A[a-zA-Z]{1})(?<date>\d{6})(?<currency>[a-zA-Z]{3})(?<amount>[\d|,|\.]{1,15})/i

      def date
        to_date(data['date'])
      end

      def credit?
        data['funds_code'].to_s.casecmp('C').zero?
      end

      def debit?
        !credit?
      end

      def amount
        to_amount(data['amount'])
      end

      def sign
        credit? ? 1 : -1
      end

      def amount_in_cents
        to_amount_in_cents(data['amount'])
      end

      def to_h
        super.merge(
          'date' => date,
          'funds_code' => funds_code,
{'fraction_non_alphanumeric': 0.14954577218728163, 'fraction_numerical': 0.013976240391334731, 'mean_word_length': 1.8582834331337326, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '6593717', 'n_tokens_mistral': 533, 'n_tokens_neox': 488, 'n_words': 93}