DoubleEntry v2.0.0.beta1 Release Notes

Release Date: 2018-12-31 // over 5 years ago
  • ➕ Added

    • ➕ Added contributor credits to README.

    • ➕ Added support for Ruby 2.3, 2.4, 2.5 and 2.6.

    • ➕ Added support for Rails 5.0, 5.1 and 5.2

    • 👌 Support passing an array of metadata values.

      DoubleEntry.transfer(
        Money.new(20_00),
        :from     => one_account,
        :to       => another_account,
        :code     => :a_business_code_for_this_type_of_transfer,
        :metadata => { :key1 => ['value 1', 'value 2'], :key2 => 'value 3' },
      )
      
    • 👍 Allow partner account to be specified for aggregates.

    • 👍 Allow filtering aggregates by multiple metadata key/value pairs.

    • Add index on the double_entry_line_checks table. This covers the query to obtain the last line check.

    Add this index to your database via a migration like:

    ```ruby
    def up
      add_index "double_entry_line_checks", ["created_at", "last_line_id"], :name => "line_checks_created_at_last_line_id_idx"
    end
    ```
    
    • 🌲 Log account balance cache errors to the database when performing the line check: DoubleEntry::Validation::LineCheck::perform!

    🔄 Changed

    • ✅ Replaced Machinist with Factory Bot in test suite.

    • Implement DoubleEntry::Transfer::Set and DoubleEntry::Account::Set with Hashes rather than Arrays for performance.

    • Reporting API now uses keyword arguments. Note these reporting classes are marked API private: their interface is not considered stable.

      • DoubleEntry::Reporting::aggregate
      • DoubleEntry::Reporting::aggregate_array
      • DoubleEntry::Reporting::Aggregate::new
      • DoubleEntry::Reporting::Aggregate::formatted_amount
      • DoubleEntry::Reporting::AggregateArray::new
      • DoubleEntry::Reporting::LineAggregateFilter::new
    • 0️⃣ Loosened database string column contstraints to the default (255 characters). Engineering teams can choose to apply this change, or apply their own column length constraints specific to their needs. (#152)

    • ✂ Removed default values for the length checks on code, account and scope (#152). These checks will now only be performed when configured with a value:

       DoubleEntry.configure do |config|
         config.code_max_length = 47
         config.account_identifier_max_length = 31
         config.scope_identifier_max_length = 23
       end
    
    • 👉 Use bigint for monetary values in the database to avoid integer overflow (#154). Apply changes via this migration:
       change_column :double_entry_account_balances, :balance, :bigint, null: false
    
       change_column :double_entry_line_aggregates, :amount, :bigint, null: false
    
       change_column :double_entry_lines, :amount, :bigint, null: false
       change_column :double_entry_lines, :balance, :bigint, null: false
    
    • 🚅 On Rails version 5.1 and above, use bigint for foreign key values in the database to avoid integer overflow (#154). Apply changes via this migration:
       change_column :double_entry_line_checks, :last_line_id, :bigint, null: false
    
       change_column :double_entry_line_metadata, :line_id, :bigint, null: false
    
       change_column :double_entry_lines, :partner_id, :bigint, null: true
       change_column :double_entry_lines, :detail_id, :bigint, null: true
    
    • 0️⃣ Line check validation no-longer performs corrections by default. The DoubleEntry::Validation::LineCheck::perform! method will only log validation failures in the database. To perform auto-correction pass the fixer option: LineCheck.perform!(fixer: DoubleEntry::Validation::AccountFixer.new)

    ✂ Removed

    • ✂ Removed support for Ruby 1.9, 2.0, 2.1 and 2.2.

    • ✂ Removed support for Rails 3.2, 4.0, and 4.1.

    • ✂ Removed unneeded development dependencies from Gemspec.

    • ✂ Removed spec and script files from gem package.

    • Removed the active_record_scope_identifier method for configuring scoped accounts.

      user_scope = accounts.active_record_scope_identifier(User)
      

    As a replacement, please define your own with a lambda:

    ```ruby
    user_scope = ->(user) do
      raise 'not a User' unless user.class.name == 'User'
      user.id
    end
    ```
    

    🛠 Fixed

    • 🛠 Fixed more Ruby warnings.

    • 👉 Use double_entry namespace when publishing to ActiveSupport::Notifications.

    • 🛠 Fixed problem of Rails version number not being set in migration template for apps using Rails 5 or higher.