Sha256: 632d8d40eddea41fbca7a2ae5aa0a99660b291d2ce4e6c8e7e64f3828e825c7d

Contents?: true

Size: 836 Bytes

Versions: 6

Compression:

Stored size: 836 Bytes

Contents

# frozen_string_literal: true

module Transformers
  module Formatters
    # Wise card accounts formatter
    class Wise < Formatter
      def initialize
        super({ date: [1], payee: [13], amount: [2] })
      end

      def payee(row)
        merchant = row[13]
        description = row[4]

        return description if merchant.nil?

        merchant
      end

      def memo(row)
        # Description goes in Memo because we'll need to extract the original
        # amount from it in the enhancer.
        description = row[4]
        amount_currency = row[3]
        original_amount = description.scan(/\d+\.\d{2}\s\w{3}/).first

        memo = amount_currency
        # Topups don't have an original amount
        memo = "#{memo},#{original_amount}" unless original_amount.nil?

        memo
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ynab_convert-2.0.6 lib/ynab_convert/transformers/formatters/wise_formatter.rb
ynab_convert-2.0.5 lib/ynab_convert/transformers/formatters/wise_formatter.rb
ynab_convert-2.0.4 lib/ynab_convert/transformers/formatters/wise_formatter.rb
ynab_convert-2.0.3 lib/ynab_convert/transformers/formatters/wise_formatter.rb
ynab_convert-2.0.1 lib/ynab_convert/transformers/formatters/wise_formatter.rb
ynab_convert-2.0.0 lib/ynab_convert/transformers/formatters/wise_formatter.rb